]> git.lizzy.rs Git - rust.git/commitdiff
Bless tests.
authorCamille GILLOT <gillot.camille@gmail.com>
Sun, 6 Mar 2022 14:44:48 +0000 (15:44 +0100)
committerCamille GILLOT <gillot.camille@gmail.com>
Sun, 17 Apr 2022 09:03:34 +0000 (11:03 +0200)
24 files changed:
src/test/ui/generic-associated-types/gat-in-trait-path-undeclared-lifetime.stderr
src/test/ui/generic-associated-types/generic_associated_type_undeclared_lifetimes.stderr
src/test/ui/generic-associated-types/issue-67510.rs
src/test/ui/generic-associated-types/issue-67510.stderr
src/test/ui/generic-associated-types/issue-70304.rs
src/test/ui/generic-associated-types/issue-70304.stderr
src/test/ui/generics/generic-extern-lifetime.stderr
src/test/ui/impl-header-lifetime-elision/trait-elided.rs
src/test/ui/impl-header-lifetime-elision/trait-elided.stderr
src/test/ui/issues/issue-10412.rs
src/test/ui/issues/issue-10412.stderr
src/test/ui/lifetimes/undeclared-lifetime-used-in-debug-macro-issue-70152.stderr
src/test/ui/methods/method-call-lifetime-args-unresolved.rs
src/test/ui/methods/method-call-lifetime-args-unresolved.stderr
src/test/ui/regions/regions-name-static.rs
src/test/ui/regions/regions-name-undeclared.rs
src/test/ui/regions/regions-name-undeclared.stderr
src/test/ui/suggestions/fn-missing-lifetime-in-item.stderr
src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs
src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr
src/test/ui/type-alias-impl-trait/issue-69136-inner-lifetime-resolve-error.rs
src/test/ui/type-alias-impl-trait/issue-69136-inner-lifetime-resolve-error.stderr
src/test/ui/underscore-lifetime/in-binder.rs
src/test/ui/where-clauses/where-lifetime-resolution.stderr

index 317897ae70f72c9037aa5123a067968d2d423605..1792d8db292c47ee798f144a1973477bcb6c1297 100644 (file)
@@ -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<dyn for<'a> X<Y<'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<dyn for<'x, 'a> X<Y<'x> = &'a [u32]>>) {}
+   |                           +++
+help: consider introducing lifetime `'x` here
+   |
+LL |   fn _f<'x>(arg : Box<dyn for<'a> X<Y<'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
index bf0ca8715036b130e46c9aa7da8f5d7564e65b1b..a4bb361900fe166f61a1adbc88d2d8af4f7160cb 100644 (file)
@@ -4,14 +4,19 @@ error[E0261]: use of undeclared lifetime name `'b`
 LL |         + Deref<Target = Self::Item<'b>>;
    |                                     ^^ 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<Target = Self::Item<'b>>;
+   |           +++++++
 help: consider introducing lifetime `'b` here
    |
 LL |     type Iter<'b, 'a>: Iterator<Item = Self::Item<'a>>
    |               +++
+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
 
index e81a5b231a0015f34f267b32f8324f04718bf61e..5725b660ab2342505f0e8aead790ab2081be77e4 100644 (file)
@@ -4,9 +4,9 @@ trait X {
     type Y<'a>;
 }
 
