diff options
| author | Michael Goulet <michael@errs.io> | 2024-03-07 15:44:07 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-03-08 19:08:13 +0000 |
| commit | ffd30e0a6939d7d25c4ac28bfac4b4e367adcd59 (patch) | |
| tree | 079aa5d6de0958fa94d642c53a3c8077baf65153 /tests/ui/impl-trait | |
| parent | 74acabe9b042ea8c42862ee29aca2a8b7d333644 (diff) | |
| download | rust-ffd30e0a6939d7d25c4ac28bfac4b4e367adcd59.tar.gz rust-ffd30e0a6939d7d25c4ac28bfac4b4e367adcd59.zip | |
Improve error message for opaque captures
Diffstat (limited to 'tests/ui/impl-trait')
| -rw-r--r-- | tests/ui/impl-trait/impl-fn-hrtb-bounds.rs | 6 | ||||
| -rw-r--r-- | tests/ui/impl-trait/impl-fn-hrtb-bounds.stderr | 9 | ||||
| -rw-r--r-- | tests/ui/impl-trait/impl-fn-parsing-ambiguities.rs | 2 | ||||
| -rw-r--r-- | tests/ui/impl-trait/impl-fn-parsing-ambiguities.stderr | 3 | ||||
| -rw-r--r-- | tests/ui/impl-trait/implicit-capture-late.stderr | 8 | ||||
| -rw-r--r-- | tests/ui/impl-trait/issues/issue-54895.rs | 2 | ||||
| -rw-r--r-- | tests/ui/impl-trait/issues/issue-54895.stderr | 3 | ||||
| -rw-r--r-- | tests/ui/impl-trait/issues/issue-67830.rs | 2 | ||||
| -rw-r--r-- | tests/ui/impl-trait/issues/issue-67830.stderr | 3 | ||||
| -rw-r--r-- | tests/ui/impl-trait/issues/issue-88236-2.rs | 6 | ||||
| -rw-r--r-- | tests/ui/impl-trait/issues/issue-88236-2.stderr | 7 | ||||
| -rw-r--r-- | tests/ui/impl-trait/issues/issue-88236.rs | 2 | ||||
| -rw-r--r-- | tests/ui/impl-trait/issues/issue-88236.stderr | 3 | ||||
| -rw-r--r-- | tests/ui/impl-trait/nested-rpit-hrtb.rs | 8 | ||||
| -rw-r--r-- | tests/ui/impl-trait/nested-rpit-hrtb.stderr | 10 |
15 files changed, 43 insertions, 31 deletions
diff --git a/tests/ui/impl-trait/impl-fn-hrtb-bounds.rs b/tests/ui/impl-trait/impl-fn-hrtb-bounds.rs index 06c3d9ad434..a9ea657f10e 100644 --- a/tests/ui/impl-trait/impl-fn-hrtb-bounds.rs +++ b/tests/ui/impl-trait/impl-fn-hrtb-bounds.rs @@ -2,19 +2,19 @@ use std::fmt::Debug; fn a() -> impl Fn(&u8) -> (impl Debug + '_) { - //~^ ERROR higher kinded lifetime bounds on nested opaque types are not supported yet + //~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` |x| x //~^ ERROR lifetime may not live long enough } fn b() -> impl for<'a> Fn(&'a u8) -> (impl Debug + 'a) { - //~^ ERROR higher kinded lifetime bounds on nested opaque types are not supported yet + //~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` |x| x //~^ ERROR lifetime may not live long enough } fn c() -> impl for<'a> Fn(&'a u8) -> (impl Debug + '_) { - //~^ ERROR higher kinded lifetime bounds on nested opaque types are not supported yet + //~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` |x| x //~^ ERROR lifetime may not live long enough } diff --git a/tests/ui/impl-trait/impl-fn-hrtb-bounds.stderr b/tests/ui/impl-trait/impl-fn-hrtb-bounds.stderr index 959d6577d9a..bdb099619b7 100644 --- a/tests/ui/impl-trait/impl-fn-hrtb-bounds.stderr +++ b/tests/ui/impl-trait/impl-fn-hrtb-bounds.stderr @@ -10,7 +10,7 @@ help: consider using the `'static` lifetime, but this is uncommon unless you're LL | fn d() -> impl Fn() -> (impl Debug + 'static) { | ~~~~~~~ -error: higher kinded lifetime bounds on nested opaque types are not supported yet +error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` --> $DIR/impl-fn-hrtb-bounds.rs:4:41 | LL | fn a() -> impl Fn(&u8) -> (impl Debug + '_) { @@ -31,7 +31,7 @@ LL | |x| x | |return type of closure is impl Debug + '2 | has type `&'1 u8` -error: higher kinded lifetime bounds on nested opaque types are not supported yet +error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` --> $DIR/impl-fn-hrtb-bounds.rs:10:52 | LL | fn b() -> impl for<'a> Fn(&'a u8) -> (impl Debug + 'a) { @@ -52,7 +52,7 @@ LL | |x| x | |return type of closure is impl Debug + '2 | has type `&'1 u8` -error: higher kinded lifetime bounds on nested opaque types are not supported yet +error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` --> $DIR/impl-fn-hrtb-bounds.rs:16:52 | LL | fn c() -> impl for<'a> Fn(&'a u8) -> (impl Debug + '_) { @@ -75,4 +75,5 @@ LL | |x| x error: aborting due to 7 previous errors -For more information about this error, try `rustc --explain E0106`. +Some errors have detailed explanations: E0106, E0657. +For more information about an error, try `rustc --explain E0106`. diff --git a/tests/ui/impl-trait/impl-fn-parsing-ambiguities.rs b/tests/ui/impl-trait/impl-fn-parsing-ambiguities.rs index a4a1f1dcee1..ef9d8733509 100644 --- a/tests/ui/impl-trait/impl-fn-parsing-ambiguities.rs +++ b/tests/ui/impl-trait/impl-fn-parsing-ambiguities.rs @@ -3,7 +3,7 @@ use std::fmt::Debug; fn a() -> impl Fn(&u8) -> impl Debug + '_ { //~^ ERROR ambiguous `+` in a type - //~| ERROR higher kinded lifetime bounds on nested opaque types are not supported yet + //~| ERROR cannot capture higher-ranked lifetime from outer `impl Trait` |x| x //~^ ERROR lifetime may not live long enough } diff --git a/tests/ui/impl-trait/impl-fn-parsing-ambiguities.stderr b/tests/ui/impl-trait/impl-fn-parsing-ambiguities.stderr index e18e89700b4..3881b37a0cb 100644 --- a/tests/ui/impl-trait/impl-fn-parsing-ambiguities.stderr +++ b/tests/ui/impl-trait/impl-fn-parsing-ambiguities.stderr @@ -10,7 +10,7 @@ error: ambiguous `+` in a type LL | fn b() -> impl Fn() -> impl Debug + Send { | ^^^^^^^^^^^^^^^^^ help: use parentheses to disambiguate: `(impl Debug + Send)` -error: higher kinded lifetime bounds on nested opaque types are not supported yet +error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` --> $DIR/impl-fn-parsing-ambiguities.rs:4:40 | LL | fn a() -> impl Fn(&u8) -> impl Debug + '_ { @@ -33,3 +33,4 @@ LL | |x| x error: aborting due to 4 previous errors +For more information about this error, try `rustc --explain E0657`. diff --git a/tests/ui/impl-trait/implicit-capture-late.stderr b/tests/ui/impl-trait/implicit-capture-late.stderr index 2fb5ebb6541..080750f8497 100644 --- a/tests/ui/impl-trait/implicit-capture-late.stderr +++ b/tests/ui/impl-trait/implicit-capture-late.stderr @@ -1,4 +1,10 @@ -error[E0657]: `impl Trait` can only capture lifetimes bound at the fn or impl level +error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from `dyn` type + --> $DIR/implicit-capture-late.rs:10:55 + | +LL | fn foo(x: Vec<i32>) -> Box<dyn for<'a> Deref<Target = impl ?Sized>> { + | ^^^^^^^^^^^ `impl Trait` implicitly captures all lifetimes in scope + | +note: lifetime declared here --> $DIR/implicit-capture-late.rs:10:36 | LL | fn foo(x: Vec<i32>) -> Box<dyn for<'a> Deref<Target = impl ?Sized>> { diff --git a/tests/ui/impl-trait/issues/issue-54895.rs b/tests/ui/impl-trait/issues/issue-54895.rs index 8d7a1d56f83..13c0038ce43 100644 --- a/tests/ui/impl-trait/issues/issue-54895.rs +++ b/tests/ui/impl-trait/issues/issue-54895.rs @@ -13,7 +13,7 @@ impl<'a> Trait<'a> for X { } fn f() -> impl for<'a> Trait<'a, Out = impl Sized + 'a> { - //~^ ERROR higher kinded lifetime bounds on nested opaque types are not supported yet + //~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` X(()) } diff --git a/tests/ui/impl-trait/issues/issue-54895.stderr b/tests/ui/impl-trait/issues/issue-54895.stderr index 999ffd52141..64b425328e3 100644 --- a/tests/ui/impl-trait/issues/issue-54895.stderr +++ b/tests/ui/impl-trait/issues/issue-54895.stderr @@ -1,4 +1,4 @@ -error: higher kinded lifetime bounds on nested opaque types are not supported yet +error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` --> $DIR/issue-54895.rs:15:53 | LL | fn f() -> impl for<'a> Trait<'a, Out = impl Sized + 'a> { @@ -12,3 +12,4 @@ LL | fn f() -> impl for<'a> Trait<'a, Out = impl Sized + 'a> { error: aborting due to 1 previous error +For more information about this error, try `rustc --explain E0657`. diff --git a/tests/ui/impl-trait/issues/issue-67830.rs b/tests/ui/impl-trait/issues/issue-67830.rs index 6dc8935c777..939eca82a8f 100644 --- a/tests/ui/impl-trait/issues/issue-67830.rs +++ b/tests/ui/impl-trait/issues/issue-67830.rs @@ -19,7 +19,7 @@ where struct A; fn test() -> impl for<'a> MyFn<&'a A, Output=impl Iterator + 'a> { - //~^ ERROR higher kinded lifetime bounds on nested opaque types are not supported yet + //~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` Wrap(|a| Some(a).into_iter()) //~^ ERROR implementation of `FnOnce` is not general enough //~| ERROR implementation of `FnOnce` is not general enough diff --git a/tests/ui/impl-trait/issues/issue-67830.stderr b/tests/ui/impl-trait/issues/issue-67830.stderr index 546198b8a10..ef513a40cf3 100644 --- a/tests/ui/impl-trait/issues/issue-67830.stderr +++ b/tests/ui/impl-trait/issues/issue-67830.stderr @@ -1,4 +1,4 @@ -error: higher kinded lifetime bounds on nested opaque types are not supported yet +error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` --> $DIR/issue-67830.rs:21:62 | LL | fn test() -> impl for<'a> MyFn<&'a A, Output=impl Iterator + 'a> { @@ -31,3 +31,4 @@ LL | Wrap(|a| Some(a).into_iter()) error: aborting due to 3 previous errors +For more information about this error, try `rustc --explain E0657`. diff --git a/tests/ui/impl-trait/issues/issue-88236-2.rs b/tests/ui/impl-trait/issues/issue-88236-2.rs index f4354d1b2ae..7ff08d8174f 100644 --- a/tests/ui/impl-trait/issues/issue-88236-2.rs +++ b/tests/ui/impl-trait/issues/issue-88236-2.rs @@ -13,17 +13,17 @@ impl<'a> Hrtb<'a> for &'a () { } fn make_impl() -> impl for<'a> Hrtb<'a, Assoc = impl Send + 'a> {} -//~^ ERROR higher kinded lifetime bounds on nested opaque types are not supported yet +//~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` fn make_weird_impl<'b>(x: &'b ()) -> impl for<'a> Hrtb<'a, Assoc = impl Send + 'a> { - //~^ ERROR higher kinded lifetime bounds on nested opaque types are not supported yet + //~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` &() //~^ ERROR implementation of `Hrtb` is not general enough //~| ERROR implementation of `Hrtb` is not general enough } fn make_bad_impl<'b>(x: &'b ()) -> impl for<'a> Hrtb<'a, Assoc = impl Send + 'a> { - //~^ ERROR higher kinded lifetime bounds on nested opaque types are not supported yet + //~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` x //~^ ERROR implementation of `Hrtb` is not general enough //~| ERROR implementation of `Hrtb` is not general enough diff --git a/tests/ui/impl-trait/issues/issue-88236-2.stderr b/tests/ui/impl-trait/issues/issue-88236-2.stderr index 1f5029f9d9f..09fd58056a5 100644 --- a/tests/ui/impl-trait/issues/issue-88236-2.stderr +++ b/tests/ui/impl-trait/issues/issue-88236-2.stderr @@ -1,4 +1,4 @@ -error: higher kinded lifetime bounds on nested opaque types are not supported yet +error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` --> $DIR/issue-88236-2.rs:15:61 | LL | fn make_impl() -> impl for<'a> Hrtb<'a, Assoc = impl Send + 'a> {} @@ -10,7 +10,7 @@ note: lifetime declared here LL | fn make_impl() -> impl for<'a> Hrtb<'a, Assoc = impl Send + 'a> {} | ^^ -error: higher kinded lifetime bounds on nested opaque types are not supported yet +error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` --> $DIR/issue-88236-2.rs:18:80 | LL | fn make_weird_impl<'b>(x: &'b ()) -> impl for<'a> Hrtb<'a, Assoc = impl Send + 'a> { @@ -40,7 +40,7 @@ LL | &() = note: `Hrtb<'a>` would have to be implemented for the type `&()` = note: ...but `Hrtb<'0>` is actually implemented for the type `&'0 ()`, for some specific lifetime `'0` -error: higher kinded lifetime bounds on nested opaque types are not supported yet +error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` --> $DIR/issue-88236-2.rs:25:78 | LL | fn make_bad_impl<'b>(x: &'b ()) -> impl for<'a> Hrtb<'a, Assoc = impl Send + 'a> { @@ -90,3 +90,4 @@ LL | x error: aborting due to 8 previous errors +For more information about this error, try `rustc --explain E0657`. diff --git a/tests/ui/impl-trait/issues/issue-88236.rs b/tests/ui/impl-trait/issues/issue-88236.rs index 36d12417354..e782a876573 100644 --- a/tests/ui/impl-trait/issues/issue-88236.rs +++ b/tests/ui/impl-trait/issues/issue-88236.rs @@ -13,6 +13,6 @@ impl<'a> Hrtb<'a> for &'a () { } fn make_impl() -> impl for<'a> Hrtb<'a, Assoc = impl Send + 'a> {} -//~^ ERROR higher kinded lifetime bounds on nested opaque types are not supported yet +//~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` fn main() {} diff --git a/tests/ui/impl-trait/issues/issue-88236.stderr b/tests/ui/impl-trait/issues/issue-88236.stderr index 6cf1a42d6a9..5dee5f88c89 100644 --- a/tests/ui/impl-trait/issues/issue-88236.stderr +++ b/tests/ui/impl-trait/issues/issue-88236.stderr @@ -1,4 +1,4 @@ -error: higher kinded lifetime bounds on nested opaque types are not supported yet +error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` --> $DIR/issue-88236.rs:15:61 | LL | fn make_impl() -> impl for<'a> Hrtb<'a, Assoc = impl Send + 'a> {} @@ -12,3 +12,4 @@ LL | fn make_impl() -> impl for<'a> Hrtb<'a, Assoc = impl Send + 'a> {} error: aborting due to 1 previous error +For more information about this error, try `rustc --explain E0657`. diff --git a/tests/ui/impl-trait/nested-rpit-hrtb.rs b/tests/ui/impl-trait/nested-rpit-hrtb.rs index a3eca741daa..c10bfbfe4dc 100644 --- a/tests/ui/impl-trait/nested-rpit-hrtb.rs +++ b/tests/ui/impl-trait/nested-rpit-hrtb.rs @@ -23,18 +23,18 @@ impl Qux<'_> for () {} // This is not supported. fn one_hrtb_outlives() -> impl for<'a> Foo<'a, Assoc = impl Sized + 'a> {} -//~^ ERROR higher kinded lifetime bounds on nested opaque types are not supported yet +//~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` // This is not supported. fn one_hrtb_trait_param() -> impl for<'a> Foo<'a, Assoc = impl Qux<'a>> {} -//~^ ERROR higher kinded lifetime bounds on nested opaque types are not supported yet +//~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` fn one_hrtb_outlives_uses() -> impl for<'a> Bar<'a, Assoc = impl Sized + 'a> {} -//~^ ERROR higher kinded lifetime bounds on nested opaque types are not supported yet +//~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` //~| ERROR implementation of `Bar` is not general enough fn one_hrtb_trait_param_uses() -> impl for<'a> Bar<'a, Assoc = impl Qux<'a>> {} -//~^ ERROR higher kinded lifetime bounds on nested opaque types are not supported yet +//~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` //~| ERROR: the trait bound `for<'a> &'a (): Qux<'_>` is not satisfied // This should resolve. diff --git a/tests/ui/impl-trait/nested-rpit-hrtb.stderr b/tests/ui/impl-trait/nested-rpit-hrtb.stderr index 4fc22712de6..2779694a517 100644 --- a/tests/ui/impl-trait/nested-rpit-hrtb.stderr +++ b/tests/ui/impl-trait/nested-rpit-hrtb.stderr @@ -29,7 +29,7 @@ help: consider introducing lifetime `'b` here LL | fn two_htrb_outlives_uses<'b>() -> impl for<'a> Bar<'a, Assoc = impl for<'b> Sized + 'b> {} | ++++ -error: higher kinded lifetime bounds on nested opaque types are not supported yet +error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` --> $DIR/nested-rpit-hrtb.rs:25:69 | LL | fn one_hrtb_outlives() -> impl for<'a> Foo<'a, Assoc = impl Sized + 'a> {} @@ -41,7 +41,7 @@ note: lifetime declared here LL | fn one_hrtb_outlives() -> impl for<'a> Foo<'a, Assoc = impl Sized + 'a> {} | ^^ -error: higher kinded lifetime bounds on nested opaque types are not supported yet +error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` --> $DIR/nested-rpit-hrtb.rs:29:68 | LL | fn one_hrtb_trait_param() -> impl for<'a> Foo<'a, Assoc = impl Qux<'a>> {} @@ -53,7 +53,7 @@ note: lifetime declared here LL | fn one_hrtb_trait_param() -> impl for<'a> Foo<'a, Assoc = impl Qux<'a>> {} | ^^ -error: higher kinded lifetime bounds on nested opaque types are not supported yet +error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` --> $DIR/nested-rpit-hrtb.rs:32:74 | LL | fn one_hrtb_outlives_uses() -> impl for<'a> Bar<'a, Assoc = impl Sized + 'a> {} @@ -74,7 +74,7 @@ LL | fn one_hrtb_outlives_uses() -> impl for<'a> Bar<'a, Assoc = impl Sized + 'a = note: `()` must implement `Bar<'a>` = note: ...but it actually implements `Bar<'0>`, for some specific lifetime `'0` -error: higher kinded lifetime bounds on nested opaque types are not supported yet +error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` --> $DIR/nested-rpit-hrtb.rs:36:73 | LL | fn one_hrtb_trait_param_uses() -> impl for<'a> Bar<'a, Assoc = impl Qux<'a>> {} @@ -133,5 +133,5 @@ LL | fn two_htrb_outlives_uses() -> impl for<'a> Bar<'a, Assoc = impl for<'b> Si error: aborting due to 12 previous errors -Some errors have detailed explanations: E0261, E0277. +Some errors have detailed explanations: E0261, E0277, E0657. For more information about an error, try `rustc --explain E0261`. |
