mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-02 18:12:51 +00:00
Check if it's after the loop earlier
This commit is contained in:
parent
116f30dc33
commit
b2d5b89a1d
@ -2250,6 +2250,11 @@ impl<'a, 'tcx> Visitor<'tcx> for InitializeVisitor<'a, 'tcx> {
|
|||||||
|
|
||||||
// If node is the desired variable, see how it's used
|
// If node is the desired variable, see how it's used
|
||||||
if var_def_id(self.cx, expr) == Some(self.var_id) {
|
if var_def_id(self.cx, expr) == Some(self.var_id) {
|
||||||
|
if self.past_loop {
|
||||||
|
self.state = VarState::DontWarn;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(parent) = get_parent_expr(self.cx, expr) {
|
if let Some(parent) = get_parent_expr(self.cx, expr) {
|
||||||
match parent.kind {
|
match parent.kind {
|
||||||
ExprKind::AssignOp(_, ref lhs, _) if lhs.hir_id == expr.hir_id => {
|
ExprKind::AssignOp(_, ref lhs, _) if lhs.hir_id == expr.hir_id => {
|
||||||
@ -2269,10 +2274,6 @@ impl<'a, 'tcx> Visitor<'tcx> for InitializeVisitor<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.past_loop {
|
|
||||||
self.state = VarState::DontWarn;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
walk_expr(self, expr);
|
walk_expr(self, expr);
|
||||||
} else if !self.past_loop && is_loop(expr) {
|
} else if !self.past_loop && is_loop(expr) {
|
||||||
self.state = VarState::DontWarn;
|
self.state = VarState::DontWarn;
|
||||||
|
Loading…
Reference in New Issue
Block a user