mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 00:03:43 +00:00
Check for mutable borrow of counter variable
This commit is contained in:
parent
6b57924e81
commit
8a5b4f19fd
@ -351,6 +351,7 @@ impl<'v, 't> Visitor<'v> for IncrementVisitor<'v, 't> {
|
||||
}
|
||||
},
|
||||
ExprAssign(ref lhs, _) if lhs.id == expr.id => *state = VarState::DontWarn,
|
||||
ExprAddrOf(mutability,_) if mutability == MutMutable => *state = VarState::DontWarn,
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
@ -430,6 +431,7 @@ impl<'v, 't> Visitor<'v> for InitializeVisitor<'v, 't> {
|
||||
} 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 }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user