Rollup merge of #149496 - aerooneqq:ice-issue-148889, r=petrochenkov
Fix #148889: Add label rib when visiting delegation body This PR relates to the delegation feature rust-lang/rust#118212, it fixes rust-lang/rust#148889 ICE. r? `@petrochenkov`
This commit is contained in:
commit
e0091c5590
3 changed files with 36 additions and 1 deletions
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
18
tests/ui/delegation/unreachable-label-ice-148889.rs
Normal file
18
tests/ui/delegation/unreachable-label-ice-148889.rs
Normal file
|
|
@ -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
tests/ui/delegation/unreachable-label-ice-148889.stderr
Normal file
13
tests/ui/delegation/unreachable-label-ice-148889.stderr
Normal file
|
|
@ -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…
Add table
Add a link
Reference in a new issue