Skip to content

Commit c77433c

Browse files
committed
Fix check for local statement
1 parent daa5a9b commit c77433c

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
569569

570570
fn is_local_statement(&self, id: hir::HirId) -> bool {
571571
let node = self.tcx.hir().get(id);
572-
matches!(node, Node::Stmt(Stmt { kind: StmtKind::Local(..), .. }))
572+
matches!(node, Node::Local(_))
573573
}
574574
}

src/test/ui/loops/loop-no-implicit-break.stderr

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,22 @@ error[E0308]: mismatched types
33
|
44
LL | 1
55
| ^ expected `()`, found integer
6+
|
7+
help: you might have meant to break the loop with this value
8+
|
9+
LL | break 1;
10+
| +++++ +
611

712
error[E0308]: mismatched types
813
--> $DIR/loop-no-implicit-break.rs:13:9
914
|
1015
LL | 1
1116
| ^ expected `()`, found integer
1217
|
13-
help: you might have meant to return this value
18+
help: you might have meant to break the loop with this value
1419
|
15-
LL | return 1;
16-
| ++++++ +
20+
LL | break 1;
21+
| +++++ +
1722

1823
error[E0308]: mismatched types
1924
--> $DIR/loop-no-implicit-break.rs:21:9

0 commit comments

Comments
 (0)