Check for mutable borrow of counter variable

This commit is contained in:
Nathan Weston
2015-09-10 08:33:29 -04:00
parent 6b57924e81
commit 8a5b4f19fd
2 changed files with 6 additions and 0 deletions
+2
View File
@@ -351,6 +351,7 @@ fn visit_expr(&mut self, expr: &'v Expr) {
}
},
ExprAssign(ref lhs, _) if lhs.id == expr.id => *state = VarState::DontWarn,
ExprAddrOf(mutability,_) if mutability == MutMutable => *state = VarState::DontWarn,
_ => ()
}
}
@@ -430,6 +431,7 @@ fn visit_expr(&mut self, expr: &'v Expr) {
} else {
VarState::DontWarn
}},
ExprAddrOf(mutability,_) if mutability == MutMutable => self.state = VarState::DontWarn,
_ => ()
}
}
+4
View File
@@ -179,4 +179,8 @@ fn main() {
let mut _index = 1;
if false { _index = 0 };
for _v in &vec { _index += 1 }
let mut _index = 0;
{ let mut _x = &mut _index; }
for _v in &vec { _index += 1 }
}