Rollup merge of #99748 - compiler-errors:better-impl-trait-printing, r=fee1-dead
Use full type name instead of just saying `impl Trait` in "captures lifetime" error I think this is very useful, especially when there's >1 `impl Trait`, and it just means passing around a bit more info that we already have access to.
This commit is contained in:
commit
ad32667bc8
27 changed files with 52 additions and 50 deletions
|
|
@ -13,7 +13,7 @@ LL | | }
|
|||
|
|
||||
= help: consider adding the following bound: `'a: 'b`
|
||||
|
||||
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
|
||||
error[E0700]: hidden type for `impl Trait<'a>` captures lifetime that does not appear in bounds
|
||||
--> $DIR/ret-impl-trait-one.rs:16:80
|
||||
|
|
||||
LL | async fn async_ret_impl_trait1<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
|
||||
error[E0700]: hidden type for `impl Swap` captures lifetime that does not appear in bounds
|
||||
--> $DIR/hidden-lifetimes.rs:29:5
|
||||
|
|
||||
LL | fn hide_ref<'a, 'b, T: 'static>(x: &'a mut &'b T) -> impl Swap + 'a {
|
||||
|
|
@ -11,7 +11,7 @@ help: to declare that the `impl Trait` captures `'b`, you can add an explicit `'
|
|||
LL | fn hide_ref<'a, 'b, T: 'static>(x: &'a mut &'b T) -> impl Swap + 'a + 'b {
|
||||
| ++++
|
||||
|
||||
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
|
||||
error[E0700]: hidden type for `impl Swap` captures lifetime that does not appear in bounds
|
||||
--> $DIR/hidden-lifetimes.rs:46:5
|
||||
|
|
||||
LL | fn hide_rc_refcell<'a, 'b: 'a, T: 'static>(x: Rc<RefCell<&'b T>>) -> impl Swap + 'a {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ fn foo<'a: 'b, 'b, 'c>(x: &'static i32, mut y: &'a i32) -> E<'b, 'c> {
|
|||
let _: &'b i32 = *u.0;
|
||||
}
|
||||
u.0
|
||||
//~^ ERROR hidden type for `impl Trait` captures lifetime that does not appear in bounds
|
||||
//~^ ERROR hidden type for `E<'b, 'c>` captures lifetime that does not appear in bounds
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
|
||||
error[E0700]: hidden type for `E<'b, 'c>` captures lifetime that does not appear in bounds
|
||||
--> $DIR/error-handling-2.rs:22:5
|
||||
|
|
||||
LL | fn foo<'a: 'b, 'b, 'c>(x: &'static i32, mut y: &'a i32) -> E<'b, 'c> {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ where
|
|||
// 'a in ['d, 'e]
|
||||
// ```
|
||||
if condition() { a } else { b }
|
||||
//~^ ERROR hidden type for `impl Trait` captures lifetime that does not appear in bounds
|
||||
//~^ ERROR hidden type for `impl Trait<'d, 'e>` captures lifetime that does not appear in bounds
|
||||
}
|
||||
|
||||
fn condition() -> bool {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
|
||||
error[E0700]: hidden type for `impl Trait<'d, 'e>` captures lifetime that does not appear in bounds
|
||||
--> $DIR/ordinary-bounds-unrelated.rs:28:33
|
||||
|
|
||||
LL | fn upper_bounds<'a, 'b, 'c, 'd, 'e>(a: Ordinary<'a>, b: Ordinary<'b>) -> impl Trait<'d, 'e>
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ fn upper_bounds<'a, 'b>(a: Ordinary<'a>, b: Ordinary<'b>) -> impl Trait<'a, 'b>
|
|||
//
|
||||
// We are forced to pick that '0 = 'e, because only 'e is outlived by *both* 'a and 'b.
|
||||
if condition() { a } else { b }
|
||||
//~^ ERROR hidden type for `impl Trait` captures lifetime that does not appear in bounds
|
||||
//~^ ERROR hidden type for `impl Trait<'a, 'b>` captures lifetime that does not appear in bounds
|
||||
}
|
||||
|
||||
fn condition() -> bool {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
|
||||
error[E0700]: hidden type for `impl Trait<'a, 'b>` captures lifetime that does not appear in bounds
|
||||
--> $DIR/ordinary-bounds-unsuited.rs:31:33
|
||||
|
|
||||
LL | fn upper_bounds<'a, 'b>(a: Ordinary<'a>, b: Ordinary<'b>) -> impl Trait<'a, 'b>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
|
||||
error[E0700]: hidden type for `impl Copy` captures lifetime that does not appear in bounds
|
||||
--> $DIR/must_outlive_least_region_or_bound.rs:3:35
|
||||
|
|
||||
LL | fn elided(x: &i32) -> impl Copy { x }
|
||||
|
|
@ -11,7 +11,7 @@ help: to declare that the `impl Trait` captures `'_`, you can add an explicit `'
|
|||
LL | fn elided(x: &i32) -> impl Copy + '_ { x }
|
||||
| ++++
|
||||
|
||||
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
|
||||
error[E0700]: hidden type for `impl Copy` captures lifetime that does not appear in bounds
|
||||
--> $DIR/must_outlive_least_region_or_bound.rs:6:44
|
||||
|
|
||||
LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x }
|
||||
|
|
@ -96,7 +96,7 @@ help: alternatively, add an explicit `'static` bound to this reference
|
|||
LL | fn with_bound<'a>(x: &'static i32) -> impl LifetimeTrait<'a> + 'static { x }
|
||||
| ~~~~~~~~~~~~
|
||||
|
||||
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
|
||||
error[E0700]: hidden type for `impl Fn(&'a u32)` captures lifetime that does not appear in bounds
|
||||
--> $DIR/must_outlive_least_region_or_bound.rs:38:5
|
||||
|
|
||||
LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ fn foo<'x, 'y>(x: Cell<&'x u32>) -> impl Trait<'y>
|
|||
where 'x: 'y
|
||||
{
|
||||
x
|
||||
//~^ ERROR hidden type for `impl Trait` captures lifetime that does not appear in bounds [E0700]
|
||||
//~^ ERROR hidden type for `impl Trait<'y>` captures lifetime that does not appear in bounds [E0700]
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
|
||||
error[E0700]: hidden type for `impl Trait<'y>` captures lifetime that does not appear in bounds
|
||||
--> $DIR/region-escape-via-bound.rs:17:5
|
||||
|
|
||||
LL | fn foo<'x, 'y>(x: Cell<&'x u32>) -> impl Trait<'y>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
|
||||
error[E0700]: hidden type for `impl Iterator<Item = u32>` captures lifetime that does not appear in bounds
|
||||
--> $DIR/static-return-lifetime-infered.rs:7:9
|
||||
|
|
||||
LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> {
|
||||
|
|
@ -11,7 +11,7 @@ help: to declare that the `impl Trait` captures `'_`, you can add an explicit `'
|
|||
LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> + '_ {
|
||||
| ++++
|
||||
|
||||
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
|
||||
error[E0700]: hidden type for `impl Iterator<Item = u32>` captures lifetime that does not appear in bounds
|
||||
--> $DIR/static-return-lifetime-infered.rs:7:9
|
||||
|
|
||||
LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> {
|
||||
|
|
@ -24,7 +24,7 @@ help: to declare that the `impl Trait` captures `'_`, you can add an explicit `'
|
|||
LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> + '_ {
|
||||
| ++++
|
||||
|
||||
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
|
||||
error[E0700]: hidden type for `impl Iterator<Item = u32>` captures lifetime that does not appear in bounds
|
||||
--> $DIR/static-return-lifetime-infered.rs:12:9
|
||||
|
|
||||
LL | fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> {
|
||||
|
|
@ -37,7 +37,7 @@ help: to declare that the `impl Trait` captures `'a`, you can add an explicit `'
|
|||
LL | fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> + 'a {
|
||||
| ++++
|
||||
|
||||
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
|
||||
error[E0700]: hidden type for `impl Iterator<Item = u32>` captures lifetime that does not appear in bounds
|
||||
--> $DIR/static-return-lifetime-infered.rs:12:9
|
||||
|
|
||||
LL | fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
|
||||
error[E0700]: hidden type for `impl Iterator<Item = u8>` captures lifetime that does not appear in bounds
|
||||
--> $DIR/issue-73159-rpit-static.rs:8:9
|
||||
|
|
||||
LL | impl<'a> Foo<'a> {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
|
||||
error[E0700]: hidden type for `Opaque(DefId(0:11 ~ impl_trait_captures[1afc]::foo::{opaque#0}), [ReStatic, T, ReEarlyBound(0, 'a)])` captures lifetime that does not appear in bounds
|
||||
--> $DIR/impl-trait-captures.rs:11:5
|
||||
|
|
||||
LL | fn foo<'a, T>(x: &T) -> impl Foo<'a> {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
|
||||
error[E0700]: hidden type for `impl Clone` captures lifetime that does not appear in bounds
|
||||
--> $DIR/arbitrary_self_types_pin_lifetime_impl_trait-async.rs:8:48
|
||||
|
|
||||
LL | async fn f(self: Pin<&Self>) -> impl Clone { self }
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
|
||||
error[E0700]: hidden type for `impl Clone` captures lifetime that does not appear in bounds
|
||||
--> $DIR/arbitrary_self_types_pin_lifetime_impl_trait.rs:6:44
|
||||
|
|
||||
LL | fn f(self: Pin<&Self>) -> impl Clone { self }
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ where
|
|||
G: Get<T>,
|
||||
{
|
||||
move || {
|
||||
//~^ ERROR hidden type for `impl Trait` captures lifetime
|
||||
//~^ ERROR hidden type for `impl FnOnce()` captures lifetime
|
||||
*dest = g.get();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ LL | fn baz<G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
|
|||
| |
|
||||
| help: consider introducing lifetime `'a` here: `'a,`
|
||||
|
||||
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
|
||||
error[E0700]: hidden type for `impl FnOnce()` captures lifetime that does not appear in bounds
|
||||
--> $DIR/missing-lifetimes-in-signature.rs:19:5
|
||||
|
|
||||
LL | fn foo<G, T>(g: G, dest: &mut T) -> impl FnOnce()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue