mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-17 05:25:37 +03:00
Check for mutable borrow of counter variable
This commit is contained in:
@@ -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,
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user