diff options
| author | bors <bors@rust-lang.org> | 2022-07-25 20:02:55 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-07-25 20:02:55 +0000 |
| commit | 6dbae3ad19309bb541d9e76638e6aa4b5449f29a (patch) | |
| tree | a35d361e27036633b9422e60fae27c050e298ec8 /src/test | |
| parent | bdf520fd419cd4dea184332f57206f1cf5ca3e8f (diff) | |
| parent | b9bd65e2ca68342bdb8ab56134677ad330d786ba (diff) | |
| download | rust-6dbae3ad19309bb541d9e76638e6aa4b5449f29a.tar.gz rust-6dbae3ad19309bb541d9e76638e6aa4b5449f29a.zip | |
Auto merge of #97313 - cjgillot:ast-lifetimes-anon, r=petrochenkov
Resolve function lifetime elision on the AST ~Based on https://github.com/rust-lang/rust/pull/97720~ Lifetime elision for functions is purely syntactic in nature, so can be resolved on the AST. This PR replicates the elision logic and diagnostics on the AST, and replaces HIR-based resolution by a `delay_span_bug`. This refactor allows for more consistent diagnostics, which don't have to guess the original code from HIR. r? `@petrochenkov`
Diffstat (limited to 'src/test')
51 files changed, 690 insertions, 669 deletions
diff --git a/src/test/ui/associated-type-bounds/elision.rs b/src/test/ui/associated-type-bounds/elision.rs new file mode 100644 index 00000000000..4a533939931 --- /dev/null +++ b/src/test/ui/associated-type-bounds/elision.rs @@ -0,0 +1,9 @@ +#![feature(associated_type_bounds)] +#![feature(anonymous_lifetime_in_impl_trait)] + +// The same thing should happen for constaints in dyn trait. +fn f(x: &mut dyn Iterator<Item: Iterator<Item = &'_ ()>>) -> Option<&'_ ()> { x.next() } +//~^ ERROR missing lifetime specifier +//~| ERROR mismatched types + +fn main() {} diff --git a/src/test/ui/associated-type-bounds/elision.stderr b/src/test/ui/associated-type-bounds/elision.stderr new file mode 100644 index 00000000000..ea302462749 --- /dev/null +++ b/src/test/ui/associated-type-bounds/elision.stderr @@ -0,0 +1,28 @@ +error[E0106]: missing lifetime specifier + --> $DIR/elision.rs:5:70 + | +LL | fn f(x: &mut dyn Iterator<Item: Iterator<Item = &'_ ()>>) -> Option<&'_ ()> { x.next() } + | ------------------------------------------------ ^^ expected named lifetime parameter + | + = help: this function's return type contains a borrowed value, but the signature does not say which one of `x`'s 2 lifetimes it is borrowed from +help: consider introducing a named lifetime parameter + | +LL | fn f<'a>(x: &'a mut dyn Iterator<Item: Iterator<Item = &'a ()>>) -> Option<&'a ()> { x.next() } + | ++++ ++ ~~ ~~ + +error[E0308]: mismatched types + --> $DIR/elision.rs:5:79 + | +LL | fn f(x: &mut dyn Iterator<Item: Iterator<Item = &'_ ()>>) -> Option<&'_ ()> { x.next() } + | ----------------------------- -------------- ^^^^^^^^ expected `&()`, found type parameter `impl Iterator<Item = &'_ ()>` + | | | + | | expected `Option<&'static ()>` because of return type + | this type parameter + | + = note: expected enum `Option<&'static ()>` + found enum `Option<impl Iterator<Item = &'_ ()>>` + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0106, E0308. +For more information about an error, try `rustc --explain E0106`. diff --git a/src/test/ui/associated-types/bound-lifetime-in-binding-only.elision.stderr b/src/test/ui/associated-types/bound-lifetime-in-binding-only.elision.stderr index e8e07997c72..4de4afb6e92 100644 --- a/src/test/ui/associated-types/bound-lifetime-in-binding-only.elision.stderr +++ b/src/test/ui/associated-types/bound-lifetime-in-binding-only.elision.stderr @@ -5,15 +5,10 @@ LL | fn elision<T: Fn() -> &i32>() { | ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from - = 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 elision<T: for<'a> Fn() -> &'a i32>() { - | +++++++ ~~~ help: consider using the `'static` lifetime | LL | fn elision<T: Fn() -> &'static i32>() { - | ~~~~~~~~ + | +++++++ error: aborting due to previous error diff --git a/src/test/ui/associated-types/bound-lifetime-in-return-only.elision.stderr b/src/test/ui/associated-types/bound-lifetime-in-return-only.elision.stderr index c75e732b7ca..7753d186504 100644 --- a/src/test/ui/associated-types/bound-lifetime-in-return-only.elision.stderr +++ b/src/test/ui/associated-types/bound-lifetime-in-return-only.elision.stderr @@ -5,15 +5,10 @@ LL | fn elision(_: fn() -> &i32) { | ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from - = 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 | fn elision(_: for<'a> fn() -> &'a i32) { - | +++++++ ~~~ help: consider using the `'static` lifetime | LL | fn elision(_: fn() -> &'static i32) { - | ~~~~~~~~ + | +++++++ error: aborting due to previous error diff --git a/src/test/ui/async-await/issues/issue-63388-2.rs b/src/test/ui/async-await/issues/issue-63388-2.rs index 458bc9faeaf..90b59f96e5f 100644 --- a/src/test/ui/async-await/issues/issue-63388-2.rs +++ b/src/test/ui/async-await/issues/issue-63388-2.rs @@ -11,6 +11,7 @@ impl Xyz { foo: &dyn Foo, bar: &'a dyn Foo ) -> &dyn Foo //~ ERROR missing lifetime specifier { + //~^ ERROR explicit lifetime required in the type of `foo` [E0621] foo } } diff --git a/src/test/ui/async-await/issues/issue-63388-2.stderr b/src/test/ui/async-await/issues/issue-63388-2.stderr index 24fd3845b4e..e515f227c7e 100644 --- a/src/test/ui/async-await/issues/issue-63388-2.stderr +++ b/src/test/ui/async-await/issues/issue-63388-2.stderr @@ -10,8 +10,21 @@ LL | ) -> &dyn Foo help: consider using the `'a` lifetime | LL | ) -> &'a dyn Foo - | ~~~ + | ++ -error: aborting due to previous error +error[E0621]: explicit lifetime required in the type of `foo` + --> $DIR/issue-63388-2.rs:13:5 + | +LL | foo: &dyn Foo, bar: &'a dyn Foo + | -------- help: add explicit lifetime `'a` to the type of `foo`: `&'a (dyn Foo + 'a)` +LL | ) -> &dyn Foo +LL | / { +LL | | +LL | | foo +LL | | } + | |_____^ lifetime `'a` required + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0106`. +Some errors have detailed explanations: E0106, E0621. +For more information about an error, try `rustc --explain E0106`. diff --git a/src/test/ui/c-variadic/variadic-ffi-6.stderr b/src/test/ui/c-variadic/variadic-ffi-6.stderr index bb15cc000a4..4c7792d9650 100644 --- a/src/test/ui/c-variadic/variadic-ffi-6.stderr +++ b/src/test/ui/c-variadic/variadic-ffi-6.stderr @@ -4,11 +4,11 @@ error[E0106]: missing lifetime specifier LL | ) -> &usize { | ^ expected named lifetime parameter | - = help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments + = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from help: consider using the `'static` lifetime | LL | ) -> &'static usize { - | ~~~~~~~~ + | +++++++ error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0106.stderr b/src/test/ui/error-codes/E0106.stderr index fbd77d96700..d11a24f7768 100644 --- a/src/test/ui/error-codes/E0106.stderr +++ b/src/test/ui/error-codes/E0106.stderr @@ -24,6 +24,17 @@ LL ~ B(&'a bool), | error[E0106]: missing lifetime specifier + --> $DIR/E0106.rs:10:14 + | +LL | type MyStr = &str; + | ^ expected named lifetime parameter + | +help: consider introducing a named lifetime parameter + | +LL | type MyStr<'a> = &'a str; + | ++++ ++ + +error[E0106]: missing lifetime specifier --> $DIR/E0106.rs:17:10 | LL | baz: Baz, @@ -50,17 +61,6 @@ LL | LL ~ buzz: Buzz<'a, 'a>, | -error[E0106]: missing lifetime specifier - --> $DIR/E0106.rs:10:14 - | -LL | type MyStr = &str; - | ^ expected named lifetime parameter - | -help: consider introducing a named lifetime parameter - | -LL | type MyStr<'a> = &'a str; - | ++++ ++ - error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/error-codes/E0637.stderr b/src/test/ui/error-codes/E0637.stderr index 87aaba65a73..35a4b34fb0a 100644 --- a/src/test/ui/error-codes/E0637.stderr +++ b/src/test/ui/error-codes/E0637.stderr @@ -4,12 +4,6 @@ error[E0637]: `'_` cannot be used here LL | fn underscore_lifetime<'_>(str1: &'_ str, str2: &'_ str) -> &'_ str { | ^^ `'_` is a reserved lifetime name -error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/E0637.rs:13:13 - | -LL | T: Into<&u32>, - | ^ explicit lifetime name needed here - error[E0106]: missing lifetime specifier --> $DIR/E0637.rs:1:62 | @@ -22,6 +16,12 @@ help: consider introducing a named lifetime parameter LL | fn underscore_lifetime<'a, '_>(str1: &'a str, str2: &'a str) -> &'a str { | +++ ~~ ~~ ~~ +error[E0637]: `&` without an explicit lifetime name cannot be used here + --> $DIR/E0637.rs:13:13 + | +LL | T: Into<&u32>, + | ^ explicit lifetime name needed here + error: aborting due to 3 previous errors Some errors have detailed explanations: E0106, E0637. diff --git a/src/test/ui/foreign-fn-return-lifetime.stderr b/src/test/ui/foreign-fn-return-lifetime.stderr index b174766cd3d..df1a23a19ed 100644 --- a/src/test/ui/foreign-fn-return-lifetime.stderr +++ b/src/test/ui/foreign-fn-return-lifetime.stderr @@ -8,7 +8,7 @@ LL | pub fn f() -> &u8; help: consider using the `'static` lifetime | LL | pub fn f() -> &'static u8; - | ~~~~~~~~ + | +++++++ error: aborting due to previous error diff --git a/src/test/ui/generic-associated-types/gat-trait-path-generic-type-arg.rs b/src/test/ui/generic-associated-types/gat-trait-path-generic-type-arg.rs index 246659a268a..dbf7e02aeaf 100644 --- a/src/test/ui/generic-associated-types/gat-trait-path-generic-type-arg.rs +++ b/src/test/ui/generic-associated-types/gat-trait-path-generic-type-arg.rs @@ -7,9 +7,10 @@ trait Foo { } impl <T, T1> Foo for T { + //~^ ERROR: the type parameter `T1` is not constrained type F<T1> = &[u8]; //~^ ERROR: the name `T1` is already used for - //~| ERROR: missing lifetime specifier + //~| ERROR: `&` without an explicit lifetime name cannot be used here } fn main() {} diff --git a/src/test/ui/generic-associated-types/gat-trait-path-generic-type-arg.stderr b/src/test/ui/generic-associated-types/gat-trait-path-generic-type-arg.stderr index e82cbf7e8e5..dad0dae6a44 100644 --- a/src/test/ui/generic-associated-types/gat-trait-path-generic-type-arg.stderr +++ b/src/test/ui/generic-associated-types/gat-trait-path-generic-type-arg.stderr @@ -1,23 +1,25 @@ error[E0403]: the name `T1` is already used for a generic parameter in this item's generic parameters - --> $DIR/gat-trait-path-generic-type-arg.rs:10:12 + --> $DIR/gat-trait-path-generic-type-arg.rs:11:12 | LL | impl <T, T1> Foo for T { | -- first use of `T1` +LL | LL | type F<T1> = &[u8]; | ^^ already used -error[E0106]: missing lifetime specifier - --> $DIR/gat-trait-path-generic-type-arg.rs:10:18 +error[E0637]: `&` without an explicit lifetime name cannot be used here + --> $DIR/gat-trait-path-generic-type-arg.rs:11:18 | LL | type F<T1> = &[u8]; - | ^ expected named lifetime parameter - | -help: consider introducing a named lifetime parameter + | ^ explicit lifetime name needed here + +error[E0207]: the type parameter `T1` is not constrained by the impl trait, self type, or predicates + --> $DIR/gat-trait-path-generic-type-arg.rs:9:10 | -LL | type F<'a, T1> = &'a [u8]; - | +++ ++ +LL | impl <T, T1> Foo for T { + | ^^ unconstrained type parameter -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors -Some errors have detailed explanations: E0106, E0403. -For more information about an error, try `rustc --explain E0106`. +Some errors have detailed explanations: E0207, E0403, E0637. +For more information about an error, try `rustc --explain E0207`. diff --git a/src/test/ui/generic-associated-types/issue-70304.rs b/src/test/ui/generic-associated-types/issue-70304.rs index c9fd7248a80..f778f985cf0 100644 --- a/src/test/ui/generic-associated-types/issue-70304.rs +++ b/src/test/ui/generic-associated-types/issue-70304.rs @@ -2,6 +2,7 @@ trait Document { type Cursor<'a>: DocCursor<'a>; + //~^ ERROR: missing required bound on `Cursor` fn cursor(&self) -> Self::Cursor<'_>; } diff --git a/src/test/ui/generic-associated-types/issue-70304.stderr b/src/test/ui/generic-associated-types/issue-70304.stderr index b3881ccb099..bba7cab7093 100644 --- a/src/test/ui/generic-associated-types/issue-70304.stderr +++ b/src/test/ui/generic-associated-types/issue-70304.stderr @@ -1,11 +1,11 @@ error[E0637]: `'_` cannot be used here - --> $DIR/issue-70304.rs:47:41 + --> $DIR/issue-70304.rs:48:41 | LL | fn create_doc() -> impl Document<Cursor<'_> = DocCursorImpl<'_>> { | ^^ `'_` is a reserved lifetime name error[E0106]: missing lifetime specifier - --> $DIR/issue-70304.rs:47:61 + --> $DIR/issue-70304.rs:48:61 | LL | fn create_doc() -> impl Document<Cursor<'_> = DocCursorImpl<'_>> { | ^^ expected named lifetime parameter @@ -16,7 +16,18 @@ help: consider using the `'static` lifetime LL | fn create_doc() -> impl Document<Cursor<'_> = DocCursorImpl<'static>> { | ~~~~~~~ -error: aborting due to 2 previous errors +error: missing required bound on `Cursor` + --> $DIR/issue-70304.rs:4:5 + | +LL | type Cursor<'a>: DocCursor<'a>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: add the required where clause: `where Self: 'a` + | + = note: this bound is currently required to ensure that impls have maximum flexibility + = note: we are soliciting feedback, see issue #87479 <https://github.com/rust-lang/rust/issues/87479> for more information + +error: aborting due to 3 previous errors Some errors have detailed explanations: E0106, E0637. For more information about an error, try `rustc --explain E0106`. diff --git a/src/test/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.rs b/src/test/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.rs index 54b483f53d4..9ea9fc71b55 100644 --- a/src/test/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.rs +++ b/src/test/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.rs @@ -8,6 +8,7 @@ fn should_error<T>() where T : Into<&u32> {} trait X<'a, K: 'a> { fn foo<'b, L: X<&'b Nested<K>>>(); //~^ ERROR missing lifetime specifier [E0106] + //~| ERROR the type `&'b Nested<K>` does not fulfill the required lifetime } fn bar<'b, L: X<&'b Nested<i32>>>(){} diff --git a/src/test/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.stderr b/src/test/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.stderr index 270d6b8e18e..e45387acaf3 100644 --- a/src/test/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.stderr +++ b/src/test/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.stderr @@ -5,21 +5,10 @@ LL | fn should_error<T>() where T : Into<&u32> {} | ^ explicit lifetime name needed here error[E0106]: missing lifetime specifier - --> $DIR/issue-65285-incorrect-explicit-lifetime-name-needed.rs:13:17 - | -LL | fn bar<'b, L: X<&'b Nested<i32>>>(){} - | ^ expected named lifetime parameter - | -help: consider using the `'b` lifetime - | -LL | fn bar<'b, L: X<'b, &'b Nested<i32>>>(){} - | +++ - -error[E0106]: missing lifetime specifier - --> $DIR/issue-65285-incorrect-explicit-lifetime-name-needed.rs:9:21 + --> $DIR/issue-65285-incorrect-explicit-lifetime-name-needed.rs:9:20 | LL | fn foo<'b, L: X<&'b Nested<K>>>(); - | ^ expected named lifetime parameter + | ^ expected named lifetime parameter | note: these named lifetimes are available to use --> $DIR/issue-65285-incorrect-explicit-lifetime-name-needed.rs:8:9 @@ -33,7 +22,30 @@ help: consider using one of the available lifetimes here LL | fn foo<'b, L: X<'lifetime, &'b Nested<K>>>(); | ++++++++++ -error: aborting due to 3 previous errors +error[E0106]: missing lifetime specifier + --> $DIR/issue-65285-incorrect-explicit-lifetime-name-needed.rs:14:16 + | +LL | fn bar<'b, L: X<&'b Nested<i32>>>(){} + | ^ expected named lifetime parameter + | +help: consider using the `'b` lifetime + | +LL | fn bar<'b, L: X<'b, &'b Nested<i32>>>(){} + | +++ + +error[E0477]: the type `&'b Nested<K>` does not fulfill the required lifetime + --> $DIR/issue-65285-incorrect-explicit-lifetime-name-needed.rs:9:19 + | +LL | fn foo<'b, L: X<&'b Nested<K>>>(); + | ^^^^^^^^^^^^^^^^ + | +note: type must satisfy the static lifetime as required by this binding + --> $DIR/issue-65285-incorrect-explicit-lifetime-name-needed.rs:8:16 + | +LL | trait X<'a, K: 'a> { + | ^^ + +error: aborting due to 4 previous errors -Some errors have detailed explanations: E0106, E0637. +Some errors have detailed explanations: E0106, E0477, E0637. For more information about an error, try `rustc --explain E0106`. diff --git a/src/test/ui/generics/wrong-number-of-args.rs b/src/test/ui/generics/wrong-number-of-args.rs index 272cd361968..cd2f96a1819 100644 --- a/src/test/ui/generics/wrong-number-of-args.rs +++ b/src/test/ui/generics/wrong-number-of-args.rs @@ -120,6 +120,7 @@ mod r#trait { type B = Box<dyn GenericLifetime>; //~^ ERROR missing lifetime specifier //~| HELP consider introducing + //~| HELP consider making the bound lifetime-generic type C = Box<dyn GenericLifetime<'static, 'static>>; //~^ ERROR this trait takes 1 lifetime argument but 2 lifetime arguments were supplied @@ -136,6 +137,7 @@ mod r#trait { type F = Box<dyn GenericLifetime<>>; //~^ ERROR missing lifetime specifier //~| HELP consider introducing + //~| HELP consider making the bound lifetime-generic type G = Box<dyn GenericType<>>; //~^ ERROR this trait takes 1 generic argument but 0 generic arguments @@ -161,6 +163,7 @@ mod associated_item { type A = Box<dyn GenericLifetimeAT<AssocTy=()>>; //~^ ERROR missing lifetime specifier //~| HELP consider introducing + //~| HELP consider making the bound lifetime-generic type B = Box<dyn GenericLifetimeAT<'static, 'static, AssocTy=()>>; //~^ ERROR this trait takes 1 lifetime argument but 2 lifetime arguments were supplied @@ -169,6 +172,7 @@ mod associated_item { type C = Box<dyn GenericLifetimeAT<(), AssocTy=()>>; //~^ ERROR missing lifetime specifier //~| HELP consider introducing + //~| HELP consider making the bound lifetime-generic //~| ERROR this trait takes 0 generic arguments but 1 generic argument //~| HELP remove } @@ -203,6 +207,7 @@ mod associated_item { //~| HELP add missing //~| ERROR missing lifetime specifier //~| HELP consider introducing + //~| HELP consider making the bound lifetime-generic type B = Box<dyn GenericLifetimeTypeAT<'static, AssocTy=()>>; //~^ ERROR this trait takes 1 generic argument but 0 generic arguments were supplied @@ -217,10 +222,12 @@ mod associated_item { type D = Box<dyn GenericLifetimeTypeAT<(), AssocTy=()>>; //~^ ERROR missing lifetime specifier //~| HELP consider introducing + //~| HELP consider making the bound lifetime-generic type E = Box<dyn GenericLifetimeTypeAT<(), (), AssocTy=()>>; //~^ ERROR missing lifetime specifier //~| HELP consider introducing + //~| HELP consider making the bound lifetime-generic //~| ERROR this trait takes 1 generic argument but 2 generic arguments //~| HELP remove @@ -265,6 +272,7 @@ mod associated_item { type A = Box<dyn GenericLifetimeLifetimeAT<AssocTy=()>>; //~^ ERROR missing lifetime specifier //~| HELP consider introducing + //~| HELP consider making the bound lifetime-generic type B = Box<dyn GenericLifetimeLifetimeAT<'static, AssocTy=()>>; //~^ ERROR this trait takes 2 lifetime arguments but 1 lifetime argument was supplied @@ -279,6 +287,7 @@ mod associated_item { type A = Box<dyn GenericLifetimeLifetimeTypeAT<AssocTy=()>>; //~^ ERROR missing lifetime specifier //~| HELP consider introducing + //~| HELP consider making the bound lifetime-generic //~| ERROR this trait takes 1 generic argument but 0 generic arguments //~| HELP add missing diff --git a/src/test/ui/generics/wrong-number-of-args.stderr b/src/test/ui/generics/wrong-number-of-args.stderr index 3b0834a5f51..388c23fc24f 100644 --- a/src/test/ui/generics/wrong-number-of-args.stderr +++ b/src/test/ui/generics/wrong-number-of-args.stderr @@ -1,3 +1,172 @@ +error[E0106]: missing lifetime specifier + --> $DIR/wrong-number-of-args.rs:48:14 + | +LL | type A = Ty; + | ^^ expected named lifetime parameter + | +help: consider introducing a named lifetime parameter + | +LL | type A<'a> = Ty<'a>; + | ++++ ++++ + +error[E0106]: missing lifetime specifier + --> $DIR/wrong-number-of-args.rs:58:16 + | +LL | type C = Ty<usize>; + | ^ expected named lifetime parameter + | +help: consider introducing a named lifetime parameter + | +LL | type C<'a> = Ty<'a, usize>; + | ++++ +++ + +error[E0106]: missing lifetime specifier + --> $DIR/wrong-number-of-args.rs:64:16 + | +LL | type E = Ty<>; + | ^ expected named lifetime parameter + | +help: consider introducing a named lifetime parameter + | +LL | type E<'a> = Ty<'a, >; + | ++++ +++ + +error[E0106]: missing lifetime specifier + --> $DIR/wrong-number-of-args.rs:120:22 + | +LL | type B = Box<dyn GenericLifetime>; + | ^^^^^^^^^^^^^^^ expected named lifetime parameter + | + = 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 B = Box<dyn for<'a> GenericLifetime<'a>>; + | +++++++ ++++ +help: consider introducing a named lifetime parameter + | +LL | type B<'a> = Box<dyn GenericLifetime<'a>>; + | ++++ ++++ + +error[E0106]: missing lifetime specifier + --> $DIR/wrong-number-of-args.rs:137:37 + | +LL | type F = Box<dyn GenericLifetime<>>; + | ^ expected named lifetime parameter + | +help: consider making the bound lifetime-generic with a new `'a` lifetime + | +LL | type F = Box<dyn for<'a> GenericLifetime<'a, >>; + | +++++++ +++ +help: consider introducing a named lifetime parameter + | +LL | type F<'a> = Box<dyn GenericLifetime<'a, >>; + | ++++ +++ + +error[E0106]: missing lifetime specifier + --> $DIR/wrong-number-of-args.rs:163:43 + | +LL | type A = Box<dyn GenericLifetimeAT<AssocTy=()>>; + | ^ expected named lifetime parameter + | +help: consider making the bound lifetime-generic with a new `'a` lifetime + | +LL | type A = Box<dyn for<'a> GenericLifetimeAT<'a, AssocTy=()>>; + | +++++++ +++ +help: consider introducing a named lifetime parameter + | +LL | type A<'a> = Box<dyn GenericLifetimeAT<'a, AssocTy=()>>; + | ++++ +++ + +error[E0106]: missing lifetime specifier + --> $DIR/wrong-number-of-args.rs:172:43 + | +LL | type C = Box<dyn GenericLifetimeAT<(), AssocTy=()>>; + | ^ expected named lifetime parameter + | +help: consider making the bound lifetime-generic with a new `'a` lifetime + | +LL | type C = Box<dyn for<'a> GenericLifetimeAT<'a, (), AssocTy=()>>; + | +++++++ +++ +help: consider introducing a named lifetime parameter + | +LL | type C<'a> = Box<dyn GenericLifetimeAT<'a, (), AssocTy=()>>; + | ++++ +++ + +error[E0106]: missing lifetime specifier + --> $DIR/wrong-number-of-args.rs:205:47 + | +LL | type A = Box<dyn GenericLifetimeTypeAT<AssocTy=()>>; + | ^ expected named lifetime parameter + | +help: consider making the bound lifetime-generic with a new `'a` lifetime + | +LL | type A = Box<dyn for<'a> GenericLifetimeTypeAT<'a, AssocTy=()>>; + | +++++++ +++ +help: consider introducing a named lifetime parameter + | +LL | type A<'a> = Box<dyn GenericLifetimeTypeAT<'a, AssocTy=()>>; + | ++++ +++ + +error[E0106]: missing lifetime specifier + --> $DIR/wrong-number-of-args.rs:222:47 + | +LL | type D = Box<dyn GenericLifetimeTypeAT<(), AssocTy=()>>; + | ^ expected named lifetime parameter + | +help: consider making the bound lifetime-generic with a new `'a` lifetime + | +LL | type D = Box<dyn for<'a> GenericLifetimeTypeAT<'a, (), AssocTy=()>>; + | +++++++ +++ +help: consider introducing a named lifetime parameter + | +LL | type D<'a> = Box<dyn GenericLifetimeTypeAT<'a, (), AssocTy=()>>; + | ++++ +++ + +error[E0106]: missing lifetime specifier + --> $DIR/wrong-number-of-args.rs:227:47 + | +LL | type E = Box<dyn GenericLifetimeTypeAT<(), (), AssocTy=()>>; + | ^ expected named lifetime parameter + | +help: consider making the bound lifetime-generic with a new `'a` lifetime + | +LL | type E = Box<dyn for<'a> GenericLifetimeTypeAT<'a, (), (), AssocTy=()>>; + | +++++++ +++ +help: consider introducing a named lifetime parameter + | +LL | type E<'a> = Box<dyn GenericLifetimeTypeAT<'a, (), (), AssocTy=()>>; + | ++++ +++ + +error[E0106]: missing lifetime specifiers + --> $DIR/wrong-number-of-args.rs:272:51 + | +LL | type A = Box<dyn GenericLifetimeLifetimeAT<AssocTy=()>>; + | ^ expected 2 lifetime parameters + | +help: consider making the bound lifetime-generic with a new `'a` lifetime + | +LL | type A = Box<dyn for<'a> GenericLifetimeLifetimeAT<'a, 'a, AssocTy=()>>; + | +++++++ +++++++ +help: consider introducing a named lifetime parameter + | +LL | type A<'a> = Box<dyn GenericLifetimeLifetimeAT<'a, 'a, AssocTy=()>>; + | ++++ +++++++ + +error[E0106]: missing lifetime specifiers + --> $DIR/wrong-number-of-args.rs:287:55 + | +LL | type A = Box<dyn GenericLifetimeLifetimeTypeAT<AssocTy=()>>; + | ^ expected 2 lifetime parameters + | +help: consider making the bound lifetime-generic with a new `'a` lifetime + | +LL | type A = Box<dyn for<'a> GenericLifetimeLifetimeTypeAT<'a, 'a, AssocTy=()>>; + | +++++++ +++++++ +help: consider introducing a named lifetime parameter + | +LL | type A<'a> = Box<dyn GenericLifetimeLifetimeTypeAT<'a, 'a, AssocTy=()>>; + | ++++ +++++++ + error[E0107]: this struct takes 0 lifetime arguments but 1 lifetime argument was supplied --> $DIR/wrong-number-of-args.rs:6:14 | @@ -148,17 +317,6 @@ help: add missing generic argument LL | type A = Ty<T>; | ~~~~~ -error[E0106]: missing lifetime specifier - --> $DIR/wrong-number-of-args.rs:48:14 - | -LL | type A = Ty; - | ^^ expected named lifetime parameter - | -help: consider introducing a named lifetime parameter - | -LL | type A<'a> = Ty<'a>; - | ++++ ~~~~~~ - error[E0107]: this struct takes 1 generic argument but 0 generic arguments were supplied --> $DIR/wrong-number-of-args.rs:54:14 | @@ -175,17 +333,6 @@ help: add missing generic argument LL | type B = Ty<'static, T>; | +++ -error[E0106]: missing lifetime specifier - --> $DIR/wrong-number-of-args.rs:58:17 - | -LL | type C = Ty<usize>; - | ^ expected named lifetime parameter - | -help: consider introducing a named lifetime parameter - | -LL | type C<'a> = Ty<'a, usize>; - | ++++ +++ - error[E0107]: this struct takes 1 generic argument but 0 generic arguments were supplied --> $DIR/wrong-number-of-args.rs:64:14 | @@ -202,17 +349,6 @@ help: add missing generic argument LL | type E = Ty<T>; | + -error[E0106]: missing lifetime specifier - --> $DIR/wrong-number-of-args.rs:64:16 - | -LL | type E = Ty<>; - | ^- expected named lifetime parameter - | -help: consider introducing a named lifetime parameter - | -LL | type E<'a> = Ty<'a>; - | ++++ ++ - error[E0107]: this struct takes 1 lifetime argument but 2 lifetime arguments were supplied --> $DIR/wrong-number-of-args.rs:70:14 | @@ -319,19 +455,8 @@ note: trait defined here, with 0 generic parameters LL | trait NonGeneric { | ^^^^^^^^^^ -error[E0106]: missing lifetime specifier - --> $DIR/wrong-number-of-args.rs:120:22 - | -LL | type B = Box<dyn GenericLifetime>; - | ^^^^^^^^^^^^^^^ expected named lifetime parameter - | -help: consider introducing a named lifetime parameter - | -LL | type B<'a> = Box<dyn GenericLifetime<'a>>; - | ++++ ~~~~~~~~~~~~~~~~~~~ - error[E0107]: this trait takes 1 lifetime argument but 2 lifetime arguments were supplied - --> $DIR/wrong-number-of-args.rs:124:22 + --> $DIR/wrong-number-of-args.rs:125:22 | LL | type C = Box<dyn GenericLifetime<'static, 'static>>; | ^^^^^^^^^^^^^^^ ------- help: remove this lifetime argument @@ -345,7 +470,7 @@ LL | trait GenericLifetime<'a> { | ^^^^^^^^^^^^^^^ -- error[E0107]: missing generics for trait `GenericType` - --> $DIR/wrong-number-of-args.rs:128:22 + --> $DIR/wrong-number-of-args.rs:129:22 | LL | type D = Box<dyn GenericType>; | ^^^^^^^^^^^ expected 1 generic argument @@ -361,7 +486,7 @@ LL | type D = Box<dyn GenericType<A>>; | ~~~~~~~~~~~~~~ error[E0107]: this trait takes 1 generic argument but 2 generic arguments were supplied - --> $DIR/wrong-number-of-args.rs:132:22 + --> $DIR/wrong-number-of-args.rs:133:22 | LL | type E = Box<dyn GenericType<String, usize>>; | ^^^^^^^^^^^ ----- help: remove this generic argument @@ -374,19 +499,8 @@ note: trait defined here, with 1 generic parameter: `A` LL | trait GenericType<A> { | ^^^^^^^^^^^ - -error[E0106]: missing lifetime specifier - --> $DIR/wrong-number-of-args.rs:136:37 - | -LL | type F = Box<dyn GenericLifetime<>>; - | ^- expected named lifetime parameter - | -help: consider introducing a named lifetime parameter - | -LL | type F<'a> = Box<dyn GenericLifetime<'a>>; - | ++++ ++ - error[E0107]: this trait takes 1 generic argument but 0 generic arguments were supplied - --> $DIR/wrong-number-of-args.rs:140:22 + --> $DIR/wrong-number-of-args.rs:142:22 | LL | type G = Box<dyn GenericType<>>; | ^^^^^^^^^^^ expected 1 generic argument @@ -402,7 +516,7 @@ LL | type G = Box<dyn GenericType<A>>; | + error[E0107]: this trait takes 0 generic arguments but 1 generic argument was supplied - --> $DIR/wrong-number-of-args.rs:151:26 + --> $DIR/wrong-number-of-args.rs:153:26 | LL | type A = Box<dyn NonGenericAT<usize, AssocTy=()>>; | ^^^^^^^^^^^^------------------- help: remove these generics @@ -410,24 +524,13 @@ LL | type A = Box<dyn NonGenericAT<usize, AssocTy=()>>; | expected 0 generic arguments | note: trait defined here, with 0 generic parameters - --> $DIR/wrong-number-of-args.rs:147:15 + --> $DIR/wrong-number-of-args.rs:149:15 | LL | trait NonGenericAT { | ^^^^^^^^^^^^ -error[E0106]: missing lifetime specifier - --> $DIR/wrong-number-of-args.rs:161:44 - | -LL | type A = Box<dyn GenericLifetimeAT<AssocTy=()>>; - | ^ expected named lifetime parameter - | -help: consider introducing a named lifetime parameter - | -LL | type A<'a> = Box<dyn GenericLifetimeAT<'a, AssocTy=()>>; - | ++++ +++ - error[E0107]: this trait takes 1 lifetime argument but 2 lifetime arguments were supplied - --> $DIR/wrong-number-of-args.rs:165:26 + --> $DIR/wrong-number-of-args.rs:168:26 | LL | type B = Box<dyn GenericLifetimeAT<'static, 'static, AssocTy=()>>; | ^^^^^^^^^^^^^^^^^ ------- help: remove this lifetime argument @@ -435,13 +538,13 @@ LL | type B = Box<dyn GenericLifetimeAT<'static, 'static, AssocTy=()>>; | expected 1 lifetime argument | note: trait defined here, with 1 lifetime parameter: `'a` - --> $DIR/wrong-number-of-args.rs:157:15 + --> $DIR/wrong-number-of-args.rs:159:15 | LL | trait GenericLifetimeAT<'a> { | ^^^^^^^^^^^^^^^^^ -- error[E0107]: this trait takes 0 generic arguments but 1 generic argument was supplied - --> $DIR/wrong-number-of-args.rs:169:26 + --> $DIR/wrong-number-of-args.rs:172:26 | LL | type C = Box<dyn GenericLifetimeAT<(), AssocTy=()>>; | ^^^^^^^^^^^^^^^^^ -- help: remove this generic argument @@ -449,30 +552,19 @@ LL | type C = Box<dyn GenericLifetimeAT<(), AssocTy=()>>; | expected 0 generic arguments | note: trait defined here, with 0 generic parameters - --> $DIR/wrong-number-of-args.rs:157:15 + --> $DIR/wrong-number-of-args.rs:159:15 | LL | trait GenericLifetimeAT<'a> { | ^^^^^^^^^^^^^^^^^ -error[E0106]: missing lifetime specifier - --> $DIR/wrong-number-of-args.rs:169:44 - | -LL | type C = Box<dyn GenericLifetimeAT<(), AssocTy=()>>; - | ^ expected named lifetime parameter - | -help: consider introducing a named lifetime parameter - | -LL | type C<'a> = Box<dyn GenericLifetimeAT<'a, (), AssocTy=()>>; - | ++++ +++ - error[E0107]: this trait takes 1 generic argument but 0 generic arguments were supplied - --> $DIR/wrong-number-of-args.rs:181:26 + --> $DIR/wrong-number-of-args.rs:185:26 | LL | type A = Box<dyn GenericTypeAT<AssocTy=()>>; | ^^^^^^^^^^^^^ expected 1 generic argument | note: trait defined here, with 1 generic parameter: `A` - --> $DIR/wrong-number-of-args.rs:177:15 + --> $DIR/wrong-number-of-args.rs:181:15 | LL | trait GenericTypeAT<A> { | ^^^^^^^^^^^^^ - @@ -482,7 +574,7 @@ LL | type A = Box<dyn GenericTypeAT<A, AssocTy=()>>; | ++ error[E0107]: this trait takes 1 generic argument but 2 generic arguments were supplied - --> $DIR/wrong-number-of-args.rs:185:26 + --> $DIR/wrong-number-of-args.rs:189:26 | LL | type B = Box<dyn GenericTypeAT<(), (), AssocTy=()>>; | ^^^^^^^^^^^^^ -- help: remove this generic argument @@ -490,13 +582,13 @@ LL | type B = Box<dyn GenericTypeAT<(), (), AssocTy=()>>; | expected 1 generic argument | note: trait defined here, with 1 generic parameter: `A` - --> $DIR/wrong-number-of-args.rs:177:15 + --> $DIR/wrong-number-of-args.rs:181:15 | LL | trait GenericTypeAT<A> { | ^^^^^^^^^^^^^ - error[E0107]: this trait takes 0 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/wrong-number-of-args.rs:189:26 + --> $DIR/wrong-number-of-args.rs:193:26 | LL | type C = Box<dyn GenericTypeAT<'static, AssocTy=()>>; | ^^^^^^^^^^^^^--------------------- help: remove these generics @@ -504,19 +596,19 @@ LL | type C = Box<dyn GenericTypeAT<'static, AssocTy=()>>; | expected 0 lifetime arguments | note: trait defined here, with 0 lifetime parameters - --> $DIR/wrong-number-of-args.rs:177:15 + --> $DIR/wrong-number-of-args.rs:181:15 | LL | trait GenericTypeAT<A> { | ^^^^^^^^^^^^^ error[E0107]: this trait takes 1 generic argument but 0 generic arguments were supplied - --> $DIR/wrong-number-of-args.rs:189:26 + --> $DIR/wrong-number-of-args.rs:193:26 | LL | type C = Box<dyn GenericTypeAT<'static, AssocTy=()>>; | ^^^^^^^^^^^^^ expected 1 generic argument | note: trait defined here, with 1 generic parameter: `A` - --> $DIR/wrong-number-of-args.rs:177:15 + --> $DIR/wrong-number-of-args.rs:181:15 | LL | trait GenericTypeAT<A> { | ^^^^^^^^^^^^^ - @@ -526,13 +618,13 @@ LL | type C = Box<dyn GenericTypeAT<'static, A, AssocTy=()>>; | +++ error[E0107]: this trait takes 1 generic argument but 0 generic arguments were supplied - --> $DIR/wrong-number-of-args.rs:201:26 + --> $DIR/wrong-number-of-args.rs:205:26 | LL | type A = Box<dyn GenericLifetimeTypeAT<AssocTy=()>>; | ^^^^^^^^^^^^^^^^^^^^^ expected 1 generic argument | note: trait defined here, with 1 generic parameter: `A` - --> $DIR/wrong-number-of-args.rs:197:15 + --> $DIR/wrong-number-of-args.rs:201:15 | LL | trait GenericLifetimeTypeAT<'a, A> { | ^^^^^^^^^^^^^^^^^^^^^ - @@ -541,25 +633,14 @@ help: add missing generic argument LL | type A = Box<dyn GenericLifetimeTypeAT<A, AssocTy=()>>; | ++ -error[E0106]: missing lifetime specifier - --> $DIR/wrong-number-of-args.rs:201:48 - | -LL | type A = Box<dyn GenericLifetimeTypeAT<AssocTy=()>>; - | ^ expected named lifetime parameter - | -help: consider introducing a named lifetime parameter - | -LL | type A<'a> = Box<dyn GenericLifetimeTypeAT<'a, AssocTy=()>>; - | ++++ +++ - error[E0107]: this trait takes 1 generic argument but 0 generic arguments were supplied - --> $DIR/wrong-number-of-args.rs:207:26 + --> $DIR/wrong-number-of-args.rs:212:26 | LL | type B = Box<dyn GenericLifetimeTypeAT<'static, AssocTy=()>>; | ^^^^^^^^^^^^^^^^^^^^^ expected 1 generic argument | note: trait defined here, with 1 generic parameter: `A` - --> $DIR/wrong-number-of-args.rs:197:15 + --> $DIR/wrong-number-of-args.rs:201:15 | LL | trait GenericLifetimeTypeAT<'a, A> { | ^^^^^^^^^^^^^^^^^^^^^ - @@ -569,7 +650,7 @@ LL | type B = Box<dyn GenericLifetimeTypeAT<'static, A, AssocTy=()>>; | +++ error[E0107]: this trait takes 1 lifetime argument but 2 lifetime arguments were supplied - --> $DIR/wrong-number-of-args.rs:211:26 + --> $DIR/wrong-number-of-args.rs:216:26 | LL | type C = Box<dyn GenericLifetimeTypeAT<'static, 'static, AssocTy=()>>; | ^^^^^^^^^^^^^^^^^^^^^ ------- help: remove this lifetime argument @@ -577,19 +658,19 @@ LL | type C = Box<dyn GenericLifetimeTypeAT<'static, 'static, AssocTy=() | expected 1 lifetime argument | note: trait defined here, with 1 lifetime parameter: `'a` - --> $DIR/wrong-number-of-args.rs:197:15 + --> $DIR/wrong-number-of-args.rs:201:15 | LL | trait GenericLifetimeTypeAT<'a, A> { | ^^^^^^^^^^^^^^^^^^^^^ -- error[E0107]: this trait takes 1 generic argument but 0 generic arguments were supplied - --> $DIR/wrong-number-of-args.rs:211:26 + --> $DIR/wrong-number-of-args.rs:216:26 | LL | type C = Box<dyn GenericLifetimeTypeAT<'static, 'static, AssocTy=()>>; | ^^^^^^^^^^^^^^^^^^^^^ expected 1 generic argument | note: trait defined here, with 1 generic parameter: `A` - --> $DIR/wrong-number-of-args.rs:197:15 + --> $DIR/wrong-number-of-args.rs:201:15 | LL | trait GenericLifetimeTypeAT<'a, A> { | ^^^^^^^^^^^^^^^^^^^^^ - @@ -598,19 +679,8 @@ help: add missing generic argument LL | type C = Box<dyn GenericLifetimeTypeAT<'static, 'static, A, AssocTy=()>>; | +++ -error[E0106]: missing lifetime specifier - --> $DIR/wrong-number-of-args.rs:217:48 - | -LL | type D = Box<dyn GenericLifetimeTypeAT<(), AssocTy=()>>; - | ^ expected named lifetime parameter - | -help: consider introducing a named lifetime parameter - | -LL | type D<'a> = Box<dyn GenericLifetimeTypeAT<'a, (), AssocTy=()>>; - | ++++ +++ - error[E0107]: this trait takes 1 generic argument but 2 generic arguments were supplied - --> $DIR/wrong-number-of-args.rs:221:26 + --> $DIR/wrong-number-of-args.rs:227:26 | LL | type E = Box<dyn GenericLifetimeTypeAT<(), (), AssocTy=()>>; | ^^^^^^^^^^^^^^^^^^^^^ -- help: remove this generic argument @@ -618,24 +688,13 @@ LL | type E = Box<dyn GenericLifetimeTypeAT<(), (), AssocTy=()>>; | expected 1 generic argument | note: trait defined here, with 1 generic parameter: `A` - --> $DIR/wrong-number-of-args.rs:197:15 + --> $DIR/wrong-number-of-args.rs:201:15 | LL | trait GenericLifetimeTypeAT<'a, A> { | ^^^^^^^^^^^^^^^^^^^^^ - -error[E0106]: missing lifetime specifier - --> $DIR/wrong-number-of-args.rs:221:48 - | -LL | type E = Box<dyn GenericLifetimeTypeAT<(), (), AssocTy=()>>; - | ^ expected named lifetime parameter - | -help: consider introducing a named lifetime parameter - | -LL | type E<'a> = Box<dyn GenericLifetimeTypeAT<'a, (), (), AssocTy=()>>; - | ++++ +++ - error[E0107]: this trait takes 1 lifetime argument but 2 lifetime arguments were supplied - --> $DIR/wrong-number-of-args.rs:227:26 + --> $DIR/wrong-number-of-args.rs:234:26 | LL | type F = Box<dyn GenericLifetimeTypeAT<'static, 'static, (), AssocTy=()>>; | ^^^^^^^^^^^^^^^^^^^^^ ------- help: remove this lifetime argument @@ -643,13 +702,13 @@ LL | type F = Box<dyn GenericLifetimeTypeAT<'static, 'static, (), AssocT | expected 1 lifetime argument | note: trait defined here, with 1 lifetime parameter: `'a` - --> $DIR/wrong-number-of-args.rs:197:15 + --> $DIR/wrong-number-of-args.rs:201:15 | LL | trait GenericLifetimeTypeAT<'a, A> { | ^^^^^^^^^^^^^^^^^^^^^ -- error[E0107]: this trait takes 1 generic argument but 2 generic arguments were supplied - --> $DIR/wrong-number-of-args.rs:231:26 + --> $DIR/wrong-number-of-args.rs:238:26 | LL | type G = Box<dyn GenericLifetimeTypeAT<'static, (), (), AssocTy=()>>; | ^^^^^^^^^^^^^^^^^^^^^ -- help: remove this generic argument @@ -657,13 +716,13 @@ LL | type G = Box<dyn GenericLifetimeTypeAT<'static, (), (), AssocTy=()> | expected 1 generic argument | note: trait defined here, with 1 generic parameter: `A` - --> $DIR/wrong-number-of-args.rs:197:15 + --> $DIR/wrong-number-of-args.rs:201:15 | LL | trait GenericLifetimeTypeAT<'a, A> { | ^^^^^^^^^^^^^^^^^^^^^ - error[E0107]: this trait takes 1 lifetime argument but 2 lifetime arguments were supplied - --> $DIR/wrong-number-of-args.rs:235:26 + --> $DIR/wrong-number-of-args.rs:242:26 | LL | type H = Box<dyn GenericLifetimeTypeAT<'static, 'static, (), (), AssocTy=()>>; | ^^^^^^^^^^^^^^^^^^^^^ ------- help: remove this lifetime argument @@ -671,13 +730,13 @@ LL | type H = Box<dyn GenericLifetimeTypeAT<'static, 'static, (), (), As | expected 1 lifetime argument | note: trait defined here, with 1 lifetime parameter: `'a` - --> $DIR/wrong-number-of-args.rs:197:15 + --> $DIR/wrong-number-of-args.rs:201:15 | LL | trait GenericLifetimeTypeAT<'a, A> { | ^^^^^^^^^^^^^^^^^^^^^ -- error[E0107]: this trait takes 1 generic argument but 2 generic arguments were supplied - --> $DIR/wrong-number-of-args.rs:235:26 + --> $DIR/wrong-number-of-args.rs:242:26 | LL | type H = Box<dyn GenericLifetimeTypeAT<'static, 'static, (), (), AssocTy=()>>; | ^^^^^^^^^^^^^^^^^^^^^ -- help: remove this generic argument @@ -685,19 +744,19 @@ LL | type H = Box<dyn GenericLifetimeTypeAT<'static, 'static, (), (), As | expected 1 generic argument | note: trait defined here, with 1 generic parameter: `A` - --> $DIR/wrong-number-of-args.rs:197:15 + --> $DIR/wrong-number-of-args.rs:201:15 | LL | trait GenericLifetimeTypeAT<'a, A> { | ^^^^^^^^^^^^^^^^^^^^^ - error[E0107]: this trait takes 2 generic arguments but 0 generic arguments were supplied - --> $DIR/wrong-number-of-args.rs:247:26 + --> $DIR/wrong-number-of-args.rs:254:26 | LL | type A = Box<dyn GenericTypeTypeAT<AssocTy=()>>; | ^^^^^^^^^^^^^^^^^ expected 2 generic arguments | note: trait defined here, with 2 generic parameters: `A`, `B` - --> $DIR/wrong-number-of-args.rs:243:15 + --> $DIR/wrong-number-of-args.rs:250:15 | LL | trait GenericTypeTypeAT<A, B> { | ^^^^^^^^^^^^^^^^^ - - @@ -707,7 +766,7 @@ LL | type A = Box<dyn GenericTypeTypeAT<A, B, AssocTy=()>>; | +++++ error[E0107]: this trait takes 2 generic arguments but 1 generic argument was supplied - --> $DIR/wrong-number-of-args.rs:251:26 + --> $DIR/wrong-number-of-args.rs:258:26 | LL | type B = Box<dyn GenericTypeTypeAT<(), AssocTy=()>>; | ^^^^^^^^^^^^^^^^^ -- supplied 1 generic argument @@ -715,7 +774,7 @@ LL | type B = Box<dyn GenericTypeTypeAT<(), AssocTy=()>>; | expected 2 generic arguments | note: trait defined here, with 2 generic parameters: `A`, `B` - --> $DIR/wrong-number-of-args.rs:243:15 + --> $DIR/wrong-number-of-args.rs:250:15 | LL | trait GenericTypeTypeAT<A, B> { | ^^^^^^^^^^^^^^^^^ - - @@ -725,7 +784,7 @@ LL | type B = Box<dyn GenericTypeTypeAT<(), B, AssocTy=()>>; | +++ error[E0107]: this trait takes 2 generic arguments but 3 generic arguments were supplied - --> $DIR/wrong-number-of-args.rs:255:26 + --> $DIR/wrong-number-of-args.rs:262:26 | LL | type C = Box<dyn GenericTypeTypeAT<(), (), (), AssocTy=()>>; | ^^^^^^^^^^^^^^^^^ -- help: remove this generic argument @@ -733,24 +792,13 @@ LL | type C = Box<dyn GenericTypeTypeAT<(), (), (), AssocTy=()>>; | expected 2 generic arguments | note: trait defined here, with 2 generic parameters: `A`, `B` - --> $DIR/wrong-number-of-args.rs:243:15 + --> $DIR/wrong-number-of-args.rs:250:15 | LL | trait GenericTypeTypeAT<A, B> { | ^^^^^^^^^^^^^^^^^ - - -error[E0106]: missing lifetime specifiers - --> $DIR/wrong-number-of-args.rs:265:52 - | -LL | type A = Box<dyn GenericLifetimeLifetimeAT<AssocTy=()>>; - | ^ expected 2 lifetime parameters - | -help: consider introducing a named lifetime parameter - | -LL | type A<'a> = Box<dyn GenericLifetimeLifetimeAT<'a, 'a, AssocTy=()>>; - | ++++ +++++++ - error[E0107]: this trait takes 2 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/wrong-number-of-args.rs:269:26 + --> $DIR/wrong-number-of-args.rs:277:26 | LL | type B = Box<dyn GenericLifetimeLifetimeAT<'static, AssocTy=()>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^ ------- supplied 1 lifetime argument @@ -758,7 +806,7 @@ LL | type B = Box<dyn GenericLifetimeLifetimeAT<'static, AssocTy=()>>; | expected 2 lifetime arguments | note: trait defined here, with 2 lifetime parameters: `'a`, `'b` - --> $DIR/wrong-number-of-args.rs:261:15 + --> $DIR/wrong-number-of-args.rs:268:15 | LL | trait GenericLifetimeLifetimeAT<'a, 'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^ -- -- @@ -768,13 +816,13 @@ LL | type B = Box<dyn GenericLifetimeLifetimeAT<'static, 'b, AssocTy=()> | ++++ error[E0107]: this trait takes 1 generic argument but 0 generic arguments were supplied - --> $DIR/wrong-number-of-args.rs:279:26 + --> $DIR/wrong-number-of-args.rs:287:26 | LL | type A = Box<dyn GenericLifetimeLifetimeTypeAT<AssocTy=()>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 1 generic argument | note: trait defined here, with 1 generic parameter: `A` - --> $DIR/wrong-number-of-args.rs:275:15 + --> $DIR/wrong-number-of-args.rs:283:15 | LL | trait GenericLifetimeLifetimeTypeAT<'a, 'b, A> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - @@ -783,19 +831,8 @@ help: add missing generic argument LL | type A = Box<dyn GenericLifetimeLifetimeTypeAT<A, AssocTy=()>>; | ++ -error[E0106]: missing lifetime specifiers - --> $DIR/wrong-number-of-args.rs:279:56 - | -LL | type A = Box<dyn GenericLifetimeLifetimeTypeAT<AssocTy=()>>; - | ^ expected 2 lifetime parameters - | -help: consider introducing a named lifetime parameter - | -LL | type A<'a> = Box<dyn GenericLifetimeLifetimeTypeAT<'a, 'a, AssocTy=()>>; - | ++++ +++++++ - error[E0107]: this trait takes 2 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/wrong-number-of-args.rs:285:26 + --> $DIR/wrong-number-of-args.rs:294:26 | LL | type B = Box<dyn GenericLifetimeLifetimeTypeAT<'static, AssocTy=()>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ------- supplied 1 lifetime argument @@ -803,7 +840,7 @@ LL | type B = Box<dyn GenericLifetimeLifetimeTypeAT<'static, AssocTy=()> | expected 2 lifetime arguments | note: trait defined here, with 2 lifetime parameters: `'a`, `'b` - --> $DIR/wrong-number-of-args.rs:275:15 + --> $DIR/wrong-number-of-args.rs:283:15 | LL | trait GenericLifetimeLifetimeTypeAT<'a, 'b, A> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -- -- @@ -813,13 +850,13 @@ LL | type B = Box<dyn GenericLifetimeLifetimeTypeAT<'static, 'b, AssocTy | ++++ error[E0107]: this trait takes 1 generic argument but 0 generic arguments were supplied - --> $DIR/wrong-number-of-args.rs:285:26 + --> $DIR/wrong-number-of-args.rs:294:26 | LL | type B = Box<dyn GenericLifetimeLifetimeTypeAT<'static, AssocTy=()>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 1 generic argument | note: trait defined here, with 1 generic parameter: `A` - --> $DIR/wrong-number-of-args.rs:275:15 + --> $DIR/wrong-number-of-args.rs:283:15 | LL | trait GenericLifetimeLifetimeTypeAT<'a, 'b, A> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - @@ -829,7 +866,7 @@ LL | type B = Box<dyn GenericLifetimeLifetimeTypeAT<'static, A, AssocTy= | +++ error[E0107]: this trait takes 2 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/wrong-number-of-args.rs:291:26 + --> $DIR/wrong-number-of-args.rs:300:26 | LL | type C = Box<dyn GenericLifetimeLifetimeTypeAT<'static, (), AssocTy=()>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ------- supplied 1 lifetime argument @@ -837,7 +874,7 @@ LL | type C = Box<dyn GenericLifetimeLifetimeTypeAT<'static, (), AssocTy | expected 2 lifetime arguments | note: trait defined here, with 2 lifetime parameters: `'a`, `'b` - --> $DIR/wrong-number-of-args.rs:275:15 + --> $DIR/wrong-number-of-args.rs:283:15 | LL | trait GenericLifetimeLifetimeTypeAT<'a, 'b, A> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -- -- @@ -847,7 +884,7 @@ LL | type C = Box<dyn GenericLifetimeLifetimeTypeAT<'static, 'b, (), Ass | ++++ error[E0107]: missing generics for struct `HashMap` - --> $DIR/wrong-number-of-args.rs:301:18 + --> $DIR/wrong-number-of-args.rs:310:18 | LL | type A = HashMap; | ^^^^^^^ expected at least 2 generic arguments @@ -863,7 +900,7 @@ LL | type A = HashMap<K, V>; | ~~~~~~~~~~~~~ error[E0107]: this struct takes at least 2 generic arguments but 1 generic argument was supplied - --> $DIR/wrong-number-of-args.rs:305:18 + --> $DIR/wrong-number-of-args.rs:314:18 | LL | type B = HashMap<String>; | ^^^^^^^ ------ supplied 1 generic argument @@ -881,7 +918,7 @@ LL | type B = HashMap<String, V>; | +++ error[E0107]: this struct takes 0 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/wrong-number-of-args.rs:309:18 + --> $DIR/wrong-number-of-args.rs:318:18 | LL | type C = HashMap<'static>; | ^^^^^^^--------- help: remove these generics @@ -895,7 +932,7 @@ LL | pub struct HashMap<K, V, S = RandomState> { | ^^^^^^^ error[E0107]: this struct takes at least 2 generic arguments but 0 generic arguments were supplied - --> $DIR/wrong-number-of-args.rs:309:18 + --> $DIR/wrong-number-of-args.rs:318:18 | LL | type C = HashMap<'static>; | ^^^^^^^ expected at least 2 generic arguments @@ -911,7 +948,7 @@ LL | type C = HashMap<'static, K, V>; | ++++++ error[E0107]: this struct takes at most 3 generic arguments but 4 generic arguments were supplied - --> $DIR/wrong-number-of-args.rs:315:18 + --> $DIR/wrong-number-of-args.rs:324:18 | LL | type D = HashMap<usize, String, char, f64>; | ^^^^^^^ --- help: remove this generic argument @@ -925,7 +962,7 @@ LL | pub struct HashMap<K, V, S = RandomState> { | ^^^^^^^ - - --------------- error[E0107]: this struct takes at least 2 generic arguments but 0 generic arguments were supplied - --> $DIR/wrong-number-of-args.rs:319:18 + --> $DIR/wrong-number-of-args.rs:328:18 | LL | type E = HashMap<>; | ^^^^^^^ expected at least 2 generic arguments @@ -941,7 +978,7 @@ LL | type E = HashMap<K, V>; | ++++ error[E0107]: missing generics for enum `Result` - --> $DIR/wrong-number-of-args.rs:325:18 + --> $DIR/wrong-number-of-args.rs:334:18 | LL | type A = Result; | ^^^^^^ expected 2 generic arguments @@ -957,7 +994,7 @@ LL | type A = Result<T, E>; | ~~~~~~~~~~~~ error[E0107]: this enum takes 2 generic arguments but 1 generic argument was supplied - --> $DIR/wrong-number-of-args.rs:329:18 + --> $DIR/wrong-number-of-args.rs:338:18 | LL | type B = Result<String>; | ^^^^^^ ------ supplied 1 generic argument @@ -975,7 +1012,7 @@ LL | type B = Result<String, E>; | +++ error[E0107]: this enum takes 0 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/wrong-number-of-args.rs:333:18 + --> $DIR/wrong-number-of-args.rs:342:18 | LL | type C = Result<'static>; | ^^^^^^--------- help: remove these generics @@ -989,7 +1026,7 @@ LL | pub enum Result<T, E> { | ^^^^^^ error[E0107]: this enum takes 2 generic arguments but 0 generic arguments were supplied - --> $DIR/wrong-number-of-args.rs:333:18 + --> $DIR/wrong-number-of-args.rs:342:18 | LL | type C = Result<'static>; | ^^^^^^ expected 2 generic arguments @@ -1005,7 +1042,7 @@ LL | type C = Result<'static, T, E>; | ++++++ error[E0107]: this enum takes 2 generic arguments but 3 generic arguments were supplied - --> $DIR/wrong-number-of-args.rs:339:18 + --> $DIR/wrong-number-of-args.rs:348:18 | LL | type D = Result<usize, String, char>; | ^^^^^^ ---- help: remove this generic argument @@ -1019,7 +1056,7 @@ LL | pub enum Result<T, E> { | ^^^^^^ - - error[E0107]: this enum takes 2 generic arguments but 0 generic arguments were supplied - --> $DIR/wrong-number-of-args.rs:343:18 + --> $DIR/wrong-number-of-args.rs:352:18 | LL | type E = Result<>; | ^^^^^^ expected 2 generic arguments diff --git a/src/test/ui/impl-header-lifetime-elision/assoc-type.rs b/src/test/ui/impl-header-lifetime-elision/assoc-type.rs index 44c46e444d6..b0089a37aa0 100644 --- a/src/test/ui/impl-header-lifetime-elision/assoc-type.rs +++ b/src/test/ui/impl-header-lifetime-elision/assoc-type.rs @@ -9,12 +9,12 @@ trait MyTrait { impl MyTrait for &i32 { type Output = &i32; - //~^ ERROR missing lifetime specifier + //~^ ERROR `&` without an explicit lifetime name cannot be used here } impl MyTrait for &u32 { type Output = &'_ i32; - //~^ ERROR missing lifetime specifier + //~^ ERROR `'_` cannot be used here } // This is what you have to do: diff --git a/src/test/ui/impl-header-lifetime-elision/assoc-type.stderr b/src/test/ui/impl-header-lifetime-elision/assoc-type.stderr index 44955c58889..c4f27e0b80e 100644 --- a/src/test/ui/impl-header-lifetime-elision/assoc-type.stderr +++ b/src/test/ui/impl-header-lifetime-elision/assoc-type.stderr @@ -1,25 +1,15 @@ -error[E0106]: missing lifetime specifier +error[E0637]: `&` without an explicit lifetime name cannot be used here --> $DIR/assoc-type.rs:11:19 | LL | type Output = &i32; - | ^ expected named lifetime parameter - | -help: consider introducing a named lifetime parameter - | -LL | type Output<'a> = &'a i32; - | ++++ ++ + | ^ explicit lifetime name needed here -error[E0106]: missing lifetime specifier +error[E0637]: `'_` cannot be used here --> $DIR/assoc-type.rs:16:20 | LL | type Output = &'_ i32; - | ^^ expected named lifetime parameter - | -help: consider introducing a named lifetime parameter - | -LL | type Output<'a> = &'a i32; - | ++++ ~~ + | ^^ `'_` is a reserved lifetime name error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0106`. +For more information about this error, try `rustc --explain E0637`. diff --git a/src/test/ui/issues/issue-13497.stderr b/src/test/ui/issues/issue-13497.stderr index 6521a67428e..4b1d979da36 100644 --- a/src/test/ui/issues/issue-13497.stderr +++ b/src/test/ui/issues/issue-13497.stderr @@ -8,7 +8,7 @@ LL | &str help: consider using the `'static` lifetime | LL | &'static str - | ~~~~~~~~ + | +++++++ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-19707.stderr b/src/test/ui/issues/issue-19707.stderr index 18f69bb5775..3e1bb32c19b 100644 --- a/src/test/ui/issues/issue-19707.stderr +++ b/src/test/ui/issues/issue-19707.stderr @@ -22,7 +22,6 @@ LL | fn bar<F: Fn(&u8, &u8) -> &u8>(f: &F) {} | --- --- ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from argument 1 or argument 2 - = 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 bar<F: for<'a> Fn(&'a u8, &'a u8) -> &'a u8>(f: &F) {} diff --git a/src/test/ui/issues/issue-30255.stderr b/src/test/ui/issues/issue-30255.stderr index e5f492af5b3..adb721a1cba 100644 --- a/src/test/ui/issues/issue-30255.stderr +++ b/src/test/ui/issues/issue-30255.stderr @@ -7,8 +7,8 @@ LL | fn f(a: &S, b: i32) -> &i32 { = help: this function's return type contains a borrowed value, but the signature does not say which one of `a`'s 2 lifetimes it is borrowed from help: consider introducing a named lifetime parameter | -LL | fn f<'a>(a: &'a S, b: i32) -> &'a i32 { - | ++++ ++ ++ +LL | fn f<'a>(a: &'a S<'a>, b: i32) -> &'a i32 { + | ++++ ++ ++++ ++ error[E0106]: missing lifetime specifier --> $DIR/issue-30255.rs:14:34 @@ -19,8 +19,8 @@ LL | fn g(a: &S, b: bool, c: &i32) -> &i32 { = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from one of `a`'s 2 lifetimes or `c` help: consider introducing a named lifetime parameter | -LL | fn g<'a>(a: &'a S, b: bool, c: &'a i32) -> &'a i32 { - | ++++ ++ ++ ++ +LL | fn g<'a>(a: &'a S<'a>, b: bool, c: &'a i32) -> &'a i32 { + | ++++ ++ ++++ ++ ++ error[E0106]: missing lifetime specifier --> $DIR/issue-30255.rs:19:44 @@ -31,8 +31,8 @@ LL | fn h(a: &bool, b: bool, c: &S, d: &i32) -> &i32 { = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `a`, one of `c`'s 2 lifetimes, or `d` help: consider introducing a named lifetime parameter | -LL | fn h<'a>(a: &'a bool, b: bool, c: &'a S, d: &'a i32) -> &'a i32 { - | ++++ ++ ++ ++ ++ +LL | fn h<'a>(a: &'a bool, b: bool, c: &'a S<'a>, d: &'a i32) -> &'a i32 { + | ++++ ++ ++ ++++ ++ ++ error: aborting due to 3 previous errors diff --git a/src/test/ui/lifetimes/issue-26638.rs b/src/test/ui/lifetimes/issue-26638.rs index 72fe4286a06..000ab6492bb 100644 --- a/src/test/ui/lifetimes/issue-26638.rs +++ b/src/test/ui/lifetimes/issue-26638.rs @@ -1,8 +1,11 @@ fn parse_type(iter: Box<dyn Iterator<Item=&str>+'static>) -> &str { iter.next() } //~^ ERROR missing lifetime specifier [E0106] +//~| ERROR mismatched types fn parse_type_2(iter: fn(&u8)->&u8) -> &str { iter() } //~^ ERROR missing lifetime specifier [E0106] +//~| ERROR mismatched types +//~| ERROR this function takes 1 argument but 0 arguments were supplied fn parse_type_3() -> &str { unimplemented!() } //~^ ERROR missing lifetime specifier [E0106] diff --git a/src/test/ui/lifetimes/issue-26638.stderr b/src/test/ui/lifetimes/issue-26638.stderr index bb7cdcbb100..f3af5cf5a35 100644 --- a/src/test/ui/lifetimes/issue-26638.stderr +++ b/src/test/ui/lifetimes/issue-26638.stderr @@ -7,23 +7,23 @@ LL | fn parse_type(iter: Box<dyn Iterator<Item=&str>+'static>) -> &str { iter.ne = help: this function's return type contains a borrowed value, but the signature does not say which one of `iter`'s 2 lifetimes it is borrowed from help: consider introducing a named lifetime parameter | -LL | fn parse_type<'a>(iter: Box<dyn Iterator<Item=&str>+'static>) -> &'a str { iter.next() } - | ++++ ++ +LL | fn parse_type<'a>(iter: Box<dyn Iterator<Item=&'a str>+'static>) -> &'a str { iter.next() } + | ++++ ++ ++ error[E0106]: missing lifetime specifier - --> $DIR/issue-26638.rs:4:40 + --> $DIR/issue-26638.rs:5:40 | LL | fn parse_type_2(iter: fn(&u8)->&u8) -> &str { iter() } | ^ expected named lifetime parameter | - = help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments + = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from help: consider using the `'static` lifetime | LL | fn parse_type_2(iter: fn(&u8)->&u8) -> &'static str { iter() } - | ~~~~~~~~ + | +++++++ error[E0106]: missing lifetime specifier - --> $DIR/issue-26638.rs:7:22 + --> $DIR/issue-26638.rs:10:22 | LL | fn parse_type_3() -> &str { unimplemented!() } | ^ expected named lifetime parameter @@ -32,8 +32,42 @@ LL | fn parse_type_3() -> &str { unimplemented!() } help: consider using the `'static` lifetime | LL | fn parse_type_3() -> &'static str { unimplemented!() } - | ~~~~~~~~ + | +++++++ + +error[E0308]: mismatched types + --> $DIR/issue-26638.rs:1:69 + | +LL | fn parse_type(iter: Box<dyn Iterator<Item=&str>+'static>) -> &str { iter.next() } + | ---- ^^^^^^^^^^^ expected `&str`, found enum `Option` + | | + | expected `&'static str` because of return type + | + = note: expected reference `&'static str` + found enum `Option<&str>` + +error[E0061]: this function takes 1 argument but 0 arguments were supplied + --> $DIR/issue-26638.rs:5:47 + | +LL | fn parse_type_2(iter: fn(&u8)->&u8) -> &str { iter() } + | ^^^^-- an argument of type `&u8` is missing + | +help: provide the argument + | +LL | fn parse_type_2(iter: fn(&u8)->&u8) -> &str { iter(/* &u8 */) } + | ~~~~~~~~~~~~~~~ + +error[E0308]: mismatched types + --> $DIR/issue-26638.rs:5:47 + | +LL | fn parse_type_2(iter: fn(&u8)->&u8) -> &str { iter() } + | ---- ^^^^^^ expected `str`, found `u8` + | | + | expected `&'static str` because of return type + | + = note: expected reference `&'static str` + found reference `&u8` -error: aborting due to 3 previous errors +error: aborting due to 6 previous errors -For more information about this error, try `rustc --explain E0106`. +Some errors have detailed explanations: E0061, E0106, E0308. +For more information about an error, try `rustc --explain E0061`. diff --git a/src/test/ui/lifetimes/lifetime-elision-return-type-requires-explicit-lifetime.stderr b/src/test/ui/lifetimes/lifetime-elision-return-type-requires-explicit-lifetime.stderr index 0e69cd50f6a..d0775487955 100644 --- a/src/test/ui/lifetimes/lifetime-elision-return-type-requires-explicit-lifetime.stderr +++ b/src/test/ui/lifetimes/lifetime-elision-return-type-requires-explicit-lifetime.stderr @@ -8,7 +8,7 @@ LL | fn f() -> &isize { help: consider using the `'static` lifetime | LL | fn f() -> &'static isize { - | ~~~~~~~~ + | +++++++ error[E0106]: missing lifetime specifier --> $DIR/lifetime-elision-return-type-requires-explicit-lifetime.rs:7:33 @@ -31,8 +31,8 @@ LL | fn h(_x: &Foo) -> &isize { = help: this function's return type contains a borrowed value, but the signature does not say which one of `_x`'s 2 lifetimes it is borrowed from help: consider introducing a named lifetime parameter | -LL | fn h<'a>(_x: &'a Foo) -> &'a isize { - | ++++ ++ ++ +LL | fn h<'a>(_x: &'a Foo<'a>) -> &'a isize { + | ++++ ++ ++++ ++ error[E0106]: missing lifetime specifier --> $DIR/lifetime-elision-return-type-requires-explicit-lifetime.rs:21:20 @@ -40,11 +40,11 @@ error[E0106]: missing lifetime specifier LL | fn i(_x: isize) -> &isize { | ^ expected named lifetime parameter | - = help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments + = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from help: consider using the `'static` lifetime | LL | fn i(_x: isize) -> &'static isize { - | ~~~~~~~~ + | +++++++ error[E0106]: missing lifetime specifier --> $DIR/lifetime-elision-return-type-requires-explicit-lifetime.rs:34:24 @@ -52,11 +52,11 @@ error[E0106]: missing lifetime specifier LL | fn j(_x: StaticStr) -> &isize { | ^ expected named lifetime parameter | - = help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments + = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from help: consider using the `'static` lifetime | LL | fn j(_x: StaticStr) -> &'static isize { - | ~~~~~~~~ + | +++++++ error[E0106]: missing lifetime specifier --> $DIR/lifetime-elision-return-type-requires-explicit-lifetime.rs:40:49 @@ -64,11 +64,11 @@ error[E0106]: missing lifetime specifier LL | fn k<'a, T: WithLifetime<'a>>(_x: T::Output) -> &isize { | ^ expected named lifetime parameter | - = help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments + = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from help: consider using the `'a` lifetime | LL | fn k<'a, T: WithLifetime<'a>>(_x: T::Output) -> &'a isize { - | ~~~ + | ++ error: aborting due to 6 previous errors diff --git a/src/test/ui/lifetimes/lifetime-errors/ex1b-return-no-names-if-else.rs b/src/test/ui/lifetimes/lifetime-errors/ex1b-return-no-names-if-else.rs index d1263a4acb2..d6c918843c7 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex1b-return-no-names-if-else.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex1b-return-no-names-if-else.rs @@ -2,4 +2,4 @@ fn foo(x: &i32, y: &i32) -> &i32 { //~ ERROR missing lifetime if x > y { x } else { y } } -fn main() { } +fn main() {} diff --git a/src/test/ui/lifetimes/missing-lifetime-in-alias.stderr b/src/test/ui/lifetimes/missing-lifetime-in-alias.stderr index b16b792aefe..b8c68a4607d 100644 --- a/src/test/ui/lifetimes/missing-lifetime-in-alias.stderr +++ b/src/test/ui/lifetimes/missing-lifetime-in-alias.stderr @@ -7,7 +7,7 @@ LL | type B<'a> = <A<'a> as Trait>::Foo; help: consider using the `'a` lifetime | LL | type B<'a> = <A<'a> as Trait<'a>>::Foo; - | ~~~~~~~~~ + | ++++ error[E0106]: missing lifetime specifier --> $DIR/missing-lifetime-in-alias.rs:26:28 @@ -20,6 +20,10 @@ note: these named lifetimes are available to use | LL | type C<'a, 'b> = <A<'a> as Trait>::Bar; | ^^ ^^ +help: consider using one of the available lifetimes here + | +LL | type C<'a, 'b> = <A<'a> as Trait<'lifetime>>::Bar; + | +++++++++++ error[E0107]: missing generics for associated type `Trait::Bar` --> $DIR/missing-lifetime-in-alias.rs:26:36 diff --git a/src/test/ui/mismatched_types/issue-74918-missing-lifetime.rs b/src/test/ui/mismatched_types/issue-74918-missing-lifetime.rs index 6aa34354a7a..c7842667dc6 100644 --- a/src/test/ui/mismatched_types/issue-74918-missing-lifetime.rs +++ b/src/test/ui/mismatched_types/issue-74918-missing-lifetime.rs @@ -9,6 +9,7 @@ impl<T, S: Iterator<Item = T>> Iterator for ChunkingIterator<T, S> { type Item = IteratorChunk<T, S>; //~ ERROR missing lifetime fn next(&mut self) -> Option<IteratorChunk<T, S>> { + //~^ ERROR `impl` item signature doesn't match `trait` item signature todo!() } } diff --git a/src/test/ui/mismatched_types/issue-74918-missing-lifetime.stderr b/src/test/ui/mismatched_types/issue-74918-missing-lifetime.stderr index c7e1f87f2d4..94a9c97576f 100644 --- a/src/test/ui/mismatched_types/issue-74918-missing-lifetime.stderr +++ b/src/test/ui/mismatched_types/issue-74918-missing-lifetime.stderr @@ -1,14 +1,30 @@ error[E0106]: missing lifetime specifier - --> $DIR/issue-74918-missing-lifetime.rs:9:31 + --> $DIR/issue-74918-missing-lifetime.rs:9:30 | LL | type Item = IteratorChunk<T, S>; - | ^ expected named lifetime parameter + | ^ expected named lifetime parameter | help: consider introducing a named lifetime parameter | LL | type Item<'a> = IteratorChunk<'a, T, S>; | ++++ +++ -error: aborting due to previous error +error: `impl` item signature doesn't match `trait` item signature + --> $DIR/issue-74918-missing-lifetime.rs:11:5 + | +LL | fn next(&mut self) -> Option<IteratorChunk<T, S>> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 mut ChunkingIterator<T, S>) -> Option<IteratorChunk<'1, T, S>>` + | + ::: $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL + | +LL | fn next(&mut self) -> Option<Self::Item>; + | ----------------------------------------- expected `fn(&'1 mut ChunkingIterator<T, S>) -> Option<IteratorChunk<'static, T, S>>` + | + = note: expected `fn(&'1 mut ChunkingIterator<T, S>) -> Option<IteratorChunk<'static, T, S>>` + found `fn(&'1 mut ChunkingIterator<T, S>) -> Option<IteratorChunk<'1, T, S>>` + = help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait` + = help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/resolve/issue-69401-trait-fn-no-body-ty-local.rs b/src/test/ui/resolve/issue-69401-trait-fn-no-body-ty-local.rs index 4397baea4a9..c377ecea94d 100644 --- a/src/test/ui/resolve/issue-69401-trait-fn-no-body-ty-local.rs +++ b/src/test/ui/resolve/issue-69401-trait-fn-no-body-ty-local.rs @@ -2,5 +2,5 @@ fn main() {} trait Foo { fn fn_with_type_named_same_as_local_in_param(b: b); - //~^ ERROR cannot find type `b` in this scope + //~^ ERROR cannot find type `b` in this scope [E0412] } diff --git a/src/test/ui/rfc1623-2.rs b/src/test/ui/rfc1623-2.rs index 35a2ef10c2e..26fa6fdb57f 100644 --- a/src/test/ui/rfc1623-2.rs +++ b/src/test/ui/rfc1623-2.rs @@ -9,5 +9,6 @@ static NON_ELIDABLE_FN: &fn(&u8, &u8) -> &u8 = //~^ ERROR missing lifetime specifier [E0106] &(non_elidable as fn(&u8, &u8) -> &u8); //~^ ERROR missing lifetime specifier [E0106] + //~| ERROR non-primitive cast fn main() {} diff --git a/src/test/ui/rfc1623-2.stderr b/src/test/ui/rfc1623-2.stderr index 65b9f68817a..495d45e2234 100644 --- a/src/test/ui/rfc1623-2.stderr +++ b/src/test/ui/rfc1623-2.stderr @@ -18,12 +18,18 @@ LL | &(non_elidable as fn(&u8, &u8) -> &u8); | --- --- ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from argument 1 or argument 2 - = 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 | &(non_elidable as for<'a> fn(&'a u8, &'a u8) -> &'a u8); | +++++++ ++ ++ ++ -error: aborting due to 2 previous errors +error[E0605]: non-primitive cast: `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8 {non_elidable}` as `for<'r, 's> fn(&'r u8, &'s u8) -> &u8` + --> $DIR/rfc1623-2.rs:10:6 + | +LL | &(non_elidable as fn(&u8, &u8) -> &u8); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid cast + +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0106`. +Some errors have detailed explanations: E0106, E0605. +For more information about an error, try `rustc --explain E0106`. 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 a761ec59167..6d7c3d73097 100644 --- a/src/test/ui/suggestions/fn-missing-lifetime-in-item.stderr +++ b/src/test/ui/suggestions/fn-missing-lifetime-in-item.stderr @@ -21,7 +21,6 @@ LL | struct S2<F: Fn(&i32, &i32) -> &i32>(F); | ---- ---- ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from argument 1 or argument 2 - = 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 | struct S2<F: for<'a> Fn(&'a i32, &'a i32) -> &'a i32>(F); diff --git a/src/test/ui/suggestions/impl-trait-missing-lifetime-gated.stderr b/src/test/ui/suggestions/impl-trait-missing-lifetime-gated.stderr index 9adc9679eee..e82a6f769e0 100644 --- a/src/test/ui/suggestions/impl-trait-missing-lifetime-gated.stderr +++ b/src/test/ui/suggestions/impl-trait-missing-lifetime-gated.stderr @@ -1,43 +1,43 @@ -error[E0658]: anonymous lifetimes in `impl Trait` are unstable - --> $DIR/impl-trait-missing-lifetime-gated.rs:5:31 - | -LL | fn f(_: impl Iterator<Item = &'_ ()>) {} - | ^^ - | - = help: add `#![feature(anonymous_lifetime_in_impl_trait)]` to the crate attributes to enable - error[E0106]: missing lifetime specifier --> $DIR/impl-trait-missing-lifetime-gated.rs:8:50 | LL | fn g(x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() } | ^^ expected named lifetime parameter | - = help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments + = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from help: consider using the `'static` lifetime | LL | fn g(x: impl Iterator<Item = &'_ ()>) -> Option<&'static ()> { x.next() } | ~~~~~~~ -error[E0658]: anonymous lifetimes in `impl Trait` are unstable - --> $DIR/impl-trait-missing-lifetime-gated.rs:8:31 - | -LL | fn g(x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() } - | ^^ - | - = help: add `#![feature(anonymous_lifetime_in_impl_trait)]` to the crate attributes to enable - error[E0106]: missing lifetime specifier --> $DIR/impl-trait-missing-lifetime-gated.rs:18:56 | LL | async fn i(x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() } | ^^ expected named lifetime parameter | - = help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments + = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from help: consider using the `'static` lifetime | LL | async fn i(x: impl Iterator<Item = &'_ ()>) -> Option<&'static ()> { x.next() } | ~~~~~~~ +error[E0658]: anonymous lifetimes in `impl Trait` are unstable + --> $DIR/impl-trait-missing-lifetime-gated.rs:5:31 + | +LL | fn f(_: impl Iterator<Item = &'_ ()>) {} + | ^^ + | + = help: add `#![feature(anonymous_lifetime_in_impl_trait)]` to the crate attributes to enable + +error[E0658]: anonymous lifetimes in `impl Trait` are unstable + --> $DIR/impl-trait-missing-lifetime-gated.rs:8:31 + | +LL | fn g(x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() } + | ^^ + | + = help: add `#![feature(anonymous_lifetime_in_impl_trait)]` to the crate attributes to enable + error: aborting due to 4 previous errors Some errors have detailed explanations: E0106, E0658. diff --git a/src/test/ui/suggestions/impl-trait-missing-lifetime.rs b/src/test/ui/suggestions/impl-trait-missing-lifetime.rs index dcc716f56b7..6f7c912d707 100644 --- a/src/test/ui/suggestions/impl-trait-missing-lifetime.rs +++ b/src/test/ui/suggestions/impl-trait-missing-lifetime.rs @@ -6,14 +6,15 @@ fn f(_: impl Iterator<Item = &'_ ()>) {} // But that lifetime does not participate in resolution. -fn g(x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() } +fn g(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() } //~^ ERROR missing lifetime specifier // This is understood as `fn foo<'_1>(_: impl Iterator<Item = &'_1 ()>) {}`. async fn h(_: impl Iterator<Item = &'_ ()>) {} // But that lifetime does not participate in resolution. -async fn i(x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() } +async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() } //~^ ERROR missing lifetime specifier +//~| ERROR lifetime may not live long enough fn main() {} diff --git a/src/test/ui/suggestions/impl-trait-missing-lifetime.stderr b/src/test/ui/suggestions/impl-trait-missing-lifetime.stderr index d3c64cb466d..b476d61017f 100644 --- a/src/test/ui/suggestions/impl-trait-missing-lifetime.stderr +++ b/src/test/ui/suggestions/impl-trait-missing-lifetime.stderr @@ -1,27 +1,35 @@ error[E0106]: missing lifetime specifier - --> $DIR/impl-trait-missing-lifetime.rs:9:50 + --> $DIR/impl-trait-missing-lifetime.rs:9:54 | -LL | fn g(x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() } - | ^^ expected named lifetime parameter +LL | fn g(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() } + | ^^ expected named lifetime parameter | - = help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments + = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from help: consider using the `'static` lifetime | -LL | fn g(x: impl Iterator<Item = &'_ ()>) -> Option<&'static ()> { x.next() } - | ~~~~~~~ +LL | fn g(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'static ()> { x.next() } + | ~~~~~~~ error[E0106]: missing lifetime specifier - --> $DIR/impl-trait-missing-lifetime.rs:16:56 + --> $DIR/impl-trait-missing-lifetime.rs:16:60 | -LL | async fn i(x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() } - | ^^ expected named lifetime parameter +LL | async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() } + | ^^ expected named lifetime parameter | - = help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments + = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from help: consider using the `'static` lifetime | -LL | async fn i(x: impl Iterator<Item = &'_ ()>) -> Option<&'static ()> { x.next() } - | ~~~~~~~ +LL | async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'static ()> { x.next() } + | ~~~~~~~ -error: aborting due to 2 previous errors +error: lifetime may not live long enough + --> $DIR/impl-trait-missing-lifetime.rs:16:69 + | +LL | async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() } + | -------------- ^^^^^^^^ returning this value requires that `'1` must outlive `'static` + | | + | return type `impl Future<Output = Option<&'static ()>>` contains a lifetime `'1` + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/suggestions/issue-86667.rs b/src/test/ui/suggestions/issue-86667.rs index 6aceb137469..366787df1b4 100644 --- a/src/test/ui/suggestions/issue-86667.rs +++ b/src/test/ui/suggestions/issue-86667.rs @@ -6,6 +6,7 @@ async fn a(s1: &str, s2: &str) -> &str { //~^ ERROR: missing lifetime specifier [E0106] s1 +//~^ ERROR: lifetime may not live long enough } fn b(s1: &str, s2: &str) -> &str { diff --git a/src/test/ui/suggestions/issue-86667.stderr b/src/test/ui/suggestions/issue-86667.stderr index 14dbbfffb0e..8d611641626 100644 --- a/src/test/ui/suggestions/issue-86667.stderr +++ b/src/test/ui/suggestions/issue-86667.stderr @@ -11,7 +11,7 @@ LL | async fn a<'a>(s1: &'a str, s2: &'a str) -> &'a str { | ++++ ++ ++ ++ error[E0106]: missing lifetime specifier - --> $DIR/issue-86667.rs:11:29 + --> $DIR/issue-86667.rs:12:29 | LL | fn b(s1: &str, s2: &str) -> &str { | ---- ---- ^ expected named lifetime parameter @@ -22,6 +22,15 @@ help: consider introducing a named lifetime parameter LL | fn b<'a>(s1: &'a str, s2: &'a str) -> &'a str { | ++++ ++ ++ ++ -error: aborting due to 2 previous errors +error: lifetime may not live long enough + --> $DIR/issue-86667.rs:8:5 + | +LL | async fn a(s1: &str, s2: &str) -> &str { + | - let's call the lifetime of this reference `'1` +LL | +LL | s1 + | ^^ returning this value requires that `'1` must outlive `'static` + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/suggestions/missing-lifetime-in-assoc-const-type.stderr b/src/test/ui/suggestions/missing-lifetime-in-assoc-const-type.stderr index 1ecaade93c8..233f1bc5a86 100644 --- a/src/test/ui/suggestions/missing-lifetime-in-assoc-const-type.stderr +++ b/src/test/ui/suggestions/missing-lifetime-in-assoc-const-type.stderr @@ -4,10 +4,6 @@ error[E0106]: missing lifetime specifier LL | const A: &str = ""; | ^ expected named lifetime parameter | -help: consider using the `'static` lifetime - | -LL | const A: &'static str = ""; - | +++++++ help: consider introducing a named lifetime parameter | LL ~ trait ZstAssert<'a>: Sized { @@ -20,10 +16,6 @@ error[E0106]: missing lifetime specifier LL | const B: S = S { s: &() }; | ^ expected named lifetime parameter | -help: consider using the `'static` lifetime - | -LL | const B: S<'static> = S { s: &() }; - | +++++++++ help: consider introducing a named lifetime parameter | LL ~ trait ZstAssert<'a>: Sized { @@ -37,10 +29,6 @@ error[E0106]: missing lifetime specifier LL | const C: &'_ str = ""; | ^^ expected named lifetime parameter | -help: consider using the `'static` lifetime - | -LL | const C: &'static str = ""; - | ~~~~~~~ help: consider introducing a named lifetime parameter | LL ~ trait ZstAssert<'a>: Sized { @@ -55,10 +43,6 @@ error[E0106]: missing lifetime specifiers LL | const D: T = T { a: &(), b: &() }; | ^ expected 2 lifetime parameters | -help: consider using the `'static` lifetime - | -LL | const D: T<'static, 'static> = T { a: &(), b: &() }; - | ++++++++++++++++++ help: consider introducing a named lifetime parameter | LL ~ trait ZstAssert<'a>: Sized { diff --git a/src/test/ui/suggestions/missing-lifetime-specifier.rs b/src/test/ui/suggestions/missing-lifetime-specifier.rs index ce847c86bed..24f5f782f35 100644 --- a/src/test/ui/suggestions/missing-lifetime-specifier.rs +++ b/src/test/ui/suggestions/missing-lifetime-specifier.rs @@ -21,22 +21,18 @@ thread_local! { } thread_local! { static b: RefCell<HashMap<i32, Vec<Vec<&Bar>>>> = RefCell::new(HashMap::new()); - //~^ ERROR missing lifetime specifier - //~| ERROR missing lifetime specifier - //~| ERROR missing lifetime specifier - //~| ERROR missing lifetime specifier + //~^ ERROR missing lifetime specifiers + //~| ERROR missing lifetime specifiers } thread_local! { static c: RefCell<HashMap<i32, Vec<Vec<Qux<i32>>>>> = RefCell::new(HashMap::new()); - //~^ ERROR missing lifetime - //~| ERROR missing lifetime + //~^ ERROR missing lifetime specifiers + //~| ERROR missing lifetime specifiers } thread_local! { static d: RefCell<HashMap<i32, Vec<Vec<&Tar<i32>>>>> = RefCell::new(HashMap::new()); - //~^ ERROR missing lifetime - //~| ERROR missing lifetime - //~| ERROR missing lifetime - //~| ERROR missing lifetime + //~^ ERROR missing lifetime specifiers + //~| ERROR missing lifetime specifiers } thread_local! { diff --git a/src/test/ui/suggestions/missing-lifetime-specifier.stderr b/src/test/ui/suggestions/missing-lifetime-specifier.stderr index 1498337549d..10fb28c1891 100644 --- a/src/test/ui/suggestions/missing-lifetime-specifier.stderr +++ b/src/test/ui/suggestions/missing-lifetime-specifier.stderr @@ -8,7 +8,7 @@ LL | static a: RefCell<HashMap<i32, Vec<Vec<Foo>>>> = RefCell::new(HashMap:: help: consider using the `'static` lifetime | LL | static a: RefCell<HashMap<i32, Vec<Vec<Foo<'static, 'static>>>>> = RefCell::new(HashMap::new()); - | ~~~~~~~~~~~~~~~~~~~~~ + | ++++++++++++++++++ error[E0106]: missing lifetime specifiers --> $DIR/missing-lifetime-specifier.rs:18:44 @@ -23,38 +23,28 @@ LL | | } | = help: this function's return type contains a borrowed value, but the signature does not say which one of `init`'s 3 lifetimes it is borrowed from -error[E0106]: missing lifetime specifier +error[E0106]: missing lifetime specifiers --> $DIR/missing-lifetime-specifier.rs:23:44 | LL | static b: RefCell<HashMap<i32, Vec<Vec<&Bar>>>> = RefCell::new(HashMap::new()); - | ^ expected named lifetime parameter + | ^^^^ expected 2 lifetime parameters + | | + | expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from help: consider using the `'static` lifetime | -LL | static b: RefCell<HashMap<i32, Vec<Vec<&'static Bar>>>> = RefCell::new(HashMap::new()); - | ~~~~~~~~ +LL | static b: RefCell<HashMap<i32, Vec<Vec<&'static Bar<'static, 'static>>>>> = RefCell::new(HashMap::new()); + | +++++++ ++++++++++++++++++ error[E0106]: missing lifetime specifiers - --> $DIR/missing-lifetime-specifier.rs:23:45 - | -LL | static b: RefCell<HashMap<i32, Vec<Vec<&Bar>>>> = RefCell::new(HashMap::new()); - | ^^^ expected 2 lifetime parameters - | - = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime - | -LL | static b: RefCell<HashMap<i32, Vec<Vec<&Bar<'static, 'static>>>>> = RefCell::new(HashMap::new()); - | ~~~~~~~~~~~~~~~~~~~~~ - -error[E0106]: missing lifetime specifier --> $DIR/missing-lifetime-specifier.rs:23:44 | LL | / thread_local! { LL | | static b: RefCell<HashMap<i32, Vec<Vec<&Bar>>>> = RefCell::new(HashMap::new()); - | | ^ expected named lifetime parameter -LL | | -LL | | + | | ^^^^ expected 2 lifetime parameters + | | | + | | expected named lifetime parameter LL | | LL | | LL | | } @@ -63,25 +53,10 @@ LL | | } = help: this function's return type contains a borrowed value, but the signature does not say which one of `init`'s 4 lifetimes it is borrowed from error[E0106]: missing lifetime specifiers - --> $DIR/missing-lifetime-specifier.rs:23:45 - | -LL | / thread_local! { -LL | | static b: RefCell<HashMap<i32, Vec<Vec<&Bar>>>> = RefCell::new(HashMap::new()); - | | ^^^ expected 2 lifetime parameters -LL | | -LL | | -LL | | -LL | | -LL | | } - | |_- - | - = help: this function's return type contains a borrowed value, but the signature does not say which one of `init`'s 4 lifetimes it is borrowed from - -error[E0106]: missing lifetime specifiers - --> $DIR/missing-lifetime-specifier.rs:30:48 + --> $DIR/missing-lifetime-specifier.rs:28:47 | LL | static c: RefCell<HashMap<i32, Vec<Vec<Qux<i32>>>>> = RefCell::new(HashMap::new()); - | ^ expected 2 lifetime parameters + | ^ expected 2 lifetime parameters | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from help: consider using the `'static` lifetime @@ -90,11 +65,11 @@ LL | static c: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'static, i32>>>>> = | +++++++++++++++++ error[E0106]: missing lifetime specifiers - --> $DIR/missing-lifetime-specifier.rs:30:48 + --> $DIR/missing-lifetime-specifier.rs:28:47 | LL | / thread_local! { LL | | static c: RefCell<HashMap<i32, Vec<Vec<Qux<i32>>>>> = RefCell::new(HashMap::new()); - | | ^ expected 2 lifetime parameters + | | ^ expected 2 lifetime parameters LL | | LL | | LL | | } @@ -102,38 +77,28 @@ LL | | } | = help: this function's return type contains a borrowed value, but the signature does not say which one of `init`'s 3 lifetimes it is borrowed from -error[E0106]: missing lifetime specifier - --> $DIR/missing-lifetime-specifier.rs:35:44 - | -LL | static d: RefCell<HashMap<i32, Vec<Vec<&Tar<i32>>>>> = RefCell::new(HashMap::new()); - | ^ expected named lifetime parameter - | - = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime - | -LL | static d: RefCell<HashMap<i32, Vec<Vec<&'static Tar<i32>>>>> = RefCell::new(HashMap::new()); - | ~~~~~~~~ - error[E0106]: missing lifetime specifiers - --> $DIR/missing-lifetime-specifier.rs:35:49 + --> $DIR/missing-lifetime-specifier.rs:33:44 | LL | static d: RefCell<HashMap<i32, Vec<Vec<&Tar<i32>>>>> = RefCell::new(HashMap::new()); - | ^ expected 2 lifetime parameters + | ^ ^ expected 2 lifetime parameters + | | + | expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from help: consider using the `'static` lifetime | -LL | static d: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, 'static, i32>>>>> = RefCell::new(HashMap::new()); - | +++++++++++++++++ +LL | static d: RefCell<HashMap<i32, Vec<Vec<&'static Tar<'static, 'static, i32>>>>> = RefCell::new(HashMap::new()); + | +++++++ +++++++++++++++++ -error[E0106]: missing lifetime specifier - --> $DIR/missing-lifetime-specifier.rs:35:44 +error[E0106]: missing lifetime specifiers + --> $DIR/missing-lifetime-specifier.rs:33:44 | LL | / thread_local! { LL | | static d: RefCell<HashMap<i32, Vec<Vec<&Tar<i32>>>>> = RefCell::new(HashMap::new()); - | | ^ expected named lifetime parameter -LL | | -LL | | + | | ^ ^ expected 2 lifetime parameters + | | | + | | expected named lifetime parameter LL | | LL | | LL | | } @@ -141,23 +106,35 @@ LL | | } | = help: this function's return type contains a borrowed value, but the signature does not say which one of `init`'s 4 lifetimes it is borrowed from -error[E0106]: missing lifetime specifiers - --> $DIR/missing-lifetime-specifier.rs:35:49 +error[E0106]: missing lifetime specifier + --> $DIR/missing-lifetime-specifier.rs:47:44 + | +LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new()); + | ^ expected named lifetime parameter + | + = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from +help: consider using the `'static` lifetime + | +LL | static f: RefCell<HashMap<i32, Vec<Vec<&'static Tar<'static, i32>>>>> = RefCell::new(HashMap::new()); + | +++++++ + +error[E0106]: missing lifetime specifier + --> $DIR/missing-lifetime-specifier.rs:47:44 | LL | / thread_local! { -LL | | static d: RefCell<HashMap<i32, Vec<Vec<&Tar<i32>>>>> = RefCell::new(HashMap::new()); - | | ^ expected 2 lifetime parameters -LL | | +LL | | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new()); + | | ^ expected named lifetime parameter LL | | LL | | +... | LL | | LL | | } | |_- | - = help: this function's return type contains a borrowed value, but the signature does not say which one of `init`'s 4 lifetimes it is borrowed from + = help: this function's return type contains a borrowed value, but the signature does not say which one of `init`'s 3 lifetimes it is borrowed from error[E0107]: this union takes 2 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/missing-lifetime-specifier.rs:43:44 + --> $DIR/missing-lifetime-specifier.rs:39:44 | LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, i32>>>>> = RefCell::new(HashMap::new()); | ^^^ ------- supplied 1 lifetime argument @@ -175,7 +152,7 @@ LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'static, i32>>>>> = | +++++++++ error[E0107]: this union takes 2 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/missing-lifetime-specifier.rs:43:44 + --> $DIR/missing-lifetime-specifier.rs:39:44 | LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, i32>>>>> = RefCell::new(HashMap::new()); | ^^^ ------- supplied 1 lifetime argument @@ -193,7 +170,7 @@ LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'k, i32>>>>> = RefC | ++++ error[E0107]: this union takes 2 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/missing-lifetime-specifier.rs:43:44 + --> $DIR/missing-lifetime-specifier.rs:39:44 | LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, i32>>>>> = RefCell::new(HashMap::new()); | ^^^ ------- supplied 1 lifetime argument @@ -211,7 +188,7 @@ LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'k, i32>>>>> = RefC | ++++ error[E0107]: this union takes 2 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/missing-lifetime-specifier.rs:43:44 + --> $DIR/missing-lifetime-specifier.rs:39:44 | LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, i32>>>>> = RefCell::new(HashMap::new()); | ^^^ ------- supplied 1 lifetime argument @@ -229,7 +206,7 @@ LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'k, i32>>>>> = RefC | ++++ error[E0107]: this union takes 2 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/missing-lifetime-specifier.rs:43:44 + --> $DIR/missing-lifetime-specifier.rs:39:44 | LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, i32>>>>> = RefCell::new(HashMap::new()); | ^^^ ------- supplied 1 lifetime argument @@ -247,7 +224,7 @@ LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'static, i32>>>>> = | +++++++++ error[E0107]: this trait takes 2 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/missing-lifetime-specifier.rs:51:45 + --> $DIR/missing-lifetime-specifier.rs:47:45 | LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new()); | ^^^ ------- supplied 1 lifetime argument @@ -264,20 +241,8 @@ help: add missing lifetime argument LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, 'static, i32>>>>> = RefCell::new(HashMap::new()); | +++++++++ -error[E0106]: missing lifetime specifier - --> $DIR/missing-lifetime-specifier.rs:51:44 - | -LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new()); - | ^ expected named lifetime parameter - | - = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime - | -LL | static f: RefCell<HashMap<i32, Vec<Vec<&'static Tar<'static, i32>>>>> = RefCell::new(HashMap::new()); - | ~~~~~~~~ - error[E0107]: this trait takes 2 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/missing-lifetime-specifier.rs:51:45 + --> $DIR/missing-lifetime-specifier.rs:47:45 | LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new()); | ^^^ ------- supplied 1 lifetime argument @@ -294,23 +259,8 @@ help: add missing lifetime argument LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, 'k, i32>>>>> = RefCell::new(HashMap::new()); | ++++ -error[E0106]: missing lifetime specifier - --> $DIR/missing-lifetime-specifier.rs:51:44 - | -LL | / thread_local! { -LL | | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new()); - | | ^ expected named lifetime parameter -LL | | -LL | | -... | -LL | | -LL | | } - | |_- - | - = help: this function's return type contains a borrowed value, but the signature does not say which one of `init`'s 3 lifetimes it is borrowed from - error[E0107]: this trait takes 2 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/missing-lifetime-specifier.rs:51:45 + --> $DIR/missing-lifetime-specifier.rs:47:45 | LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new()); | ^^^ ------- supplied 1 lifetime argument @@ -328,7 +278,7 @@ LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, 'k, i32>>>>> = Ref | ++++ error[E0107]: this trait takes 2 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/missing-lifetime-specifier.rs:51:45 + --> $DIR/missing-lifetime-specifier.rs:47:45 | LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new()); | ^^^ ------- supplied 1 lifetime argument @@ -346,7 +296,7 @@ LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, 'k, i32>>>>> = Ref | ++++ error[E0107]: this trait takes 2 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/missing-lifetime-specifier.rs:51:45 + --> $DIR/missing-lifetime-specifier.rs:47:45 | LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new()); | ^^^ ------- supplied 1 lifetime argument @@ -363,7 +313,7 @@ help: add missing lifetime argument LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, 'static, i32>>>>> = RefCell::new(HashMap::new()); | +++++++++ -error: aborting due to 24 previous errors +error: aborting due to 20 previous errors Some errors have detailed explanations: E0106, E0107. For more information about an error, try `rustc --explain E0106`. diff --git a/src/test/ui/suggestions/missing-lt-for-hrtb.rs b/src/test/ui/suggestions/missing-lt-for-hrtb.rs index a90a90122ad..04ea3d831c9 100644 --- a/src/test/ui/suggestions/missing-lt-for-hrtb.rs +++ b/src/test/ui/suggestions/missing-lt-for-hrtb.rs @@ -1,10 +1,8 @@ struct X<'a>(&'a ()); struct S<'a>(&'a dyn Fn(&X) -> &X); -//~^ ERROR missing lifetime specifier -//~| ERROR missing lifetime specifier +//~^ ERROR missing lifetime specifiers struct V<'a>(&'a dyn for<'b> Fn(&X) -> &X); -//~^ ERROR missing lifetime specifier -//~| ERROR missing lifetime specifier +//~^ ERROR missing lifetime specifiers fn main() { let x = S(&|x| { diff --git a/src/test/ui/suggestions/missing-lt-for-hrtb.stderr b/src/test/ui/suggestions/missing-lt-for-hrtb.stderr index 33f9d092e6e..fa515644431 100644 --- a/src/test/ui/suggestions/missing-lt-for-hrtb.stderr +++ b/src/test/ui/suggestions/missing-lt-for-hrtb.stderr @@ -1,67 +1,36 @@ -error[E0106]: missing lifetime specifier +error[E0106]: missing lifetime specifiers --> $DIR/missing-lt-for-hrtb.rs:2:32 | LL | struct S<'a>(&'a dyn Fn(&X) -> &X); - | -- ^ expected named lifetime parameter + | -- ^^ expected named lifetime parameter + | | + | expected named lifetime parameter | = help: this function's return type contains a borrowed value, but the signature does not say which one of argument 1's 2 lifetimes it is borrowed from - = 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 | struct S<'a>(&'a dyn for<'b> Fn(&'b X) -> &'b X); - | +++++++ ~~~~~ ~~~ -help: consider using the `'a` lifetime - | -LL | struct S<'a>(&'a dyn Fn(&X) -> &'a X); - | ~~~ - -error[E0106]: missing lifetime specifier - --> $DIR/missing-lt-for-hrtb.rs:2:33 - | -LL | struct S<'a>(&'a dyn Fn(&X) -> &X); - | -- ^ expected named lifetime parameter - | - = help: this function's return type contains a borrowed value, but the signature does not say which one of argument 1's 2 lifetimes it is borrowed from - = 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 | struct S<'a>(&'a dyn for<'b> Fn(&'b X) -> &X<'b>); - | +++++++ ~~~~~ ~~~~~ help: consider using the `'a` lifetime | -LL | struct S<'a>(&'a dyn Fn(&X) -> &X<'a>); - | ~~~~~ +LL | struct S<'a>(&'a dyn Fn(&X) -> &'a X<'a>); + | ++ ++++ -error[E0106]: missing lifetime specifier - --> $DIR/missing-lt-for-hrtb.rs:5:40 +error[E0106]: missing lifetime specifiers + --> $DIR/missing-lt-for-hrtb.rs:4:40 | LL | struct V<'a>(&'a dyn for<'b> Fn(&X) -> &X); - | -- ^ expected named lifetime parameter + | -- ^^ expected named lifetime parameter + | | + | expected named lifetime parameter | = help: this function's return type contains a borrowed value, but the signature does not say which one of argument 1's 2 lifetimes it is borrowed from note: these named lifetimes are available to use - --> $DIR/missing-lt-for-hrtb.rs:5:10 + --> $DIR/missing-lt-for-hrtb.rs:4:10 | LL | struct V<'a>(&'a dyn for<'b> Fn(&X) -> &X); | ^^ ^^ help: consider using one of the available lifetimes here | -LL | struct V<'a>(&'a dyn for<'b> Fn(&X) -> &'lifetime X); - | +++++++++ - -error[E0106]: missing lifetime specifier - --> $DIR/missing-lt-for-hrtb.rs:5:41 - | -LL | struct V<'a>(&'a dyn for<'b> Fn(&X) -> &X); - | -- ^ expected named lifetime parameter - | - = help: this function's return type contains a borrowed value, but the signature does not say which one of argument 1's 2 lifetimes it is borrowed from -note: these named lifetimes are available to use - --> $DIR/missing-lt-for-hrtb.rs:5:10 - | -LL | struct V<'a>(&'a dyn for<'b> Fn(&X) -> &X); - | ^^ ^^ +LL | struct V<'a>(&'a dyn for<'b> Fn(&X) -> &'lifetime X<'lifetime>); + | +++++++++ +++++++++++ -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/suggestions/return-elided-lifetime.rs b/src/test/ui/suggestions/return-elided-lifetime.rs index ca336bbb056..012d5492a04 100644 --- a/src/test/ui/suggestions/return-elided-lifetime.rs +++ b/src/test/ui/suggestions/return-elided-lifetime.rs @@ -6,32 +6,27 @@ fn f1() -> &i32 { loop {} } //~^ ERROR missing lifetime specifier [E0106] fn f1_() -> (&i32, &i32) { loop {} } -//~^ ERROR missing lifetime specifier [E0106] -//~^^ ERROR missing lifetime specifier [E0106] +//~^ ERROR missing lifetime specifiers [E0106] fn f2(a: i32, b: i32) -> &i32 { loop {} } //~^ ERROR missing lifetime specifier [E0106] fn f2_(a: i32, b: i32) -> (&i32, &i32) { loop {} } -//~^ ERROR missing lifetime specifier [E0106] -//~^^ ERROR missing lifetime specifier [E0106] +//~^ ERROR missing lifetime specifiers [E0106] struct S<'a, 'b> { a: &'a i32, b: &'b i32 } fn f3(s: &S) -> &i32 { loop {} } //~^ ERROR missing lifetime specifier [E0106] fn f3_(s: &S, t: &S) -> (&i32, &i32) { loop {} } -//~^ ERROR missing lifetime specifier [E0106] -//~^^ ERROR missing lifetime specifier [E0106] +//~^ ERROR missing lifetime specifiers [E0106] fn f4<'a, 'b>(a: &'a i32, b: &'b i32) -> &i32 { loop {} } //~^ ERROR missing lifetime specifier [E0106] fn f4_<'a, 'b>(a: &'a i32, b: &'b i32) -> (&i32, &i32) { loop {} } -//~^ ERROR missing lifetime specifier [E0106] -//~^^ ERROR missing lifetime specifier [E0106] +//~^ ERROR missing lifetime specifiers [E0106] fn f5<'a>(a: &'a i32, b: &i32) -> &i32 { loop {} } //~^ ERROR missing lifetime specifier [E0106] fn f5_<'a>(a: &'a i32, b: &i32) -> (&i32, &i32) { loop {} } -//~^ ERROR missing lifetime specifier [E0106] -//~^^ ERROR missing lifetime specifier [E0106] +//~^ ERROR missing lifetime specifiers [E0106] fn main() {} diff --git a/src/test/ui/suggestions/return-elided-lifetime.stderr b/src/test/ui/suggestions/return-elided-lifetime.stderr index f147b4463e2..273d95bc747 100644 --- a/src/test/ui/suggestions/return-elided-lifetime.stderr +++ b/src/test/ui/suggestions/return-elided-lifetime.stderr @@ -8,70 +8,50 @@ LL | fn f1() -> &i32 { loop {} } help: consider using the `'static` lifetime | LL | fn f1() -> &'static i32 { loop {} } - | ~~~~~~~~ + | +++++++ -error[E0106]: missing lifetime specifier +error[E0106]: missing lifetime specifiers --> $DIR/return-elided-lifetime.rs:8:14 | LL | fn f1_() -> (&i32, &i32) { loop {} } - | ^ expected named lifetime parameter + | ^ ^ expected named lifetime parameter + | | + | expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from help: consider using the `'static` lifetime | -LL | fn f1_() -> (&'static i32, &i32) { loop {} } - | ~~~~~~~~ +LL | fn f1_() -> (&'static i32, &'static i32) { loop {} } + | +++++++ +++++++ error[E0106]: missing lifetime specifier - --> $DIR/return-elided-lifetime.rs:8:20 - | -LL | fn f1_() -> (&i32, &i32) { loop {} } - | ^ expected named lifetime parameter - | - = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime - | -LL | fn f1_() -> (&i32, &'static i32) { loop {} } - | ~~~~~~~~ - -error[E0106]: missing lifetime specifier - --> $DIR/return-elided-lifetime.rs:12:26 + --> $DIR/return-elided-lifetime.rs:11:26 | LL | fn f2(a: i32, b: i32) -> &i32 { loop {} } | ^ expected named lifetime parameter | - = help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments + = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from help: consider using the `'static` lifetime | LL | fn f2(a: i32, b: i32) -> &'static i32 { loop {} } - | ~~~~~~~~ + | +++++++ -error[E0106]: missing lifetime specifier - --> $DIR/return-elided-lifetime.rs:14:28 +error[E0106]: missing lifetime specifiers + --> $DIR/return-elided-lifetime.rs:13:28 | LL | fn f2_(a: i32, b: i32) -> (&i32, &i32) { loop {} } - | ^ expected named lifetime parameter - | - = help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments -help: consider using the `'static` lifetime + | ^ ^ expected named lifetime parameter + | | + | expected named lifetime parameter | -LL | fn f2_(a: i32, b: i32) -> (&'static i32, &i32) { loop {} } - | ~~~~~~~~ - -error[E0106]: missing lifetime specifier - --> $DIR/return-elided-lifetime.rs:14:34 - | -LL | fn f2_(a: i32, b: i32) -> (&i32, &i32) { loop {} } - | ^ expected named lifetime parameter - | - = help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments + = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from help: consider using the `'static` lifetime | -LL | fn f2_(a: i32, b: i32) -> (&i32, &'static i32) { loop {} } - | ~~~~~~~~ +LL | fn f2_(a: i32, b: i32) -> (&'static i32, &'static i32) { loop {} } + | +++++++ +++++++ error[E0106]: missing lifetime specifier - --> $DIR/return-elided-lifetime.rs:19:17 + --> $DIR/return-elided-lifetime.rs:17:17 | LL | fn f3(s: &S) -> &i32 { loop {} } | -- ^ expected named lifetime parameter @@ -79,42 +59,32 @@ LL | fn f3(s: &S) -> &i32 { loop {} } = help: this function's return type contains a borrowed value, but the signature does not say which one of `s`'s 3 lifetimes it is borrowed from help: consider introducing a named lifetime parameter | -LL | fn f3<'a>(s: &'a S) -> &'a i32 { loop {} } - | ++++ ++ ++ +LL | fn f3<'a>(s: &'a S<'a, 'a>) -> &'a i32 { loop {} } + | ++++ ++ ++++++++ ++ -error[E0106]: missing lifetime specifier - --> $DIR/return-elided-lifetime.rs:21:26 +error[E0106]: missing lifetime specifiers + --> $DIR/return-elided-lifetime.rs:19:26 | LL | fn f3_(s: &S, t: &S) -> (&i32, &i32) { loop {} } - | -- -- ^ expected named lifetime parameter + | -- -- ^ ^ expected named lifetime parameter + | | + | expected named lifetime parameter | = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from one of `s`'s 3 lifetimes or one of `t`'s 3 lifetimes help: consider introducing a named lifetime parameter | -LL | fn f3_<'a>(s: &'a S, t: &'a S) -> (&'a i32, &i32) { loop {} } - | ++++ ++ ++ ++ +LL | fn f3_<'a>(s: &'a S<'a, 'a>, t: &'a S<'a, 'a>) -> (&'a i32, &'a i32) { loop {} } + | ++++ ++ ++++++++ ++ ++++++++ ++ ++ error[E0106]: missing lifetime specifier - --> $DIR/return-elided-lifetime.rs:21:32 - | -LL | fn f3_(s: &S, t: &S) -> (&i32, &i32) { loop {} } - | -- -- ^ expected named lifetime parameter - | - = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from one of `s`'s 3 lifetimes or one of `t`'s 3 lifetimes -help: consider introducing a named lifetime parameter - | -LL | fn f3_<'a>(s: &'a S, t: &'a S) -> (&i32, &'a i32) { loop {} } - | ++++ ++ ++ ++ - -error[E0106]: missing lifetime specifier - --> $DIR/return-elided-lifetime.rs:25:42 + --> $DIR/return-elided-lifetime.rs:22:42 | LL | fn f4<'a, 'b>(a: &'a i32, b: &'b i32) -> &i32 { loop {} } | ------- ------- ^ expected named lifetime parameter | - = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `a` or `b` + = help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments note: these named lifetimes are available to use - --> $DIR/return-elided-lifetime.rs:25:7 + --> $DIR/return-elided-lifetime.rs:22:7 | LL | fn f4<'a, 'b>(a: &'a i32, b: &'b i32) -> &i32 { loop {} } | ^^ ^^ @@ -123,42 +93,27 @@ help: consider using one of the available lifetimes here LL | fn f4<'a, 'b>(a: &'a i32, b: &'b i32) -> &'lifetime i32 { loop {} } | +++++++++ -error[E0106]: missing lifetime specifier - --> $DIR/return-elided-lifetime.rs:27:44 - | -LL | fn f4_<'a, 'b>(a: &'a i32, b: &'b i32) -> (&i32, &i32) { loop {} } - | ------- ------- ^ expected named lifetime parameter - | - = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `a` or `b` -note: these named lifetimes are available to use - --> $DIR/return-elided-lifetime.rs:27:8 - | -LL | fn f4_<'a, 'b>(a: &'a i32, b: &'b i32) -> (&i32, &i32) { loop {} } - | ^^ ^^ -help: consider using one of the available lifetimes here - | -LL | fn f4_<'a, 'b>(a: &'a i32, b: &'b i32) -> (&'lifetime i32, &i32) { loop {} } - | +++++++++ - -error[E0106]: missing lifetime specifier - --> $DIR/return-elided-lifetime.rs:27:50 +error[E0106]: missing lifetime specifiers + --> $DIR/return-elided-lifetime.rs:24:44 | LL | fn f4_<'a, 'b>(a: &'a i32, b: &'b i32) -> (&i32, &i32) { loop {} } - | ------- ------- ^ expected named lifetime parameter + | ------- ------- ^ ^ expected named lifetime parameter + | | + | expected named lifetime parameter | - = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `a` or `b` + = help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments note: these named lifetimes are available to use - --> $DIR/return-elided-lifetime.rs:27:8 + --> $DIR/return-elided-lifetime.rs:24:8 | LL | fn f4_<'a, 'b>(a: &'a i32, b: &'b i32) -> (&i32, &i32) { loop {} } | ^^ ^^ help: consider using one of the available lifetimes here | -LL | fn f4_<'a, 'b>(a: &'a i32, b: &'b i32) -> (&i32, &'lifetime i32) { loop {} } - | +++++++++ +LL | fn f4_<'a, 'b>(a: &'a i32, b: &'b i32) -> (&'lifetime i32, &'lifetime i32) { loop {} } + | +++++++++ +++++++++ error[E0106]: missing lifetime specifier - --> $DIR/return-elided-lifetime.rs:31:35 + --> $DIR/return-elided-lifetime.rs:27:35 | LL | fn f5<'a>(a: &'a i32, b: &i32) -> &i32 { loop {} } | ------- ---- ^ expected named lifetime parameter @@ -167,32 +122,22 @@ LL | fn f5<'a>(a: &'a i32, b: &i32) -> &i32 { loop {} } help: consider using the `'a` lifetime | LL | fn f5<'a>(a: &'a i32, b: &i32) -> &'a i32 { loop {} } - | ~~~ - -error[E0106]: missing lifetime specifier - --> $DIR/return-elided-lifetime.rs:33:37 - | -LL | fn f5_<'a>(a: &'a i32, b: &i32) -> (&i32, &i32) { loop {} } - | ------- ---- ^ expected named lifetime parameter - | - = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `a` or `b` -help: consider using the `'a` lifetime - | -LL | fn f5_<'a>(a: &'a i32, b: &i32) -> (&'a i32, &i32) { loop {} } - | ~~~ + | ++ -error[E0106]: missing lifetime specifier - --> $DIR/return-elided-lifetime.rs:33:43 +error[E0106]: missing lifetime specifiers + --> $DIR/return-elided-lifetime.rs:29:37 | LL | fn f5_<'a>(a: &'a i32, b: &i32) -> (&i32, &i32) { loop {} } - | ------- ---- ^ expected named lifetime parameter + | ------- ---- ^ ^ expected named lifetime parameter + | | + | expected named lifetime parameter | = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `a` or `b` help: consider using the `'a` lifetime | -LL | fn f5_<'a>(a: &'a i32, b: &i32) -> (&i32, &'a i32) { loop {} } - | ~~~ +LL | fn f5_<'a>(a: &'a i32, b: &i32) -> (&'a i32, &'a i32) { loop {} } + | ++ ++ -error: aborting due to 15 previous errors +error: aborting due to 10 previous errors For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/suggestions/return-without-lifetime.stderr b/src/test/ui/suggestions/return-without-lifetime.stderr index 449a61d4809..5028e8d628f 100644 --- a/src/test/ui/suggestions/return-without-lifetime.stderr +++ b/src/test/ui/suggestions/return-without-lifetime.stderr @@ -7,7 +7,7 @@ LL | struct Foo<'a>(&usize); help: consider using the `'a` lifetime | LL | struct Foo<'a>(&'a usize); - | ~~~ + | ++ error[E0106]: missing lifetime specifier --> $DIR/return-without-lifetime.rs:5:34 @@ -19,7 +19,7 @@ LL | fn func1<'a>(_arg: &'a Thing) -> &() { unimplemented!() } help: consider using the `'a` lifetime | LL | fn func1<'a>(_arg: &'a Thing) -> &'a () { unimplemented!() } - | ~~~ + | ++ error[E0106]: missing lifetime specifier --> $DIR/return-without-lifetime.rs:7:35 @@ -31,7 +31,7 @@ LL | fn func2<'a>(_arg: &Thing<'a>) -> &() { unimplemented!() } help: consider using the `'a` lifetime | LL | fn func2<'a>(_arg: &Thing<'a>) -> &'a () { unimplemented!() } - | ~~~ + | ++ error: aborting due to 3 previous errors diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-lifetime-elision.stderr b/src/test/ui/unboxed-closures/unboxed-closure-sugar-lifetime-elision.stderr index d25452456bb..2b8fec86c8a 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-lifetime-elision.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-lifetime-elision.stderr @@ -5,6 +5,11 @@ LL | let _: dyn Foo(&isize, &usize) -> &usize; | ------ ------ ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from argument 1 or argument 2 + = 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 | let _: dyn for<'a> Foo(&'a isize, &'a usize) -> &'a usize; + | +++++++ ++ ++ ++ help: consider introducing a named lifetime parameter | LL ~ fn main<'a>() { diff --git a/src/test/ui/underscore-lifetime/dyn-trait-underscore-in-struct.rs b/src/test/ui/underscore-lifetime/dyn-trait-underscore-in-struct.rs index 37c87dbeaa9..e1deab736cf 100644 --- a/src/test/ui/underscore-lifetime/dyn-trait-underscore-in-struct.rs +++ b/src/test/ui/underscore-lifetime/dyn-trait-underscore-in-struct.rs @@ -7,7 +7,6 @@ use std::fmt::Debug; struct Foo { x: Box<dyn Debug + '_>, //~ ERROR missing lifetime specifier - //~^ ERROR E0228 } -fn main() { } +fn main() {} diff --git a/src/test/ui/underscore-lifetime/dyn-trait-underscore-in-struct.stderr b/src/test/ui/underscore-lifetime/dyn-trait-underscore-in-struct.stderr index b865278e25f..fd086002803 100644 --- a/src/test/ui/underscore-lifetime/dyn-trait-underscore-in-struct.stderr +++ b/src/test/ui/underscore-lifetime/dyn-trait-underscore-in-struct.stderr @@ -10,13 +10,6 @@ LL ~ struct Foo<'a> { LL ~ x: Box<dyn Debug + 'a>, | -error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an explicit bound - --> $DIR/dyn-trait-underscore-in-struct.rs:9:12 - | -LL | x: Box<dyn Debug + '_>, - | ^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0106, E0228. -For more information about an error, try `rustc --explain E0106`. +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/underscore-lifetime/underscore-lifetime-binders.stderr b/src/test/ui/underscore-lifetime/underscore-lifetime-binders.stderr index 22bf1fdba32..50401791eff 100644 --- a/src/test/ui/underscore-lifetime/underscore-lifetime-binders.stderr +++ b/src/test/ui/underscore-lifetime/underscore-lifetime-binders.stderr @@ -1,3 +1,14 @@ +error[E0106]: missing lifetime specifier + --> $DIR/underscore-lifetime-binders.rs:2:17 + | +LL | struct Baz<'a>(&'_ &'a u8); + | ^^ expected named lifetime parameter + | +help: consider using the `'a` lifetime + | +LL | struct Baz<'a>(&'a &'a u8); + | ~~ + error[E0637]: `'_` cannot be used here --> $DIR/underscore-lifetime-binders.rs:4:8 | @@ -11,17 +22,6 @@ LL | fn meh() -> Box<dyn for<'_> Meh<'_>> | ^^ `'_` is a reserved lifetime name error[E0106]: missing lifetime specifier - --> $DIR/underscore-lifetime-binders.rs:2:17 - | -LL | struct Baz<'a>(&'_ &'a u8); - | ^^ expected named lifetime parameter - | -help: consider using the `'a` lifetime - | -LL | struct Baz<'a>(&'a &'a u8); - | ~~ - -error[E0106]: missing lifetime specifier --> $DIR/underscore-lifetime-binders.rs:10:33 | LL | fn meh() -> Box<dyn for<'_> Meh<'_>> |
