diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2021-09-19 17:31:30 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-19 17:31:30 +0900 |
| commit | ba1a90a417bf81b33c793552b4fd95e6df81a38a (patch) | |
| tree | 0d67656402d0b5487913d3057fa72860a2a619be /compiler/rustc_resolve/src | |
| parent | e675073e73d13a3a2d21f605de873b96ef642595 (diff) | |
| parent | ffdabc8be8c3514d97ff24de21e3e4f2d9441a16 (diff) | |
| download | rust-ba1a90a417bf81b33c793552b4fd95e6df81a38a.tar.gz rust-ba1a90a417bf81b33c793552b4fd95e6df81a38a.zip | |
Rollup merge of #88966 - tmiasko:block-label-shadowing, r=petrochenkov
Check for shadowing issues involving block labels
Diffstat (limited to 'compiler/rustc_resolve/src')
| -rw-r--r-- | compiler/rustc_resolve/src/late/lifetimes.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/rustc_resolve/src/late/lifetimes.rs b/compiler/rustc_resolve/src/late/lifetimes.rs index a5dbbffeaa8..a158e0e48e8 100644 --- a/compiler/rustc_resolve/src/late/lifetimes.rs +++ b/compiler/rustc_resolve/src/late/lifetimes.rs @@ -1652,7 +1652,11 @@ fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body<'_>) { } fn expression_label(ex: &hir::Expr<'_>) -> Option<Ident> { - if let hir::ExprKind::Loop(_, Some(label), ..) = ex.kind { Some(label.ident) } else { None } + match ex.kind { + hir::ExprKind::Loop(_, Some(label), ..) => Some(label.ident), + hir::ExprKind::Block(_, Some(label)) => Some(label.ident), + _ => None, + } } fn check_if_label_shadows_lifetime(tcx: TyCtxt<'_>, mut scope: ScopeRef<'_>, label: Ident) { |
