diff options
| author | bors <bors@rust-lang.org> | 2023-09-14 19:56:55 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-09-14 19:56:55 +0000 |
| commit | dac91a82e146d89fefe94dcbb53cd6c2662e354f (patch) | |
| tree | b17e0f57c57a47fb6d4b54df4313174f090ee4e3 /compiler/rustc_hir_analysis/src | |
| parent | ccf817b9bbe449204a227430d0a84a4f1d1798cc (diff) | |
| parent | e324a59eb6ba1a7883bf23ff42d425ca96960f2a (diff) | |
| download | rust-dac91a82e146d89fefe94dcbb53cd6c2662e354f.tar.gz rust-dac91a82e146d89fefe94dcbb53cd6c2662e354f.zip | |
Auto merge of #115677 - matthewjasper:let-expr-recovery, r=b-naber
Improve invalid let expression handling - Move all of the checks for valid let expression positions to parsing. - Add a field to ExprKind::Let in AST/HIR to mark whether it's in a valid location. - Suppress some later errors and MIR construction for invalid let expressions. - Fix a (drop) scope issue that was also responsible for #104172. Fixes #104172 Fixes #104868
Diffstat (limited to 'compiler/rustc_hir_analysis/src')
| -rw-r--r-- | compiler/rustc_hir_analysis/src/check/region.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/rustc_hir_analysis/src/check/region.rs b/compiler/rustc_hir_analysis/src/check/region.rs index 5bd6fcb9612..463fab93e3f 100644 --- a/compiler/rustc_hir_analysis/src/check/region.rs +++ b/compiler/rustc_hir_analysis/src/check/region.rs @@ -149,7 +149,7 @@ fn resolve_block<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, blk: &'tcx h // From now on, we continue normally. visitor.cx = prev_cx; } - hir::StmtKind::Local(..) | hir::StmtKind::Item(..) => { + hir::StmtKind::Local(..) => { // Each declaration introduces a subscope for bindings // introduced by the declaration; this subscope covers a // suffix of the block. Each subscope in a block has the @@ -163,6 +163,10 @@ fn resolve_block<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, blk: &'tcx h visitor.cx.var_parent = visitor.cx.parent; visitor.visit_stmt(statement) } + hir::StmtKind::Item(..) => { + // Don't create scopes for items, since they won't be + // lowered to THIR and MIR. + } hir::StmtKind::Expr(..) | hir::StmtKind::Semi(..) => visitor.visit_stmt(statement), } } |