-fn f(x: Box<dyn X<Y<'a>=&'a ()>>) {}
-  //~^ ERROR: use of undeclared lifetime name `'a`
-  //~| ERROR: use of undeclared lifetime name `'a`
-
+fn f(x: Box<dyn X<Y<'a> = &'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() {}
index abc02b33e0e6a115635876ba33c9a4cc2f998d4d..8aeda22bad75ffc1a853a844c88ccc78409a6916 100644 (file)
@@ -1,19 +1,50 @@
 error[E0261]: use of undeclared lifetime name `'a`
   --> $DIR/issue-67510.rs:7:21
    |
-LL | fn f(x: Box<dyn X<Y<'a>=&'a ()>>) {}
-   |     -               ^^ undeclared lifetime
-   |     |
-   |     help: consider introducing lifetime `'a` here: `<'a>`
+LL | fn f(x: Box<dyn X<Y<'a> = &'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<dyn for<'a> X<Y<'a> = &'a ()>>) {}
+   |                 +++++++
+help: consider introducing lifetime `'a` here
+   |
+LL | fn f<'a>(x: Box<dyn X<Y<'a> = &'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<dyn X<Y<'a> = &'a ()>>) {}
+   |                            ^^ undeclared lifetime
+   |
+help: consider making the bound lifetime-generic with a new `'a` lifetime
+   |
+LL | fn f(x: Box<dyn for<'a> X<Y<'a> = &'a ()>>) {}
+   |                 +++++++
+help: consider introducing lifetime `'a` here
+   |
+LL | fn f<'a>(x: Box<dyn X<Y<'a> = &'a ()>>) {}
+   |     ++++
+
+error[E0038]: the trait `X` cannot be made into an object
+  --> $DIR/issue-67510.rs:7:13
+   |
+LL | fn f(x: Box<dyn X<Y<'a> = &'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 <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
+  --> $DIR/issue-67510.rs:4:10
    |
-LL | fn f(x: Box<dyn X<Y<'a>=&'a ()>>) {}
-   |     -                    ^^ undeclared lifetime
-   |     |
-   |     help: consider introducing lifetime `'a` here: `<'a>`
+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
 
-error: aborting due to 2 previous errors
+error: aborting due to 3 previous errors
 
-For more information about this error, try `rustc --explain E0261`.
+Some errors have detailed explanations: E0038, E0261.
+For more information about an error, try `rustc --explain E0038`.
index ae64f9310d112912fb24bf32deaba3943153d377..448d7ec2873955bb67aaf6b7da37d509c59e3b01 100644 (file)
@@ -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 @@ struct Lexer<'d, Cursor>
     _phantom: std::marker::PhantomData<&'d ()>,
 }
 
-
 impl<'d, Cursor> Lexer<'d, Cursor>
 where
     Cursor: DocCursor<'d>,
@@ -44,15 +40,12 @@ pub fn from<Doc>(document: &'d Doc) -> Lexer<'d, Cursor>
     where
         Doc: Document<Cursor<'d> = Cursor>,
     {
-        Lexer {
-            cursor: document.cursor(),
-            _phantom: std::marker::PhantomData,
-        }
+        Lexer { cursor: document.cursor(), _phantom: std::marker::PhantomData }
     }
 }
 
 fn create_doc() -> impl Document<Cursor<'_> = DocCursorImpl<'_>> {
-                                       //~^ ERROR: missing lifetime specifier
+    //~^ ERROR: missing lifetime specifier
     DocumentImpl {}
 }
 
index c53dbf63a3c5b98c2891a316cfa2462159fe79ef..c5f59a24057d24747704ea38c570f0d2950ecd87 100644 (file)
@@ -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<Cursor<'_> = DocCursorImpl<'_>> {
    |                                         ^^ expected named lifetime parameter
index 909848604ec8a5048fad45f055cf8c20ac393d6c..33332e760f5823f3ec4ac018cb8f55426a43f2cb 100644 (file)
@@ -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
 
index 102d259b0c87ab5e9976df924dce3951c6448e77..c3e76d9cb5a030d3a5fa557df3ae1d6dfdb061ff 100644 (file)
@@ -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() {}
index 15bc3f106b9c48169fed5d56eb8af8fe6307fff0..be918d0a30ce81bf83441dd9db7d7e666962130a 100644 (file)
@@ -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...
index 020585136856bd35070624c7a0e54bcb44a019fe..0de170161b514a06b0a3576a2ab9c309be34c7a3 100644 (file)
@@ -1,16 +1,20 @@
-trait Serializable<'self, T> { //~ ERROR lifetimes cannot use keyword names
-    fn serialize(val : &'self T) -> Vec<u8>; //~ 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<u8>; //~ ERROR lifetimes cannot use keyword names
+    fn deserialize(repr: &[u8]) -> &'self T; //~ ERROR lifetimes cannot use keyword names
 }
 
-impl<'self> Serializable<str> for &'self str { //~ ERROR lifetimes cannot use keyword names
+impl<'self> Serializable<str> 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<u8> { //~ 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<u8> {
+        //~^ 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"
     }
 }
index a91b3c90ebb25e3328e26e51faab9e56d3dca5f6..a65005fd72d09ac1c59e6bbb721a1795332e17fe 100644 (file)
@@ -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<u8>;
-   |                         ^^^^^
+LL |     fn serialize(val: &'self T) -> Vec<u8>;
+   |                        ^^^^^
 
 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<str> 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<str> 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<u8> {
-   |                         ^^^^^
+LL |     fn serialize(val: &'self str) -> Vec<u8> {
+   |                        ^^^^^
 
 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<str> for &'self str {
    |             ^^^^^^^^^^^^^^^^^ help: indicate the anonymous lifetime: `Serializable<'_, str>`
@@ -49,7 +49,7 @@ LL | impl<'self> Serializable<str> 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<str> for &'self str {
    |             ^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
index cb459f31cd243fd14eb0683812b1c1b2847ee2b2..0d6ade41511fdcbd8766581e7b922090d1c75079 100644 (file)
@@ -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
 
index d16ba3df47b63de0fa78d120adab7aa840d5b8cd..ba7231070a0f428697d74e17a9b7bf1eda0a0a3e 100644 (file)
@@ -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
 }
index c9f235c4f7df7509b14b4aa93e065ec2670e2dc6..78af19586a1b7751168243c4883e2bdf735310a2 100644 (file)
@@ -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 <https://github.com/rust-lang/rust/issues/42868>
+
+error: aborting due to previous error; 1 warning emitted
 
 For more information about this error, try `rustc --explain E0261`.
index 730fd99aa68c29c92c2320b3196da7c7a4db019d..da316c6ef5e435c82b61b25b19bfa1ebb9505e08 100644 (file)
@@ -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() {}
index b8f50a40c45237cdd552f134d68e0b9871e0ad68..7b6ede19341b4953f141faa58f48252bc3f6d3c2 100644 (file)
@@ -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
index 4399263f716edca6daa667f35237d58778e1af44..532603de5f783f2b8d4939b2977d9f09be01fff7 100644 (file)
@@ -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<dyn for<'b, 'a> 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<dyn for<'a, 'b> 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<dyn for<'b, 'a> 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<dyn for<'a, 'b> 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`.
index 7c0f8d199a965b111a9c9be6479f379988499391..a761ec5916745d5a5df8bcdd450159165eed0abb 100644 (file)
@@ -5,14 +5,14 @@ LL | struct S1<F: Fn(&i32, &i32) -> &'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<F: for<'a> 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
index dd434ea5318781753c9ec94bbf55a6ada781a323..647b343fe06947c43727e39ec7b84c87a1ad5e73 100644 (file)
@@ -14,28 +14,31 @@ fn get(self) -> usize {
 
 fn foo<G, T>(g: G, dest: &mut T) -> impl FnOnce()
 where
-    G: Get<T>
+    G: Get<T>,
 {
     move || {
+        //~^ ERROR hidden type for `impl Trait` captures lifetime
         *dest = g.get();
     }
 }
 
 // After applying suggestion for `foo`:
 fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
+//~^ ERROR the parameter type `G` may not live long enough
 where
-    G: Get<T>
+    G: Get<T>,
 {
+    //~^ ERROR the parameter type `G` may not live long enough
     move || {
         *dest = g.get();
     }
 }
 
-
 // After applying suggestion for `bar`:
-fn baz<G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ //~ ERROR undeclared lifetime
+fn baz<G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
+//~^ ERROR undeclared lifetime name `'a`
 where
-    G: Get<T>
+    G: Get<T>,
 {
     move || {
         *dest = g.get();
@@ -44,9 +47,11 @@ fn baz<G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ //~ ERROR undeclared
 
 // 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<T>
+    G: Get<T>,
 {
+    //~^ ERROR the parameter type `G` may not live long enough
     move || {
         *dest = g.get();
     }
@@ -55,6 +60,8 @@ fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
 // Same as above, but show that we pay attention to lifetime names from parent item
 impl<'a> Foo {
     fn qux<'b, G: Get<T> + '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 @@ fn qux<'b, G: Get<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ {
 
 // 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<T>
+    G: Get<T>,
 {
     move || {
         *dest = g.get();
@@ -73,19 +81,20 @@ fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a
 
 // 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<T>
+    G: Get<T>,
 {
+    //~^ 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<T>
+    G: Get<T>,
 {
     move || {
         *dest = g.get();
@@ -95,7 +104,7 @@ fn ok<'a, G: 'a, T>(g: G, dest: &'a mut T) -> impl FnOnce() + 'a
 // 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<T>
+    G: Get<T>,
 {
     move || {
         *dest = g.get();
index 916a6c2bf12af6277f3affdfbb205a216295f3dc..6d538dfd609a80b47df0c180df5646e31308b387 100644 (file)
 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: 'a, T>(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, T>(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, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
+   |                                                   ++++
+
+error[E0311]: the parameter type `G` may not live long enough
+  --> $DIR/missing-lifetimes-in-signature.rs:26:37
+   |
+LL | fn bar<G, 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:26:26
+   |
+LL | fn bar<G, T>(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, T>(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, T>(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<T>,
+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<T>,
+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<T> + '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<T> + '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<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ {
+   |                                                          ^^^^^^^^^^^^^^^^^^
+help: consider introducing an explicit lifetime bound
+   |
+LL |     fn qux<'c, 'b, G: 'c + Get<T> + '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<T> + '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<T> + '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<T> + '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<T> + '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
 
-For more information about this error, try `rustc --explain E0261`.
+Some errors have detailed explanations: E0261, E0309, E0621, E0700.
+For more information about an error, try `rustc --explain E0261`.
index 6732902c09a504d7aef29f1291d36a998cfe3a8e..b0de8bf6aa4f267d578e319fff1bf448dac14d9d 100644 (file)
@@ -18,5 +18,7 @@ impl<T> WithAssoc<T> for () {
 //~^ 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() {}
index fe45e39d938f009e1b340cd155fbc6fb322cbe0b..d038fbbe1b40a191fc35a9da4cccccc9f95293f7 100644 (file)
@@ -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<A> = impl WithAssoc<A, AssocType = impl SomeTrait + 'a>;
-   |             -                                                   ^^ 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<A> = impl for<'a> WithAssoc<A, AssocType = impl SomeTrait + 'a>;
+   |                       +++++++
+help: consider introducing lifetime `'a` here
+   |
+LL | type Return<'a, A> = impl WithAssoc<A, AssocType = impl SomeTrait + 'a>;
+   |             +++
+
+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<A> = impl WithAssoc<A, AssocType = impl SomeTrait + 'a>;
+   |             ^
+
+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<A> = impl WithAssoc<A, AssocType = impl SomeTrait + 'a>;
+   |             ^
 
-error: aborting due to previous error
+error: aborting due to 3 previous errors
 
 For more information about this error, try `rustc --explain E0261`.
index e4ee5e8cb2741e8b5cf49a0cc4e32c17d3c43763..74dc331b00a5ce797c70091012def3c127f39ea9 100644 (file)
@@ -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<'_>() {
index 6c52664154bbf333667287e087c21af0396527b6..e8df02fbad62f3590c792544a85d29c697414904 100644 (file)
@@ -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