Rollup merge of #88966 - tmiasko:block-label-shadowing, r=petrochenkov

Check for shadowing issues involving block labels
This commit is contained in:
Yuki Okushi 2021-09-19 17:31:30 +09:00 committed by GitHub
commit ba1a90a417
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 61 additions and 21 deletions

View file

@ -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) {