diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 21b36f1934c3..f4bd6354972b 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -3937,7 +3937,9 @@ fn resolve_delegation( //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); + this.with_lifetime_rib(LifetimeRibKind::Elided(LifetimeRes::Infer), |this| { + this.visit_block(body); + }); }); }); } diff --git a/tests/ui/delegation/ice-line-bounds-issue-148732.rs b/tests/ui/delegation/ice-line-bounds-issue-148732.rs index 699e7d86f258..0123f0c8705b 100644 --- a/tests/ui/delegation/ice-line-bounds-issue-148732.rs +++ b/tests/ui/delegation/ice-line-bounds-issue-148732.rs @@ -2,7 +2,7 @@ //~^ ERROR cannot find function `a` in this scope //~| ERROR functions delegation is not yet fully implemented dbg!(b); - //~^ ERROR missing lifetime specifier + //~^ ERROR: `fn() {b}` doesn't implement `Debug` } fn main() {} diff --git a/tests/ui/delegation/ice-line-bounds-issue-148732.stderr b/tests/ui/delegation/ice-line-bounds-issue-148732.stderr index c4f261181b10..eb93655beb60 100644 --- a/tests/ui/delegation/ice-line-bounds-issue-148732.stderr +++ b/tests/ui/delegation/ice-line-bounds-issue-148732.stderr @@ -1,9 +1,3 @@ -error[E0106]: missing lifetime specifier - --> $DIR/ice-line-bounds-issue-148732.rs:4:5 - | -LL | dbg!(b); - | ^^^^^^^ expected named lifetime parameter - error[E0425]: cannot find function `a` in this scope --> $DIR/ice-line-bounds-issue-148732.rs:1:7 | @@ -25,7 +19,18 @@ LL | | } = help: add `#![feature(fn_delegation)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date +error[E0277]: `fn() {b}` doesn't implement `Debug` + --> $DIR/ice-line-bounds-issue-148732.rs:4:5 + | +LL | reuse a as b { + | - consider calling this function +... +LL | dbg!(b); + | ^^^^^^^ the trait `Debug` is not implemented for fn item `fn() {b}` + | + = help: use parentheses to call this function: `b()` + error: aborting due to 3 previous errors -Some errors have detailed explanations: E0106, E0425, E0658. -For more information about an error, try `rustc --explain E0106`. +Some errors have detailed explanations: E0277, E0425, E0658. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/delegation/wrong-lifetime-rib.rs b/tests/ui/delegation/wrong-lifetime-rib.rs index 14d62cbaa41f..825ac6a64008 100644 --- a/tests/ui/delegation/wrong-lifetime-rib.rs +++ b/tests/ui/delegation/wrong-lifetime-rib.rs @@ -29,4 +29,14 @@ impl X { //~ ERROR: expected a type, found a trait } } +mod ice_156806 { + trait X {} + + impl X { //~ ERROR: expected a type, found a trait + reuse Iterator::fold { //~ ERROR: `()` is not an iterator + let _: &X; //~ ERROR: expected a type, found a trait + } + } +} + fn main() {} diff --git a/tests/ui/delegation/wrong-lifetime-rib.stderr b/tests/ui/delegation/wrong-lifetime-rib.stderr index 2c9594af581c..07ddc94f7a4a 100644 --- a/tests/ui/delegation/wrong-lifetime-rib.stderr +++ b/tests/ui/delegation/wrong-lifetime-rib.stderr @@ -19,6 +19,21 @@ help: you might have intended to implement this trait for a given type LL | impl X for /* Type */ { | ++++++++++++++ +error[E0782]: expected a type, found a trait + --> $DIR/wrong-lifetime-rib.rs:35:10 + | +LL | impl X { + | ^ + | +help: you can add the `dyn` keyword if you want a trait object + | +LL | impl dyn X { + | +++ +help: you might have intended to implement this trait for a given type + | +LL | impl X for /* Type */ { + | ++++++++++++++ + error[E0116]: cannot define inherent `impl` for a type outside of the crate where the type is defined --> $DIR/wrong-lifetime-rib.rs:9:5 | @@ -40,7 +55,28 @@ LL - reuse<<<&Project> :: Ty> :: Ty as Iterator>::next; LL + reuse<<<&() as Example>::Ty> :: Ty as Iterator>::next; | -error: aborting due to 4 previous errors +error[E0782]: expected a type, found a trait + --> $DIR/wrong-lifetime-rib.rs:37:21 + | +LL | let _: &X; + | ^ + | +help: you can add the `dyn` keyword if you want a trait object + | +LL | let _: &dyn X; + | +++ -Some errors have detailed explanations: E0116, E0223, E0423, E0782. +error[E0599]: `()` is not an iterator + --> $DIR/wrong-lifetime-rib.rs:36:25 + | +LL | reuse Iterator::fold { + | ^^^^ `()` is not an iterator + | + = note: the following trait bounds were not satisfied: + `(): Iterator` + which is required by `&mut (): Iterator` + +error: aborting due to 7 previous errors + +Some errors have detailed explanations: E0116, E0223, E0423, E0599, E0782. For more information about an error, try `rustc --explain E0116`.