mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-22 10:05:06 +03:00
Add an Init mode to MutateMode.
This isn't necessary right now, but check_loans needs to be able to distinguish between initialization and writes in the ExprUseVisitor mutate callback.
This commit is contained in:
@@ -356,7 +356,7 @@ pub fn add_assignment(&self,
|
||||
let path_index = self.move_path(tcx, lp.clone());
|
||||
|
||||
match mode {
|
||||
euv::JustWrite => {
|
||||
euv::Init | euv::JustWrite => {
|
||||
self.assignee_ids.borrow_mut().insert(assignee_id);
|
||||
}
|
||||
euv::WriteAndRead => { }
|
||||
|
||||
@@ -86,6 +86,7 @@ pub enum ConsumeMode {
|
||||
|
||||
#[deriving(PartialEq,Show)]
|
||||
pub enum MutateMode {
|
||||
Init,
|
||||
JustWrite, // x = y
|
||||
WriteAndRead, // x += y
|
||||
}
|
||||
@@ -712,7 +713,7 @@ fn walk_pat(&mut self, cmt_discr: mc::cmt, pat: @ast::Pat) {
|
||||
let def = def_map.borrow().get_copy(&pat.id);
|
||||
match mc.cat_def(pat.id, pat.span, pat_ty, def) {
|
||||
Ok(binding_cmt) => {
|
||||
delegate.mutate(pat.id, pat.span, binding_cmt, JustWrite);
|
||||
delegate.mutate(pat.id, pat.span, binding_cmt, Init);
|
||||
}
|
||||
Err(_) => { }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user