Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion compiler/rustc_resolve/src/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3689,7 +3689,11 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
let ident = Ident::new(kw::SelfLower, span.normalize_to_macro_rules());
let res = Res::Local(delegation.id);
this.innermost_rib_bindings(ValueNS).insert(ident, res);
this.visit_block(body);

//As we lower target_expr_template body to a body of a function we need a label rib (#148889)
this.with_label_rib(RibKind::FnOrCoroutine, |this| {
this.visit_block(body);
});
});
}

Expand Down
18 changes: 18 additions & 0 deletions tests/ui/delegation/unreachable-label-ice-148889.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#![allow(incomplete_features)]
#![feature(fn_delegation)]

trait Trait {
fn static_method2(x: i32, y: i32) -> i32 {
x + y
}
}

struct S;
impl Trait for S {}

pub fn main() {
'foo: loop {
reuse <S as Trait>::static_method2 { loop { break 'foo; } }
//~^ ERROR use of unreachable label `'foo`
}
}
13 changes: 13 additions & 0 deletions tests/ui/delegation/unreachable-label-ice-148889.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
error[E0767]: use of unreachable label `'foo`
--> $DIR/unreachable-label-ice-148889.rs:15:59
|
LL | 'foo: loop {
| ---- unreachable label defined here
LL | reuse <S as Trait>::static_method2 { loop { break 'foo; } }
| ^^^^ unreachable label `'foo`
|
= note: labels are unreachable through functions, closures, async blocks and modules

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0767`.
Loading