From ca57bada05373ff227c661cc542e99c92b70c0ee Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sun, 6 Mar 2022 15:44:48 +0100 Subject: [PATCH] Bless tests. --- ...t-in-trait-path-undeclared-lifetime.stderr | 14 +- ...ssociated_type_undeclared_lifetimes.stderr | 19 +- .../generic-associated-types/issue-67510.rs | 8 +- .../issue-67510.stderr | 53 +++- .../generic-associated-types/issue-70304.rs | 13 +- .../issue-70304.stderr | 2 +- .../generics/generic-extern-lifetime.stderr | 21 +- .../trait-elided.rs | 7 +- .../trait-elided.stderr | 2 +- src/test/ui/issues/issue-10412.rs | 18 +- src/test/ui/issues/issue-10412.stderr | 28 +-- ...ime-used-in-debug-macro-issue-70152.stderr | 10 +- .../method-call-lifetime-args-unresolved.rs | 5 +- ...ethod-call-lifetime-args-unresolved.stderr | 17 +- src/test/ui/regions/regions-name-static.rs | 5 +- .../ui/regions/regions-name-undeclared.rs | 8 +- .../ui/regions/regions-name-undeclared.stderr | 104 ++++---- .../fn-missing-lifetime-in-item.stderr | 8 +- .../missing-lifetimes-in-signature.rs | 31 ++- .../missing-lifetimes-in-signature.stderr | 229 +++++++++++++++++- ...ssue-69136-inner-lifetime-resolve-error.rs | 2 + ...-69136-inner-lifetime-resolve-error.stderr | 40 ++- src/test/ui/underscore-lifetime/in-binder.rs | 8 +- .../where-lifetime-resolution.stderr | 33 ++- 24 files changed, 527 insertions(+), 158 deletions(-) diff --git a/src/test/ui/generic-associated-types/gat-in-trait-path-undeclared-lifetime.stderr b/src/test/ui/generic-associated-types/gat-in-trait-path-undeclared-lifetime.stderr index 317897ae70f7..1792d8db292c 100644 --- a/src/test/ui/generic-associated-types/gat-in-trait-path-undeclared-lifetime.stderr +++ b/src/test/ui/generic-associated-types/gat-in-trait-path-undeclared-lifetime.stderr @@ -2,9 +2,17 @@ error[E0261]: use of undeclared lifetime name `'x` --> $DIR/gat-in-trait-path-undeclared-lifetime.rs:8:35 | LL | fn _f(arg : Box X = &'a [u32]>>) {} - | - ^^ undeclared lifetime - | | - | help: consider introducing lifetime `'x` here: `<'x>` + | ^^ undeclared lifetime + | + = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html +help: consider making the bound lifetime-generic with a new `'x` lifetime + | +LL | fn _f(arg : Box X = &'a [u32]>>) {} + | +++ +help: consider introducing lifetime `'x` here + | +LL | fn _f<'x>(arg : Box X = &'a [u32]>>) {} + | ++++ error[E0582]: binding for associated type `Y` references lifetime `'a`, which does not appear in the trait input types --> $DIR/gat-in-trait-path-undeclared-lifetime.rs:8:33 diff --git a/src/test/ui/generic-associated-types/generic_associated_type_undeclared_lifetimes.stderr b/src/test/ui/generic-associated-types/generic_associated_type_undeclared_lifetimes.stderr index bf0ca8715036..a4bb361900fe 100644 --- a/src/test/ui/generic-associated-types/generic_associated_type_undeclared_lifetimes.stderr +++ b/src/test/ui/generic-associated-types/generic_associated_type_undeclared_lifetimes.stderr @@ -4,14 +4,19 @@ error[E0261]: use of undeclared lifetime name `'b` LL | + Deref>; | ^^ undeclared lifetime | -help: consider introducing lifetime `'b` here + = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html +help: consider making the bound lifetime-generic with a new `'b` lifetime | -LL | trait Iterable<'b> { - | ++++ +LL | + for<'b> Deref>; + | +++++++ help: consider introducing lifetime `'b` here | LL | type Iter<'b, 'a>: Iterator> | +++ +help: consider introducing lifetime `'b` here + | +LL | trait Iterable<'b> { + | ++++ error[E0261]: use of undeclared lifetime name `'undeclared` --> $DIR/generic_associated_type_undeclared_lifetimes.rs:11:41 @@ -21,12 +26,12 @@ LL | fn iter<'a>(&'a self) -> Self::Iter<'undeclared>; | help: consider introducing lifetime `'undeclared` here | -LL | trait Iterable<'undeclared> { - | +++++++++++++ -help: consider introducing lifetime `'undeclared` here - | LL | fn iter<'undeclared, 'a>(&'a self) -> Self::Iter<'undeclared>; | ++++++++++++ +help: consider introducing lifetime `'undeclared` here + | +LL | trait Iterable<'undeclared> { + | +++++++++++++ error: aborting due to 2 previous errors diff --git a/src/test/ui/generic-associated-types/issue-67510.rs b/src/test/ui/generic-associated-types/issue-67510.rs index e81a5b231a00..5725b660ab23 100644 --- a/src/test/ui/generic-associated-types/issue-67510.rs +++ b/src/test/ui/generic-associated-types/issue-67510.rs @@ -4,9 +4,9 @@ trait X { type Y<'a>; } -fn f(x: Box=&'a ()>>) {} - //~^ ERROR: use of undeclared lifetime name `'a` - //~| ERROR: use of undeclared lifetime name `'a` - +fn f(x: Box = &'a ()>>) {} +//~^ ERROR: use of undeclared lifetime name `'a` +//~| ERROR: use of undeclared lifetime name `'a` +//~| ERROR: the trait `X` cannot be made into an object [E0038] fn main() {} diff --git a/src/test/ui/generic-associated-types/issue-67510.stderr b/src/test/ui/generic-associated-types/issue-67510.stderr index abc02b33e0e6..8aeda22bad75 100644 --- a/src/test/ui/generic-associated-types/issue-67510.stderr +++ b/src/test/ui/generic-associated-types/issue-67510.stderr @@ -1,19 +1,50 @@ error[E0261]: use of undeclared lifetime name `'a` --> $DIR/issue-67510.rs:7:21 | -LL | fn f(x: Box=&'a ()>>) {} - | - ^^ undeclared lifetime - | | - | help: consider introducing lifetime `'a` here: `<'a>` +LL | fn f(x: Box = &'a ()>>) {} + | ^^ undeclared lifetime + | + = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html +help: consider making the bound lifetime-generic with a new `'a` lifetime + | +LL | fn f(x: Box X = &'a ()>>) {} + | +++++++ +help: consider introducing lifetime `'a` here + | +LL | fn f<'a>(x: Box = &'a ()>>) {} + | ++++ error[E0261]: use of undeclared lifetime name `'a` - --> $DIR/issue-67510.rs:7:26 + --> $DIR/issue-67510.rs:7:28 | -LL | fn f(x: Box=&'a ()>>) {} - | - ^^ undeclared lifetime - | | - | help: consider introducing lifetime `'a` here: `<'a>` +LL | fn f(x: Box = &'a ()>>) {} + | ^^ undeclared lifetime + | +help: consider making the bound lifetime-generic with a new `'a` lifetime + | +LL | fn f(x: Box X = &'a ()>>) {} + | +++++++ +help: consider introducing lifetime `'a` here + | +LL | fn f<'a>(x: Box = &'a ()>>) {} + | ++++ -error: aborting due to 2 previous errors +error[E0038]: the trait `X` cannot be made into an object + --> $DIR/issue-67510.rs:7:13 + | +LL | fn f(x: Box = &'a ()>>) {} + | ^^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object + | +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit + --> $DIR/issue-67510.rs:4:10 + | +LL | trait X { + | - this trait cannot be made into an object... +LL | type Y<'a>; + | ^ ...because it contains the generic associated type `Y` + = help: consider moving `Y` to another trait -For more information about this error, try `rustc --explain E0261`. +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0038, E0261. +For more information about an error, try `rustc --explain E0038`. diff --git a/src/test/ui/generic-associated-types/issue-70304.rs b/src/test/ui/generic-associated-types/issue-70304.rs index ae64f9310d11..448d7ec28739 100644 --- a/src/test/ui/generic-associated-types/issue-70304.rs +++ b/src/test/ui/generic-associated-types/issue-70304.rs @@ -12,13 +12,10 @@ impl Document for DocumentImpl { type Cursor<'a> = DocCursorImpl<'a>; fn cursor(&self) -> Self::Cursor<'_> { - DocCursorImpl { - document: &self, - } + DocCursorImpl { document: &self } } } - trait DocCursor<'a> {} struct DocCursorImpl<'a> { @@ -35,7 +32,6 @@ where _phantom: std::marker::PhantomData<&'d ()>, } - impl<'d, Cursor> Lexer<'d, Cursor> where Cursor: DocCursor<'d>, @@ -44,15 +40,12 @@ where where Doc: Document = Cursor>, { - Lexer { - cursor: document.cursor(), - _phantom: std::marker::PhantomData, - } + Lexer { cursor: document.cursor(), _phantom: std::marker::PhantomData } } } fn create_doc() -> impl Document = DocCursorImpl<'_>> { - //~^ ERROR: missing lifetime specifier + //~^ ERROR: missing lifetime specifier DocumentImpl {} } diff --git a/src/test/ui/generic-associated-types/issue-70304.stderr b/src/test/ui/generic-associated-types/issue-70304.stderr index c53dbf63a3c5..c5f59a24057d 100644 --- a/src/test/ui/generic-associated-types/issue-70304.stderr +++ b/src/test/ui/generic-associated-types/issue-70304.stderr @@ -1,5 +1,5 @@ error[E0106]: missing lifetime specifier - --> $DIR/issue-70304.rs:54:41 + --> $DIR/issue-70304.rs:47:41 | LL | fn create_doc() -> impl Document = DocCursorImpl<'_>> { | ^^ expected named lifetime parameter diff --git a/src/test/ui/generics/generic-extern-lifetime.stderr b/src/test/ui/generics/generic-extern-lifetime.stderr index 909848604ec8..33332e760f58 100644 --- a/src/test/ui/generics/generic-extern-lifetime.stderr +++ b/src/test/ui/generics/generic-extern-lifetime.stderr @@ -2,7 +2,9 @@ error[E0261]: use of undeclared lifetime name `'a` --> $DIR/generic-extern-lifetime.rs:6:26 | LL | pub fn life2<'b>(x: &'a i32, y: &'b i32); - | ^^ undeclared lifetime + | - ^^ undeclared lifetime + | | + | help: consider introducing lifetime `'a` here: `'a,` error[E0261]: use of undeclared lifetime name `'a` --> $DIR/generic-extern-lifetime.rs:8:37 @@ -13,8 +15,12 @@ LL | pub fn life4<'b>(x: for<'c> fn(&'a i32)); = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html help: consider making the type lifetime-generic with a new `'a` lifetime | -LL | pub fn life4<'b>(x: for<'c, 'a> fn(&'a i32)); - | ++++ +LL | pub fn life4<'b>(x: for<'a, 'c> fn(&'a i32)); + | +++ +help: consider introducing lifetime `'a` here + | +LL | pub fn life4<'a, 'b>(x: for<'c> fn(&'a i32)); + | +++ error[E0261]: use of undeclared lifetime name `'a` --> $DIR/generic-extern-lifetime.rs:11:39 @@ -22,11 +28,14 @@ error[E0261]: use of undeclared lifetime name `'a` LL | pub fn life7<'b>() -> for<'c> fn(&'a i32); | ^^ undeclared lifetime | - = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html help: consider making the type lifetime-generic with a new `'a` lifetime | -LL | pub fn life7<'b>() -> for<'c, 'a> fn(&'a i32); - | ++++ +LL | pub fn life7<'b>() -> for<'a, 'c> fn(&'a i32); + | +++ +help: consider introducing lifetime `'a` here + | +LL | pub fn life7<'a, 'b>() -> for<'c> fn(&'a i32); + | +++ error: aborting due to 3 previous errors diff --git a/src/test/ui/impl-header-lifetime-elision/trait-elided.rs b/src/test/ui/impl-header-lifetime-elision/trait-elided.rs index 102d259b0c87..c3e76d9cb5a0 100644 --- a/src/test/ui/impl-header-lifetime-elision/trait-elided.rs +++ b/src/test/ui/impl-header-lifetime-elision/trait-elided.rs @@ -1,9 +1,8 @@ #![allow(warnings)] -trait MyTrait<'a> { } +trait MyTrait<'a> {} -impl MyTrait for u32 { - //~^ ERROR implicit elided lifetime not allowed here -} +impl MyTrait for u32 {} +//~^ ERROR implicit elided lifetime not allowed here fn main() {} diff --git a/src/test/ui/impl-header-lifetime-elision/trait-elided.stderr b/src/test/ui/impl-header-lifetime-elision/trait-elided.stderr index 15bc3f106b9c..be918d0a30ce 100644 --- a/src/test/ui/impl-header-lifetime-elision/trait-elided.stderr +++ b/src/test/ui/impl-header-lifetime-elision/trait-elided.stderr @@ -1,7 +1,7 @@ error[E0726]: implicit elided lifetime not allowed here --> $DIR/trait-elided.rs:5:6 | -LL | impl MyTrait for u32 { +LL | impl MyTrait for u32 {} | ^^^^^^^- help: indicate the anonymous lifetime: `<'_>` | = note: assuming a `'static` lifetime... diff --git a/src/test/ui/issues/issue-10412.rs b/src/test/ui/issues/issue-10412.rs index 020585136856..0de170161b51 100644 --- a/src/test/ui/issues/issue-10412.rs +++ b/src/test/ui/issues/issue-10412.rs @@ -1,16 +1,20 @@ -trait Serializable<'self, T> { //~ ERROR lifetimes cannot use keyword names - fn serialize(val : &'self T) -> Vec; //~ ERROR lifetimes cannot use keyword names - fn deserialize(repr : &[u8]) -> &'self T; //~ ERROR lifetimes cannot use keyword names +trait Serializable<'self, T> { + //~^ ERROR lifetimes cannot use keyword names + fn serialize(val: &'self T) -> Vec; //~ ERROR lifetimes cannot use keyword names + fn deserialize(repr: &[u8]) -> &'self T; //~ ERROR lifetimes cannot use keyword names } -impl<'self> Serializable for &'self str { //~ ERROR lifetimes cannot use keyword names +impl<'self> Serializable for &'self str { //~^ ERROR lifetimes cannot use keyword names + //~| ERROR lifetimes cannot use keyword names //~| ERROR implicit elided lifetime not allowed here - //~| ERROR the size for values of type `str` cannot be known at compilation time - fn serialize(val : &'self str) -> Vec { //~ ERROR lifetimes cannot use keyword names + //~| ERROR the size for values of type `str` cannot be known at compilation time [E0277] + fn serialize(val: &'self str) -> Vec { + //~^ ERROR lifetimes cannot use keyword names vec![1] } - fn deserialize(repr: &[u8]) -> &'self str { //~ ERROR lifetimes cannot use keyword names + fn deserialize(repr: &[u8]) -> &'self str { + //~^ ERROR lifetimes cannot use keyword names "hi" } } diff --git a/src/test/ui/issues/issue-10412.stderr b/src/test/ui/issues/issue-10412.stderr index a91b3c90ebb2..a65005fd72d0 100644 --- a/src/test/ui/issues/issue-10412.stderr +++ b/src/test/ui/issues/issue-10412.stderr @@ -5,43 +5,43 @@ LL | trait Serializable<'self, T> { | ^^^^^ error: lifetimes cannot use keyword names - --> $DIR/issue-10412.rs:2:25 + --> $DIR/issue-10412.rs:3:24 | -LL | fn serialize(val : &'self T) -> Vec; - | ^^^^^ +LL | fn serialize(val: &'self T) -> Vec; + | ^^^^^ error: lifetimes cannot use keyword names - --> $DIR/issue-10412.rs:3:38 + --> $DIR/issue-10412.rs:4:37 | -LL | fn deserialize(repr : &[u8]) -> &'self T; - | ^^^^^ +LL | fn deserialize(repr: &[u8]) -> &'self T; + | ^^^^^ error: lifetimes cannot use keyword names - --> $DIR/issue-10412.rs:6:6 + --> $DIR/issue-10412.rs:7:6 | LL | impl<'self> Serializable for &'self str { | ^^^^^ error: lifetimes cannot use keyword names - --> $DIR/issue-10412.rs:6:36 + --> $DIR/issue-10412.rs:7:36 | LL | impl<'self> Serializable for &'self str { | ^^^^^ error: lifetimes cannot use keyword names - --> $DIR/issue-10412.rs:10:25 + --> $DIR/issue-10412.rs:12:24 | -LL | fn serialize(val : &'self str) -> Vec { - | ^^^^^ +LL | fn serialize(val: &'self str) -> Vec { + | ^^^^^ error: lifetimes cannot use keyword names - --> $DIR/issue-10412.rs:13:37 + --> $DIR/issue-10412.rs:16:37 | LL | fn deserialize(repr: &[u8]) -> &'self str { | ^^^^^ error[E0726]: implicit elided lifetime not allowed here - --> $DIR/issue-10412.rs:6:13 + --> $DIR/issue-10412.rs:7:13 | LL | impl<'self> Serializable for &'self str { | ^^^^^^^^^^^^^^^^^ help: indicate the anonymous lifetime: `Serializable<'_, str>` @@ -49,7 +49,7 @@ LL | impl<'self> Serializable for &'self str { = note: assuming a `'static` lifetime... error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/issue-10412.rs:6:13 + --> $DIR/issue-10412.rs:7:13 | LL | impl<'self> Serializable for &'self str { | ^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time diff --git a/src/test/ui/lifetimes/undeclared-lifetime-used-in-debug-macro-issue-70152.stderr b/src/test/ui/lifetimes/undeclared-lifetime-used-in-debug-macro-issue-70152.stderr index cb459f31cd24..0d6ade41511f 100644 --- a/src/test/ui/lifetimes/undeclared-lifetime-used-in-debug-macro-issue-70152.stderr +++ b/src/test/ui/lifetimes/undeclared-lifetime-used-in-debug-macro-issue-70152.stderr @@ -9,6 +9,8 @@ LL | a: &'b str, error[E0261]: use of undeclared lifetime name `'b` --> $DIR/undeclared-lifetime-used-in-debug-macro-issue-70152.rs:3:9 | +LL | #[derive(Eq, PartialEq)] + | -- lifetime `'b` is missing in item created through this procedural macro LL | struct Test { | - help: consider introducing lifetime `'b` here: `<'b>` LL | a: &'b str, @@ -22,12 +24,12 @@ LL | fn foo(&'b self) {} | help: consider introducing lifetime `'b` here | -LL | impl<'b> T for Test { - | ++++ -help: consider introducing lifetime `'b` here - | LL | fn foo<'b>(&'b self) {} | ++++ +help: consider introducing lifetime `'b` here + | +LL | impl<'b> T for Test { + | ++++ error: aborting due to 3 previous errors diff --git a/src/test/ui/methods/method-call-lifetime-args-unresolved.rs b/src/test/ui/methods/method-call-lifetime-args-unresolved.rs index d16ba3df47b6..ba7231070a0f 100644 --- a/src/test/ui/methods/method-call-lifetime-args-unresolved.rs +++ b/src/test/ui/methods/method-call-lifetime-args-unresolved.rs @@ -1,3 +1,6 @@ fn main() { - 0.clone::<'a>(); //~ ERROR use of undeclared lifetime name `'a` + 0.clone::<'a>(); + //~^ ERROR use of undeclared lifetime name `'a` + //~| WARN cannot specify lifetime arguments explicitly if late bound + //~| WARN this was previously accepted by the compiler } diff --git a/src/test/ui/methods/method-call-lifetime-args-unresolved.stderr b/src/test/ui/methods/method-call-lifetime-args-unresolved.stderr index c9f235c4f7df..78af19586a1b 100644 --- a/src/test/ui/methods/method-call-lifetime-args-unresolved.stderr +++ b/src/test/ui/methods/method-call-lifetime-args-unresolved.stderr @@ -6,6 +6,21 @@ LL | fn main() { LL | 0.clone::<'a>(); | ^^ undeclared lifetime -error: aborting due to previous error +warning: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/method-call-lifetime-args-unresolved.rs:2:15 + | +LL | 0.clone::<'a>(); + | ^^ + | + ::: $SRC_DIR/core/src/clone.rs:LL:COL + | +LL | fn clone(&self) -> Self; + | - the late bound lifetime parameter is introduced here + | + = note: `#[warn(late_bound_lifetime_arguments)]` on by default + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #42868 + +error: aborting due to previous error; 1 warning emitted For more information about this error, try `rustc --explain E0261`. diff --git a/src/test/ui/regions/regions-name-static.rs b/src/test/ui/regions/regions-name-static.rs index 730fd99aa68c..da316c6ef5e4 100644 --- a/src/test/ui/regions/regions-name-static.rs +++ b/src/test/ui/regions/regions-name-static.rs @@ -1,5 +1,6 @@ -struct Foo<'static> { //~ ERROR invalid lifetime parameter name: `'static` - x: &'static isize +struct Foo<'static> { + //~^ ERROR invalid lifetime parameter name: `'static` + x: &'static isize, } fn main() {} diff --git a/src/test/ui/regions/regions-name-undeclared.rs b/src/test/ui/regions/regions-name-undeclared.rs index b8f50a40c452..7b6ede19341b 100644 --- a/src/test/ui/regions/regions-name-undeclared.rs +++ b/src/test/ui/regions/regions-name-undeclared.rs @@ -23,14 +23,14 @@ fn bar<'a>(x: &'a isize) { let y: &'a isize = x; // &'a is not visible to *items*: - type X = Option<&'a isize>; //~ ERROR undeclared lifetime + type X = Option<&'a isize>; //~ ERROR can't use generic parameters from outer item enum E { - E1(&'a isize) //~ ERROR undeclared lifetime + E1(&'a isize) //~ ERROR can't use generic parameters from outer item } struct S { - f: &'a isize //~ ERROR undeclared lifetime + f: &'a isize //~ ERROR can't use generic parameters from outer item } - fn f(a: &'a isize) { } //~ ERROR undeclared lifetime + fn f(a: &'a isize) { } //~ ERROR can't use generic parameters from outer item // &'a CAN be declared on functions and used then: fn g<'a>(a: &'a isize) { } // OK diff --git a/src/test/ui/regions/regions-name-undeclared.stderr b/src/test/ui/regions/regions-name-undeclared.stderr index 4399263f716e..532603de5f78 100644 --- a/src/test/ui/regions/regions-name-undeclared.stderr +++ b/src/test/ui/regions/regions-name-undeclared.stderr @@ -1,19 +1,3 @@ -error[E0261]: use of undeclared lifetime name `'a` - --> $DIR/regions-name-undeclared.rs:28:13 - | -LL | enum E { - | - help: consider introducing lifetime `'a` here: `<'a>` -LL | E1(&'a isize) - | ^^ undeclared lifetime - -error[E0261]: use of undeclared lifetime name `'a` - --> $DIR/regions-name-undeclared.rs:31:13 - | -LL | struct S { - | - help: consider introducing lifetime `'a` here: `<'a>` -LL | f: &'a isize - | ^^ undeclared lifetime - error[E0261]: use of undeclared lifetime name `'b` --> $DIR/regions-name-undeclared.rs:16:24 | @@ -22,12 +6,12 @@ LL | fn m4(&self, arg: &'b isize) { } | help: consider introducing lifetime `'b` here | -LL | impl<'b, 'a> Foo<'a> { - | +++ -help: consider introducing lifetime `'b` here - | LL | fn m4<'b>(&self, arg: &'b isize) { } | ++++ +help: consider introducing lifetime `'b` here + | +LL | impl<'b, 'a> Foo<'a> { + | +++ error[E0261]: use of undeclared lifetime name `'b` --> $DIR/regions-name-undeclared.rs:17:12 @@ -37,12 +21,12 @@ LL | fn m5(&'b self) { } | help: consider introducing lifetime `'b` here | -LL | impl<'b, 'a> Foo<'a> { - | +++ -help: consider introducing lifetime `'b` here - | LL | fn m5<'b>(&'b self) { } | ++++ +help: consider introducing lifetime `'b` here + | +LL | impl<'b, 'a> Foo<'a> { + | +++ error[E0261]: use of undeclared lifetime name `'b` --> $DIR/regions-name-undeclared.rs:18:27 @@ -52,26 +36,54 @@ LL | fn m6(&self, arg: Foo<'b>) { } | help: consider introducing lifetime `'b` here | -LL | impl<'b, 'a> Foo<'a> { - | +++ -help: consider introducing lifetime `'b` here - | LL | fn m6<'b>(&self, arg: Foo<'b>) { } | ++++ +help: consider introducing lifetime `'b` here + | +LL | impl<'b, 'a> Foo<'a> { + | +++ -error[E0261]: use of undeclared lifetime name `'a` +error[E0401]: can't use generic parameters from outer item --> $DIR/regions-name-undeclared.rs:26:22 | +LL | fn bar<'a>(x: &'a isize) { + | -- lifetime parameter from outer item +... LL | type X = Option<&'a isize>; - | - ^^ undeclared lifetime + | - ^^ use of generic parameter from outer item | | | help: consider introducing lifetime `'a` here: `<'a>` -error[E0261]: use of undeclared lifetime name `'a` +error[E0401]: can't use generic parameters from outer item + --> $DIR/regions-name-undeclared.rs:28:13 + | +LL | fn bar<'a>(x: &'a isize) { + | -- lifetime parameter from outer item +... +LL | enum E { + | - help: consider introducing lifetime `'a` here: `<'a>` +LL | E1(&'a isize) + | ^^ use of generic parameter from outer item + +error[E0401]: can't use generic parameters from outer item + --> $DIR/regions-name-undeclared.rs:31:13 + | +LL | fn bar<'a>(x: &'a isize) { + | -- lifetime parameter from outer item +... +LL | struct S { + | - help: consider introducing lifetime `'a` here: `<'a>` +LL | f: &'a isize + | ^^ use of generic parameter from outer item + +error[E0401]: can't use generic parameters from outer item --> $DIR/regions-name-undeclared.rs:33:14 | +LL | fn bar<'a>(x: &'a isize) { + | -- lifetime parameter from outer item +... LL | fn f(a: &'a isize) { } - | - ^^ undeclared lifetime + | - ^^ use of generic parameter from outer item | | | help: consider introducing lifetime `'a` here: `<'a>` @@ -90,14 +102,14 @@ LL | ... &'b isize, | ^^ undeclared lifetime | = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html +help: consider making the bound lifetime-generic with a new `'b` lifetime + | +LL | b: Box FnOnce(&'a isize, + | +++ help: consider introducing lifetime `'b` here | LL | fn fn_types<'b>(a: &'a isize, | ++++ -help: consider making the bound lifetime-generic with a new `'b` lifetime - | -LL | b: Box FnOnce(&'a isize, - | ++++ error[E0261]: use of undeclared lifetime name `'b` --> $DIR/regions-name-undeclared.rs:46:36 @@ -105,15 +117,14 @@ error[E0261]: use of undeclared lifetime name `'b` LL | ... &'b isize)>, | ^^ undeclared lifetime | - = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html +help: consider making the bound lifetime-generic with a new `'b` lifetime + | +LL | b: Box FnOnce(&'a isize, + | +++ help: consider introducing lifetime `'b` here | LL | fn fn_types<'b>(a: &'a isize, | ++++ -help: consider making the bound lifetime-generic with a new `'b` lifetime - | -LL | b: Box FnOnce(&'a isize, - | ++++ error[E0261]: use of undeclared lifetime name `'a` --> $DIR/regions-name-undeclared.rs:47:17 @@ -132,13 +143,14 @@ LL | async fn buggy(&self) -> &'a str { | help: consider introducing lifetime `'a` here | -LL | impl<'a> Bug { - | ++++ -help: consider introducing lifetime `'a` here - | LL | async fn buggy<'a>(&self) -> &'a str { | ++++ +help: consider introducing lifetime `'a` here + | +LL | impl<'a> Bug { + | ++++ error: aborting due to 12 previous errors -For more information about this error, try `rustc --explain E0261`. +Some errors have detailed explanations: E0261, E0401. +For more information about an error, try `rustc --explain E0261`. diff --git a/src/test/ui/suggestions/fn-missing-lifetime-in-item.stderr b/src/test/ui/suggestions/fn-missing-lifetime-in-item.stderr index 7c0f8d199a96..a761ec591674 100644 --- a/src/test/ui/suggestions/fn-missing-lifetime-in-item.stderr +++ b/src/test/ui/suggestions/fn-missing-lifetime-in-item.stderr @@ -5,14 +5,14 @@ LL | struct S1 &'a i32>(F); | ^^ undeclared lifetime | = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html -help: consider introducing lifetime `'a` here - | -LL | struct S1<'a, F: Fn(&i32, &i32) -> &'a i32>(F); - | +++ help: consider making the bound lifetime-generic with a new `'a` lifetime | LL | struct S1 Fn(&i32, &i32) -> &'a i32>(F); | +++++++ +help: consider introducing lifetime `'a` here + | +LL | struct S1<'a, F: Fn(&i32, &i32) -> &'a i32>(F); + | +++ error[E0106]: missing lifetime specifier --> $DIR/fn-missing-lifetime-in-item.rs:2:32 diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs index dd434ea53187..647b343fe069 100644 --- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs +++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs @@ -14,28 +14,31 @@ impl Get for Foo { fn foo(g: G, dest: &mut T) -> impl FnOnce() where - G: Get + G: Get, { move || { + //~^ ERROR hidden type for `impl Trait` captures lifetime *dest = g.get(); } } // After applying suggestion for `foo`: fn bar(g: G, dest: &mut T) -> impl FnOnce() + '_ +//~^ ERROR the parameter type `G` may not live long enough where - G: Get + G: Get, { + //~^ ERROR the parameter type `G` may not live long enough move || { *dest = g.get(); } } - // After applying suggestion for `bar`: -fn baz(g: G, dest: &mut T) -> impl FnOnce() + '_ //~ ERROR undeclared lifetime +fn baz(g: G, dest: &mut T) -> impl FnOnce() + '_ +//~^ ERROR undeclared lifetime name `'a` where - G: Get + G: Get, { move || { *dest = g.get(); @@ -44,9 +47,11 @@ where // After applying suggestion for `baz`: fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ +//~^ ERROR the parameter type `G` may not live long enough where - G: Get + G: Get, { + //~^ ERROR the parameter type `G` may not live long enough move || { *dest = g.get(); } @@ -55,6 +60,8 @@ where // Same as above, but show that we pay attention to lifetime names from parent item impl<'a> Foo { fn qux<'b, G: Get + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ { + //~^ ERROR the parameter type `G` may not live long enough + //~| ERROR the parameter type `G` may not live long enough move || { *dest = g.get(); } @@ -63,8 +70,9 @@ impl<'a> Foo { // After applying suggestion for `qux`: fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a +//~^ ERROR explicit lifetime required in the type of `dest` where - G: Get + G: Get, { move || { *dest = g.get(); @@ -73,19 +81,20 @@ where // Potential incorrect attempt: fn bak<'a, G, T>(g: G, dest: &'a mut T) -> impl FnOnce() + 'a +//~^ ERROR the parameter type `G` may not live long enough where - G: Get + G: Get, { + //~^ ERROR the parameter type `G` may not live long enough move || { *dest = g.get(); } } - // We need to tie the lifetime of `G` with the lifetime of `&mut T` and the returned closure: fn ok<'a, G: 'a, T>(g: G, dest: &'a mut T) -> impl FnOnce() + 'a where - G: Get + G: Get, { move || { *dest = g.get(); @@ -95,7 +104,7 @@ where // This also works. The `'_` isn't necessary but it's where we arrive to following the suggestions: fn ok2<'a, G: 'a, T>(g: G, dest: &'a mut T) -> impl FnOnce() + '_ + 'a where - G: Get + G: Get, { move || { *dest = g.get(); diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr index 916a6c2bf12a..6d538dfd609a 100644 --- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr +++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr @@ -1,11 +1,234 @@ error[E0261]: use of undeclared lifetime name `'a` - --> $DIR/missing-lifetimes-in-signature.rs:36:11 + --> $DIR/missing-lifetimes-in-signature.rs:38:11 | LL | fn baz(g: G, dest: &mut T) -> impl FnOnce() + '_ | - ^^ undeclared lifetime | | | help: consider introducing lifetime `'a` here: `'a,` -error: aborting due to previous error +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/missing-lifetimes-in-signature.rs:19:5 + | +LL | fn foo(g: G, dest: &mut T) -> impl FnOnce() + | ------ hidden type `[closure@$DIR/missing-lifetimes-in-signature.rs:19:5: 22:6]` captures the anonymous lifetime defined here +... +LL | / move || { +LL | | +LL | | *dest = g.get(); +LL | | } + | |_____^ + | +help: to declare that the `impl Trait` captures `'_`, you can add an explicit `'_` lifetime bound + | +LL | fn foo(g: G, dest: &mut T) -> impl FnOnce() + '_ + | ++++ -For more information about this error, try `rustc --explain E0261`. +error[E0311]: the parameter type `G` may not live long enough + --> $DIR/missing-lifetimes-in-signature.rs:26:37 + | +LL | fn bar(g: G, dest: &mut T) -> impl FnOnce() + '_ + | ^^^^^^^^^^^^^^^^^^ + | +note: the parameter type `G` must be valid for the anonymous lifetime defined here... + --> $DIR/missing-lifetimes-in-signature.rs:26:26 + | +LL | fn bar(g: G, dest: &mut T) -> impl FnOnce() + '_ + | ^^^^^^ +note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:32:5: 34:6]` will meet its required lifetime bounds + --> $DIR/missing-lifetimes-in-signature.rs:26:37 + | +LL | fn bar(g: G, dest: &mut T) -> impl FnOnce() + '_ + | ^^^^^^^^^^^^^^^^^^ +help: consider introducing an explicit lifetime bound + | +LL | fn bar<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a + | ~~~~~ ++++ + +error[E0311]: the parameter type `G` may not live long enough + --> $DIR/missing-lifetimes-in-signature.rs:30:1 + | +LL | / { +LL | | +LL | | move || { +LL | | *dest = g.get(); +LL | | } +LL | | } + | |_^ + | +note: the parameter type `G` must be valid for the anonymous lifetime defined here... + --> $DIR/missing-lifetimes-in-signature.rs:26:26 + | +LL | fn bar(g: G, dest: &mut T) -> impl FnOnce() + '_ + | ^^^^^^ +note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:32:5: 34:6]` will meet its required lifetime bounds + --> $DIR/missing-lifetimes-in-signature.rs:30:1 + | +LL | / { +LL | | +LL | | move || { +LL | | *dest = g.get(); +LL | | } +LL | | } + | |_^ +help: consider introducing an explicit lifetime bound + | +LL ~ fn bar<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ +LL | +LL | where +LL | G: Get, +LL | { +LL | + ... + +error[E0311]: the parameter type `G` may not live long enough + --> $DIR/missing-lifetimes-in-signature.rs:49:45 + | +LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + | ^^^^^^^^^^^^^^^^^^ + | +note: the parameter type `G` must be valid for the anonymous lifetime defined here... + --> $DIR/missing-lifetimes-in-signature.rs:49:34 + | +LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + | ^^^^^^ +note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:55:5: 57:6]` will meet its required lifetime bounds + --> $DIR/missing-lifetimes-in-signature.rs:49:45 + | +LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + | ^^^^^^^^^^^^^^^^^^ +help: consider introducing an explicit lifetime bound + | +LL | fn qux<'b, 'a, G: 'b + 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'b + | +++ ~~~~~~~ ++++ + +error[E0311]: the parameter type `G` may not live long enough + --> $DIR/missing-lifetimes-in-signature.rs:53:1 + | +LL | / { +LL | | +LL | | move || { +LL | | *dest = g.get(); +LL | | } +LL | | } + | |_^ + | +note: the parameter type `G` must be valid for the anonymous lifetime defined here... + --> $DIR/missing-lifetimes-in-signature.rs:49:34 + | +LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + | ^^^^^^ +note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:55:5: 57:6]` will meet its required lifetime bounds + --> $DIR/missing-lifetimes-in-signature.rs:53:1 + | +LL | / { +LL | | +LL | | move || { +LL | | *dest = g.get(); +LL | | } +LL | | } + | |_^ +help: consider introducing an explicit lifetime bound + | +LL ~ fn qux<'b, 'a, G: 'b + 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ +LL | +LL | where +LL | G: Get, +LL | { +LL | + ... + +error[E0311]: the parameter type `G` may not live long enough + --> $DIR/missing-lifetimes-in-signature.rs:62:58 + | +LL | fn qux<'b, G: Get + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ { + | ^^^^^^^^^^^^^^^^^^ + | +note: the parameter type `G` must be valid for the anonymous lifetime defined here... + --> $DIR/missing-lifetimes-in-signature.rs:62:47 + | +LL | fn qux<'b, G: Get + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ { + | ^^^^^^ +note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:65:9: 67:10]` will meet its required lifetime bounds + --> $DIR/missing-lifetimes-in-signature.rs:62:58 + | +LL | fn qux<'b, G: Get + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ { + | ^^^^^^^^^^^^^^^^^^ +help: consider introducing an explicit lifetime bound + | +LL | fn qux<'c, 'b, G: 'c + Get + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'c { + | +++ ~~~~~~~ ++++ + +error[E0311]: the parameter type `G` may not live long enough + --> $DIR/missing-lifetimes-in-signature.rs:62:77 + | +LL | fn qux<'b, G: Get + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ { + | _____________________________________________________________________________^ +LL | | +LL | | +LL | | move || { +LL | | *dest = g.get(); +LL | | } +LL | | } + | |_____^ + | +note: the parameter type `G` must be valid for the anonymous lifetime defined here... + --> $DIR/missing-lifetimes-in-signature.rs:62:47 + | +LL | fn qux<'b, G: Get + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ { + | ^^^^^^ +note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:65:9: 67:10]` will meet its required lifetime bounds + --> $DIR/missing-lifetimes-in-signature.rs:62:77 + | +LL | fn qux<'b, G: Get + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ { + | _____________________________________________________________________________^ +LL | | +LL | | +LL | | move || { +LL | | *dest = g.get(); +LL | | } +LL | | } + | |_____^ +help: consider introducing an explicit lifetime bound + | +LL ~ fn qux<'c, 'b, G: 'c + Get + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ { +LL | +LL | +LL | move || { +LL | *dest = g.get(); +LL | } + ... + +error[E0621]: explicit lifetime required in the type of `dest` + --> $DIR/missing-lifetimes-in-signature.rs:72:45 + | +LL | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a + | ------ ^^^^^^^^^^^^^^^^^^^^^^^ lifetime `'a` required + | | + | help: add explicit lifetime `'a` to the type of `dest`: `&'a mut T` + +error[E0309]: the parameter type `G` may not live long enough + --> $DIR/missing-lifetimes-in-signature.rs:83:44 + | +LL | fn bak<'a, G, T>(g: G, dest: &'a mut T) -> impl FnOnce() + 'a + | - ^^^^^^^^^^^^^^^^^^ ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:89:5: 91:6]` will meet its required lifetime bounds + | | + | help: consider adding an explicit lifetime bound...: `G: 'a` + +error[E0309]: the parameter type `G` may not live long enough + --> $DIR/missing-lifetimes-in-signature.rs:87:1 + | +LL | fn bak<'a, G, T>(g: G, dest: &'a mut T) -> impl FnOnce() + 'a + | - help: consider adding an explicit lifetime bound...: `G: 'a` +... +LL | / { +LL | | +LL | | move || { +LL | | *dest = g.get(); +LL | | } +LL | | } + | |_^ ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:89:5: 91:6]` will meet its required lifetime bounds + +error: aborting due to 11 previous errors + +Some errors have detailed explanations: E0261, E0309, E0621, E0700. +For more information about an error, try `rustc --explain E0261`. diff --git a/src/test/ui/type-alias-impl-trait/issue-69136-inner-lifetime-resolve-error.rs b/src/test/ui/type-alias-impl-trait/issue-69136-inner-lifetime-resolve-error.rs index 6732902c09a5..b0de8bf6aa4f 100644 --- a/src/test/ui/type-alias-impl-trait/issue-69136-inner-lifetime-resolve-error.rs +++ b/src/test/ui/type-alias-impl-trait/issue-69136-inner-lifetime-resolve-error.rs @@ -18,5 +18,7 @@ type Return = impl WithAssoc; //~^ ERROR use of undeclared lifetime name `'a` fn my_fun() -> Return<()> {} +//~^ ERROR non-defining opaque type use in defining scope +//~| ERROR non-defining opaque type use in defining scope fn main() {} diff --git a/src/test/ui/type-alias-impl-trait/issue-69136-inner-lifetime-resolve-error.stderr b/src/test/ui/type-alias-impl-trait/issue-69136-inner-lifetime-resolve-error.stderr index fe45e39d938f..d038fbbe1b40 100644 --- a/src/test/ui/type-alias-impl-trait/issue-69136-inner-lifetime-resolve-error.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-69136-inner-lifetime-resolve-error.stderr @@ -2,10 +2,42 @@ error[E0261]: use of undeclared lifetime name `'a` --> $DIR/issue-69136-inner-lifetime-resolve-error.rs:17:65 | LL | type Return = impl WithAssoc; - | - ^^ undeclared lifetime - | | - | help: consider introducing lifetime `'a` here: `'a,` + | ^^ undeclared lifetime + | + = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html +help: consider making the bound lifetime-generic with a new `'a` lifetime + | +LL | type Return = impl for<'a> WithAssoc; + | +++++++ +help: consider introducing lifetime `'a` here + | +LL | type Return<'a, A> = impl WithAssoc; + | +++ -error: aborting due to previous error +error: non-defining opaque type use in defining scope + --> $DIR/issue-69136-inner-lifetime-resolve-error.rs:20:27 + | +LL | fn my_fun() -> Return<()> {} + | ^^ + | +note: used non-generic type `()` for generic parameter + --> $DIR/issue-69136-inner-lifetime-resolve-error.rs:17:13 + | +LL | type Return = impl WithAssoc; + | ^ + +error: non-defining opaque type use in defining scope + --> $DIR/issue-69136-inner-lifetime-resolve-error.rs:20:27 + | +LL | fn my_fun() -> Return<()> {} + | ^^ + | +note: used non-generic type `()` for generic parameter + --> $DIR/issue-69136-inner-lifetime-resolve-error.rs:17:13 + | +LL | type Return = impl WithAssoc; + | ^ + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0261`. diff --git a/src/test/ui/underscore-lifetime/in-binder.rs b/src/test/ui/underscore-lifetime/in-binder.rs index e4ee5e8cb274..74dc331b00a5 100644 --- a/src/test/ui/underscore-lifetime/in-binder.rs +++ b/src/test/ui/underscore-lifetime/in-binder.rs @@ -10,22 +10,22 @@ impl<'_> IceCube<'_> {} //~^ ERROR `'_` cannot be used here struct Struct<'_> { -//~^ ERROR `'_` cannot be used here + //~^ ERROR `'_` cannot be used here v: Vec<&'static char> } enum Enum<'_> { -//~^ ERROR `'_` cannot be used here + //~^ ERROR `'_` cannot be used here Variant } union Union<'_> { -//~^ ERROR `'_` cannot be used here + //~^ ERROR `'_` cannot be used here a: u32 } trait Trait<'_> { -//~^ ERROR `'_` cannot be used here + //~^ ERROR `'_` cannot be used here } fn foo<'_>() { diff --git a/src/test/ui/where-clauses/where-lifetime-resolution.stderr b/src/test/ui/where-clauses/where-lifetime-resolution.stderr index 6c52664154bb..e8df02fbad62 100644 --- a/src/test/ui/where-clauses/where-lifetime-resolution.stderr +++ b/src/test/ui/where-clauses/where-lifetime-resolution.stderr @@ -1,20 +1,41 @@ error[E0261]: use of undeclared lifetime name `'a` --> $DIR/where-lifetime-resolution.rs:6:38 | -LL | fn f() where - | - help: consider introducing lifetime `'a` here: `<'a>` -LL | for<'a> dyn Trait1<'a>: Trait1<'a>, // OK LL | (dyn for<'a> Trait1<'a>): Trait1<'a>, | ^^ undeclared lifetime + | + = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html +help: consider making the bound lifetime-generic with a new `'a` lifetime + | +LL | (dyn for<'a> Trait1<'a>): for<'a> Trait1<'a>, + | +++++++ +help: consider making the bound lifetime-generic with a new `'a` lifetime + | +LL | for<'a> (dyn for<'a> Trait1<'a>): Trait1<'a>, + | +++++++ +help: consider introducing lifetime `'a` here + | +LL | fn f<'a>() where + | ++++ error[E0261]: use of undeclared lifetime name `'b` --> $DIR/where-lifetime-resolution.rs:8:52 | -LL | fn f() where - | - help: consider introducing lifetime `'b` here: `<'b>` -... LL | for<'a> dyn for<'b> Trait2<'a, 'b>: Trait2<'a, 'b>, | ^^ undeclared lifetime + | +help: consider making the bound lifetime-generic with a new `'b` lifetime + | +LL | for<'a> dyn for<'b> Trait2<'a, 'b>: for<'b> Trait2<'a, 'b>, + | +++++++ +help: consider making the bound lifetime-generic with a new `'b` lifetime + | +LL | for<'b, 'a> dyn for<'b> Trait2<'a, 'b>: Trait2<'a, 'b>, + | +++ +help: consider introducing lifetime `'b` here + | +LL | fn f<'b>() where + | ++++ error: aborting due to 2 previous errors