From fe91cfd684340f45dabd15568b7dae2f8118ee44 Mon Sep 17 00:00:00 2001 From: Jack Huey <31162821+jackh726@users.noreply.github.com> Date: Sun, 22 May 2022 01:36:12 -0400 Subject: [PATCH] Use revisions for NLL in suggestions --- ...ound-needing-more-suggestions.base.stderr} | 10 +- ...-bound-needing-more-suggestions.nll.stderr | 6 +- ...t-static-bound-needing-more-suggestions.rs | 6 +- ...yn-trait-with-implicit-static-bound-nll.rs | 118 ++++++++++++++++++ ...ait-with-implicit-static-bound-nll.stderr} | 8 +- ...dyn-trait-with-implicit-static-bound.fixed | 5 + ...on-dyn-trait-with-implicit-static-bound.rs | 5 + ...yn-trait-with-implicit-static-bound.stderr | 26 ++-- ...sing-lifetimes-in-signature-2.base.stderr} | 10 +- ...issing-lifetimes-in-signature-2.nll.stderr | 6 +- .../missing-lifetimes-in-signature-2.rs | 4 + ...issing-lifetimes-in-signature.base.stderr} | 36 +++--- .../missing-lifetimes-in-signature.nll.stderr | 47 ++++--- .../missing-lifetimes-in-signature.rs | 20 ++- ...t-object-nested-in-impl-trait.base.stderr} | 16 +-- ...ait-object-nested-in-impl-trait.nll.stderr | 16 ++- .../trait-object-nested-in-impl-trait.rs | 20 ++- .../suggest-impl-trait-lifetime-nll.fixed | 24 ++++ .../suggest-impl-trait-lifetime-nll.rs | 24 ++++ ...=> suggest-impl-trait-lifetime-nll.stderr} | 2 +- .../suggest-impl-trait-lifetime.fixed | 5 + .../suggest-impl-trait-lifetime.rs | 5 + .../suggest-impl-trait-lifetime.stderr | 4 +- 23 files changed, 330 insertions(+), 93 deletions(-) rename src/test/ui/suggestions/{impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.stderr => impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.base.stderr} (94%) create mode 100644 src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-nll.rs rename src/test/ui/suggestions/{impl-on-dyn-trait-with-implicit-static-bound.nll.stderr => impl-on-dyn-trait-with-implicit-static-bound-nll.stderr} (88%) rename src/test/ui/suggestions/lifetimes/{missing-lifetimes-in-signature-2.stderr => missing-lifetimes-in-signature-2.base.stderr} (70%) rename src/test/ui/suggestions/lifetimes/{missing-lifetimes-in-signature.stderr => missing-lifetimes-in-signature.base.stderr} (81%) rename src/test/ui/suggestions/lifetimes/{trait-object-nested-in-impl-trait.stderr => trait-object-nested-in-impl-trait.base.stderr} (90%) create mode 100644 src/test/ui/suggestions/suggest-impl-trait-lifetime-nll.fixed create mode 100644 src/test/ui/suggestions/suggest-impl-trait-lifetime-nll.rs rename src/test/ui/suggestions/{suggest-impl-trait-lifetime.nll.stderr => suggest-impl-trait-lifetime-nll.stderr} (89%) diff --git a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.stderr b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.base.stderr similarity index 94% rename from src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.stderr rename to src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.base.stderr index b125eacfb6c..12c7c8f9b7e 100644 --- a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.stderr +++ b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.base.stderr @@ -1,23 +1,23 @@ error[E0515]: cannot return reference to function parameter `val` - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:21:9 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:25:9 | LL | val.use_self() | ^^^^^^^^^^^^^^ returns a reference to data owned by the current function error[E0515]: cannot return reference to function parameter `val` - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:43:9 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:47:9 | LL | val.use_self() | ^^^^^^^^^^^^^^ returns a reference to data owned by the current function error[E0515]: cannot return reference to function parameter `val` - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:109:9 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:113:9 | LL | val.use_self() | ^^^^^^^^^^^^^^ returns a reference to data owned by the current function error[E0772]: `val` has lifetime `'a` but calling `use_self` introduces an implicit `'static` lifetime requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:66:13 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:70:13 | LL | fn use_it<'a>(val: Box + 'a>) -> &'a () { | -------------------------------------- this data with lifetime `'a`... @@ -25,7 +25,7 @@ LL | val.use_self() | ^^^^^^^^ ...is used and required to live as long as `'static` here | note: the used `impl` has a `'static` requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:60:30 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:64:30 | LL | impl MyTrait for Box> { | ^^^^^^^^^^^^^^^^^^^^^^^^ this has an implicit `'static` lifetime requirement diff --git a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.nll.stderr b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.nll.stderr index 2dc300ac76f..db790049c6f 100644 --- a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.nll.stderr +++ b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.nll.stderr @@ -1,17 +1,17 @@ error[E0515]: cannot return reference to function parameter `val` - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:21:9 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:25:9 | LL | val.use_self() | ^^^^^^^^^^^^^^ returns a reference to data owned by the current function error[E0515]: cannot return reference to function parameter `val` - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:43:9 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:47:9 | LL | val.use_self() | ^^^^^^^^^^^^^^ returns a reference to data owned by the current function error[E0515]: cannot return reference to function parameter `val` - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:109:9 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:113:9 | LL | val.use_self() | ^^^^^^^^^^^^^^ returns a reference to data owned by the current function diff --git a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs index 0045d3fcf1c..ec90a0987f0 100644 --- a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs +++ b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // FIXME: the following cases need to suggest more things to make users reach a working end state. mod bav { @@ -63,7 +67,7 @@ mod bay { impl Bar for i32 {} fn use_it<'a>(val: Box + 'a>) -> &'a () { - val.use_self() //~ ERROR E0772 + val.use_self() //[base]~ ERROR E0772 } } diff --git a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-nll.rs b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-nll.rs new file mode 100644 index 00000000000..37be629e77c --- /dev/null +++ b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-nll.rs @@ -0,0 +1,118 @@ +// FIXME(nll): On NLL stabilization, this should replace +// `impl-on-dyn-trait-with-implicit-static-bound.rs`. Compiletest has +// problems with rustfix and revisions. +// ignore-compare-mode-nll +// compile-flags: -Zborrowck=mir + +#![allow(dead_code)] + +mod foo { + trait OtherTrait<'a> {} + impl<'a> OtherTrait<'a> for &'a () {} + + trait ObjectTrait {} + trait MyTrait { + fn use_self(&self) -> &(); + } + trait Irrelevant {} + + impl MyTrait for dyn ObjectTrait { + fn use_self(&self) -> &() { panic!() } + } + impl Irrelevant for dyn ObjectTrait {} + + fn use_it<'a, T>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { + val.use_self::() //~ ERROR borrowed data escapes + } +} + +mod bar { + trait ObjectTrait {} + trait MyTrait { + fn use_self(&self) -> &(); + } + trait Irrelevant {} + + impl MyTrait for dyn ObjectTrait { + fn use_self(&self) -> &() { panic!() } + } + impl Irrelevant for dyn ObjectTrait {} + + fn use_it<'a>(val: &'a dyn ObjectTrait) -> &'a () { + val.use_self() + } +} + +mod baz { + trait ObjectTrait {} + trait MyTrait { + fn use_self(&self) -> &(); + } + trait Irrelevant {} + + impl MyTrait for Box { + fn use_self(&self) -> &() { panic!() } + } + impl Irrelevant for Box {} + + fn use_it<'a>(val: &'a Box) -> &'a () { + val.use_self() + } +} + +mod bat { + trait OtherTrait<'a> {} + impl<'a> OtherTrait<'a> for &'a () {} + + trait ObjectTrait {} + + impl dyn ObjectTrait { + fn use_self(&self) -> &() { panic!() } + } + + fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { + val.use_self() + //~^ ERROR borrowed data escapes + } +} + +mod ban { + trait OtherTrait<'a> {} + impl<'a> OtherTrait<'a> for &'a () {} + + trait ObjectTrait {} + trait MyTrait { + fn use_self(&self) -> &() { panic!() } + } + trait Irrelevant { + fn use_self(&self) -> &() { panic!() } + } + + impl MyTrait for dyn ObjectTrait {} + + fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> { + val.use_self() //~ ERROR borrowed data escapes + } +} + +mod bal { + trait OtherTrait<'a> {} + impl<'a> OtherTrait<'a> for &'a () {} + + trait ObjectTrait {} + trait MyTrait { + fn use_self(&self) -> &() { panic!() } + } + trait Irrelevant { + fn use_self(&self) -> &() { panic!() } + } + + impl MyTrait for dyn ObjectTrait {} + impl Irrelevant for dyn ObjectTrait {} + + fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { + MyTrait::use_self(val) //~ ERROR borrowed data escapes + } +} + +fn main() {} diff --git a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.nll.stderr b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-nll.stderr similarity index 88% rename from src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.nll.stderr rename to src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-nll.stderr index a1ef32c5445..38731ea8955 100644 --- a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.nll.stderr +++ b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-nll.stderr @@ -1,5 +1,5 @@ error[E0521]: borrowed data escapes outside of function - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:20:9 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-nll.rs:25:9 | LL | fn use_it<'a, T>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { | -- --- `val` is a reference that is only valid in the function body @@ -12,7 +12,7 @@ LL | val.use_self::() | argument requires that `'a` must outlive `'static` error[E0521]: borrowed data escapes outside of function - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:69:9 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-nll.rs:74:9 | LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { | -- --- `val` is a reference that is only valid in the function body @@ -25,7 +25,7 @@ LL | val.use_self() | argument requires that `'a` must outlive `'static` error[E0521]: borrowed data escapes outside of function - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:88:9 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-nll.rs:94:9 | LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> { | -- --- `val` is a reference that is only valid in the function body @@ -38,7 +38,7 @@ LL | val.use_self() | argument requires that `'a` must outlive `'static` error[E0521]: borrowed data escapes outside of function - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:108:9 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-nll.rs:114:9 | LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { | -- --- `val` is a reference that is only valid in the function body diff --git a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.fixed b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.fixed index 3c10f85d942..74da1cbfea5 100644 --- a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.fixed +++ b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.fixed @@ -1,3 +1,8 @@ +// FIXME(nll): On NLL stabilization, this should be replaced by +// `impl-on-dyn-trait-with-implicit-static-bound-nll.rs`. Compiletest has +// problems with rustfix and revisions. +// ignore-compare-mode-nll + // run-rustfix #![allow(dead_code)] diff --git a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.rs b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.rs index 88ab03dfc1e..e0058b181b4 100644 --- a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.rs +++ b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.rs @@ -1,3 +1,8 @@ +// FIXME(nll): On NLL stabilization, this should be replaced by +// `impl-on-dyn-trait-with-implicit-static-bound-nll.rs`. Compiletest has +// problems with rustfix and revisions. +// ignore-compare-mode-nll + // run-rustfix #![allow(dead_code)] diff --git a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.stderr b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.stderr index ed094c1365c..fbe7ac94a0a 100644 --- a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.stderr +++ b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.stderr @@ -1,5 +1,5 @@ error[E0759]: `val` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:20:13 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:25:13 | LL | fn use_it<'a, T>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { | ---------------------- this data with lifetime `'a`... @@ -7,7 +7,7 @@ LL | val.use_self::() | ^^^^^^^^ ...is used and required to live as long as `'static` here | note: the used `impl` has a `'static` requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:14:32 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:19:32 | LL | impl MyTrait for dyn ObjectTrait { | ^^^^^^^^^^^^^^ this has an implicit `'static` lifetime requirement @@ -19,7 +19,7 @@ LL | impl MyTrait for dyn ObjectTrait + '_ { | ++++ error[E0772]: `val` has lifetime `'a` but calling `use_self` introduces an implicit `'static` lifetime requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:69:13 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:74:13 | LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { | ------------------- this data with lifetime `'a`... @@ -27,7 +27,7 @@ LL | val.use_self() | ^^^^^^^^ ...is used and required to live as long as `'static` here because of an implicit lifetime bound on the inherent `impl` | note: the used `impl` has a `'static` requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:64:14 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:69:14 | LL | impl dyn ObjectTrait { | ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement @@ -39,7 +39,7 @@ LL | impl dyn ObjectTrait + '_ { | ++++ error[E0759]: `val` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:88:13 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:93:13 | LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> { | ------------------- this data with lifetime `'a`... @@ -47,7 +47,7 @@ LL | val.use_self() | ^^^^^^^^ ...is used and required to live as long as `'static` here | note: the used `impl` has a `'static` requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:85:26 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:90:26 | LL | fn use_self(&self) -> &() { panic!() } | -------- calling this method introduces the `impl`'s 'static` requirement @@ -64,7 +64,7 @@ LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { | ++++ error[E0759]: `val` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:108:27 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:113:27 | LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { | ------------------- this data with lifetime `'a`... @@ -72,12 +72,12 @@ LL | MyTrait::use_self(val) | ^^^ ...is used here... | note: ...and is required to live as long as `'static` here - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:108:9 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:113:9 | LL | MyTrait::use_self(val) | ^^^^^^^^^^^^^^^^^ note: the used `impl` has a `'static` requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:104:26 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:109:26 | LL | fn use_self(&self) -> &() { panic!() } | -------- calling this method introduces the `impl`'s 'static` requirement @@ -90,7 +90,7 @@ LL | impl MyTrait for dyn ObjectTrait + '_ {} | ++++ error[E0772]: `val` has lifetime `'a` but calling `use_self` introduces an implicit `'static` lifetime requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:37:13 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:42:13 | LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> &'a () { | ------------------- this data with lifetime `'a`... @@ -98,7 +98,7 @@ LL | val.use_self() | ^^^^^^^^ ...is used and required to live as long as `'static` here | note: the used `impl` has a `'static` requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:31:26 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:36:26 | LL | impl MyTrait for dyn ObjectTrait { | ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement @@ -110,7 +110,7 @@ LL | impl MyTrait for dyn ObjectTrait + '_ { | ++++ error[E0772]: `val` has lifetime `'a` but calling `use_self` introduces an implicit `'static` lifetime requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:54:13 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:59:13 | LL | fn use_it<'a>(val: &'a Box) -> &'a () { | ----------------------------- this data with lifetime `'a`... @@ -118,7 +118,7 @@ LL | val.use_self() | ^^^^^^^^ ...is used and required to live as long as `'static` here | note: the used `impl` has a `'static` requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:48:30 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:53:30 | LL | impl MyTrait for Box { | ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.base.stderr similarity index 70% rename from src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr rename to src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.base.stderr index 5d195e5ff32..4e0e6675e5a 100644 --- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr +++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.base.stderr @@ -1,21 +1,21 @@ error[E0311]: the parameter type `T` may not live long enough - --> $DIR/missing-lifetimes-in-signature-2.rs:20:9 + --> $DIR/missing-lifetimes-in-signature-2.rs:24:9 | LL | foo.bar(move |_| { | ^^^ | note: the parameter type `T` must be valid for the anonymous lifetime defined here... - --> $DIR/missing-lifetimes-in-signature-2.rs:19:24 + --> $DIR/missing-lifetimes-in-signature-2.rs:23:24 | LL | fn func(foo: &Foo, t: T) { | ^^^ -note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature-2.rs:20:13: 23:6]` will meet its required lifetime bounds... - --> $DIR/missing-lifetimes-in-signature-2.rs:20:9 +note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature-2.rs:24:13: 27:6]` will meet its required lifetime bounds... + --> $DIR/missing-lifetimes-in-signature-2.rs:24:9 | LL | foo.bar(move |_| { | ^^^ note: ...that is required by this bound - --> $DIR/missing-lifetimes-in-signature-2.rs:11:12 + --> $DIR/missing-lifetimes-in-signature-2.rs:15:12 | LL | F: 'a, | ^^ diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.nll.stderr b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.nll.stderr index 0212c2d712c..9f35175c08d 100644 --- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.nll.stderr +++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.nll.stderr @@ -1,5 +1,5 @@ error[E0311]: the parameter type `T` may not live long enough - --> $DIR/missing-lifetimes-in-signature-2.rs:20:5 + --> $DIR/missing-lifetimes-in-signature-2.rs:24:5 | LL | / foo.bar(move |_| { LL | | @@ -8,12 +8,12 @@ LL | | }); | |______^ | note: the parameter type `T` must be valid for the anonymous lifetime defined here... - --> $DIR/missing-lifetimes-in-signature-2.rs:19:24 + --> $DIR/missing-lifetimes-in-signature-2.rs:23:24 | LL | fn func(foo: &Foo, t: T) { | ^^^ note: ...so that the type `T` will meet its required lifetime bounds - --> $DIR/missing-lifetimes-in-signature-2.rs:20:5 + --> $DIR/missing-lifetimes-in-signature-2.rs:24:5 | LL | / foo.bar(move |_| { LL | | diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.rs b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.rs index c6802ac6cc7..3e3b4403304 100644 --- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.rs +++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // Regression test for #81650 struct Foo<'a> { diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.base.stderr similarity index 81% rename from src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr rename to src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.base.stderr index ae9a020a099..d51d12b909d 100644 --- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr +++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.base.stderr @@ -1,5 +1,5 @@ error[E0261]: use of undeclared lifetime name `'a` - --> $DIR/missing-lifetimes-in-signature.rs:37:11 + --> $DIR/missing-lifetimes-in-signature.rs:42:11 | LL | fn baz(g: G, dest: &mut T) -> impl FnOnce() + '_ | - ^^ undeclared lifetime @@ -7,10 +7,10 @@ LL | fn baz(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 - --> $DIR/missing-lifetimes-in-signature.rs:19:5 + --> $DIR/missing-lifetimes-in-signature.rs:23:5 | LL | fn foo(g: G, dest: &mut T) -> impl FnOnce() - | ------ hidden type `[closure@$DIR/missing-lifetimes-in-signature.rs:19:5: 22:6]` captures the anonymous lifetime defined here + | ------ hidden type `[closure@$DIR/missing-lifetimes-in-signature.rs:23:5: 26:6]` captures the anonymous lifetime defined here ... LL | / move || { LL | | @@ -24,18 +24,18 @@ LL | fn foo(g: G, dest: &mut T) -> impl FnOnce() + '_ | ++++ error[E0311]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:26:37 + --> $DIR/missing-lifetimes-in-signature.rs:30:37 | LL | fn bar(g: G, dest: &mut T) -> impl FnOnce() + '_ | ^^^^^^^^^^^^^^^^^^ | note: the parameter type `G` must be valid for the anonymous lifetime defined here... - --> $DIR/missing-lifetimes-in-signature.rs:26:26 + --> $DIR/missing-lifetimes-in-signature.rs:30:26 | LL | fn bar(g: G, dest: &mut T) -> impl FnOnce() + '_ | ^^^^^^ -note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:31:5: 33:6]` will meet its required lifetime bounds - --> $DIR/missing-lifetimes-in-signature.rs:26:37 +note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:35:5: 38:6]` will meet its required lifetime bounds + --> $DIR/missing-lifetimes-in-signature.rs:30:37 | LL | fn bar(g: G, dest: &mut T) -> impl FnOnce() + '_ | ^^^^^^^^^^^^^^^^^^ @@ -48,18 +48,18 @@ LL ~ G: Get + 'a, | error[E0311]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:48:45 + --> $DIR/missing-lifetimes-in-signature.rs:53:45 | LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ | ^^^^^^^^^^^^^^^^^^ | note: the parameter type `G` must be valid for the anonymous lifetime defined here... - --> $DIR/missing-lifetimes-in-signature.rs:48:34 + --> $DIR/missing-lifetimes-in-signature.rs:53:34 | LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ | ^^^^^^ -note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:53:5: 55:6]` will meet its required lifetime bounds - --> $DIR/missing-lifetimes-in-signature.rs:48:45 +note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:58:5: 61:6]` will meet its required lifetime bounds + --> $DIR/missing-lifetimes-in-signature.rs:53:45 | LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ | ^^^^^^^^^^^^^^^^^^ @@ -69,18 +69,18 @@ LL | fn qux<'b, 'a, G: 'a + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + ' | +++ ++++ ++++ error[E0311]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:60:58 + --> $DIR/missing-lifetimes-in-signature.rs:66:58 | LL | fn qux<'b, G: Get + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ { | ^^^^^^^^^^^^^^^^^^ | note: the parameter type `G` must be valid for the anonymous lifetime defined here... - --> $DIR/missing-lifetimes-in-signature.rs:60:47 + --> $DIR/missing-lifetimes-in-signature.rs:66:47 | LL | fn qux<'b, G: Get + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ { | ^^^^^^ -note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:62:9: 64:10]` will meet its required lifetime bounds - --> $DIR/missing-lifetimes-in-signature.rs:60:58 +note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:68:9: 71:10]` will meet its required lifetime bounds + --> $DIR/missing-lifetimes-in-signature.rs:66:58 | LL | fn qux<'b, G: Get + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ { | ^^^^^^^^^^^^^^^^^^ @@ -90,7 +90,7 @@ LL | fn qux<'c, 'b, G: Get + 'b + 'c, T>(g: G, dest: &mut T) -> impl FnOn | +++ ++++ ++++ error[E0621]: explicit lifetime required in the type of `dest` - --> $DIR/missing-lifetimes-in-signature.rs:69:45 + --> $DIR/missing-lifetimes-in-signature.rs:76:45 | LL | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a | ------ ^^^^^^^^^^^^^^^^^^^^^^^ lifetime `'a` required @@ -98,10 +98,10 @@ LL | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a | help: add explicit lifetime `'a` to the type of `dest`: `&'a mut T` error[E0309]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:80:44 + --> $DIR/missing-lifetimes-in-signature.rs:89:44 | LL | fn bak<'a, G, T>(g: G, dest: &'a mut T) -> impl FnOnce() + 'a - | ^^^^^^^^^^^^^^^^^^ ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:85:5: 87:6]` will meet its required lifetime bounds + | ^^^^^^^^^^^^^^^^^^ ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:94:5: 97:6]` will meet its required lifetime bounds | help: consider adding an explicit lifetime bound... | diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.nll.stderr b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.nll.stderr index 24eac64d334..63932cb6ba0 100644 --- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.nll.stderr +++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.nll.stderr @@ -1,5 +1,5 @@ error[E0261]: use of undeclared lifetime name `'a` - --> $DIR/missing-lifetimes-in-signature.rs:37:11 + --> $DIR/missing-lifetimes-in-signature.rs:42:11 | LL | fn baz(g: G, dest: &mut T) -> impl FnOnce() + '_ | - ^^ undeclared lifetime @@ -7,10 +7,10 @@ LL | fn baz(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 - --> $DIR/missing-lifetimes-in-signature.rs:19:5 + --> $DIR/missing-lifetimes-in-signature.rs:23:5 | LL | fn foo(g: G, dest: &mut T) -> impl FnOnce() - | ------ hidden type `[closure@$DIR/missing-lifetimes-in-signature.rs:19:5: 22:6]` captures the anonymous lifetime defined here + | ------ hidden type `[closure@$DIR/missing-lifetimes-in-signature.rs:23:5: 26:6]` captures the anonymous lifetime defined here ... LL | / move || { LL | | @@ -24,22 +24,24 @@ LL | fn foo(g: G, dest: &mut T) -> impl FnOnce() + '_ | ++++ error[E0311]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:31:5 + --> $DIR/missing-lifetimes-in-signature.rs:35:5 | LL | / move || { +LL | | LL | | *dest = g.get(); LL | | } | |_____^ | note: the parameter type `G` must be valid for the anonymous lifetime defined here... - --> $DIR/missing-lifetimes-in-signature.rs:26:26 + --> $DIR/missing-lifetimes-in-signature.rs:30:26 | LL | fn bar(g: G, dest: &mut T) -> impl FnOnce() + '_ | ^^^^^^ note: ...so that the type `G` will meet its required lifetime bounds - --> $DIR/missing-lifetimes-in-signature.rs:31:5 + --> $DIR/missing-lifetimes-in-signature.rs:35:5 | LL | / move || { +LL | | LL | | *dest = g.get(); LL | | } | |_____^ @@ -49,22 +51,24 @@ LL | G: Get + 'a, | ++++ error[E0311]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:53:5 + --> $DIR/missing-lifetimes-in-signature.rs:58:5 | LL | / move || { +LL | | LL | | *dest = g.get(); LL | | } | |_____^ | note: the parameter type `G` must be valid for the anonymous lifetime defined here... - --> $DIR/missing-lifetimes-in-signature.rs:48:34 + --> $DIR/missing-lifetimes-in-signature.rs:53:34 | LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ | ^^^^^^ note: ...so that the type `G` will meet its required lifetime bounds - --> $DIR/missing-lifetimes-in-signature.rs:53:5 + --> $DIR/missing-lifetimes-in-signature.rs:58:5 | LL | / move || { +LL | | LL | | *dest = g.get(); LL | | } | |_____^ @@ -74,22 +78,24 @@ LL | fn qux<'a, G: 'a + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ | ++++ error[E0311]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:62:9 + --> $DIR/missing-lifetimes-in-signature.rs:68:9 | LL | / move || { +LL | | LL | | *dest = g.get(); LL | | } | |_________^ | note: the parameter type `G` must be valid for the anonymous lifetime defined here... - --> $DIR/missing-lifetimes-in-signature.rs:60:47 + --> $DIR/missing-lifetimes-in-signature.rs:66:47 | LL | fn qux<'b, G: Get + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ { | ^^^^^^ note: ...so that the type `G` will meet its required lifetime bounds - --> $DIR/missing-lifetimes-in-signature.rs:62:9 + --> $DIR/missing-lifetimes-in-signature.rs:68:9 | LL | / move || { +LL | | LL | | *dest = g.get(); LL | | } | |_________^ @@ -99,22 +105,26 @@ LL | fn qux<'b, G: Get + 'b + 'c, T>(g: G, dest: &mut T) -> impl FnOnce() | ++++ error[E0311]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:74:5 + --> $DIR/missing-lifetimes-in-signature.rs:81:5 | LL | / move || { +LL | | +LL | | LL | | *dest = g.get(); LL | | } | |_____^ | note: the parameter type `G` must be valid for the anonymous lifetime defined here... - --> $DIR/missing-lifetimes-in-signature.rs:69:34 + --> $DIR/missing-lifetimes-in-signature.rs:76:34 | LL | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a | ^^^^^^ note: ...so that the type `G` will meet its required lifetime bounds - --> $DIR/missing-lifetimes-in-signature.rs:74:5 + --> $DIR/missing-lifetimes-in-signature.rs:81:5 | LL | / move || { +LL | | +LL | | LL | | *dest = g.get(); LL | | } | |_____^ @@ -124,20 +134,23 @@ LL | fn bat<'a, G: 'a + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a | ++++ error[E0621]: explicit lifetime required in the type of `dest` - --> $DIR/missing-lifetimes-in-signature.rs:74:5 + --> $DIR/missing-lifetimes-in-signature.rs:81:5 | LL | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a | ------ help: add explicit lifetime `'a` to the type of `dest`: `&'a mut T` ... LL | / move || { +LL | | +LL | | LL | | *dest = g.get(); LL | | } | |_____^ lifetime `'a` required error[E0309]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:85:5 + --> $DIR/missing-lifetimes-in-signature.rs:94:5 | LL | / move || { +LL | | LL | | *dest = g.get(); LL | | } | |_____^ ...so that the type `G` will meet its required lifetime bounds diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs index 0a3e6b48163..20366201269 100644 --- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs +++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + pub trait Get { fn get(self) -> T; } @@ -24,11 +28,12 @@ where // After applying suggestion for `foo`: fn bar(g: G, dest: &mut T) -> impl FnOnce() + '_ -//~^ ERROR the parameter type `G` may not live long enough +//[base]~^ ERROR the parameter type `G` may not live long enough where G: Get, { move || { + //[nll]~^ ERROR the parameter type `G` may not live long enough *dest = g.get(); } } @@ -46,11 +51,12 @@ where // After applying suggestion for `baz`: fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ -//~^ ERROR the parameter type `G` may not live long enough +//[base]~^ ERROR the parameter type `G` may not live long enough where G: Get, { move || { + //[nll]~^ ERROR the parameter type `G` may not live long enough *dest = g.get(); } } @@ -58,8 +64,9 @@ where // Same as above, but show that we pay attention to lifetime names from parent item impl<'a> Foo { fn qux<'b, G: Get + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ { - //~^ ERROR the parameter type `G` may not live long enough + //[base]~^ ERROR the parameter type `G` may not live long enough move || { + //[nll]~^ ERROR the parameter type `G` may not live long enough *dest = g.get(); } } @@ -67,22 +74,25 @@ impl<'a> Foo { // After applying suggestion for `qux`: fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a -//~^ ERROR explicit lifetime required in the type of `dest` +//[base]~^ ERROR explicit lifetime required in the type of `dest` where G: Get, { move || { + //[nll]~^ ERROR the parameter type `G` may not live long enough + //[nll]~| ERROR explicit lifetime required *dest = g.get(); } } // Potential incorrect attempt: fn bak<'a, G, T>(g: G, dest: &'a mut T) -> impl FnOnce() + 'a -//~^ ERROR the parameter type `G` may not live long enough +//[base]~^ ERROR the parameter type `G` may not live long enough where G: Get, { move || { + //[nll]~^ ERROR the parameter type `G` may not live long enough *dest = g.get(); } } diff --git a/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.stderr b/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.base.stderr similarity index 90% rename from src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.stderr rename to src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.base.stderr index a5b50634c71..0bd7f289340 100644 --- a/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.stderr +++ b/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.base.stderr @@ -1,5 +1,5 @@ error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/trait-object-nested-in-impl-trait.rs:30:31 + --> $DIR/trait-object-nested-in-impl-trait.rs:35:31 | LL | fn iter(&self) -> impl Iterator> { | ----- this data with an anonymous lifetime `'_`... @@ -10,7 +10,7 @@ LL | remaining: self.0.iter(), | ...is used here... | note: ...and is required to live as long as `'static` here - --> $DIR/trait-object-nested-in-impl-trait.rs:27:23 + --> $DIR/trait-object-nested-in-impl-trait.rs:31:23 | LL | fn iter(&self) -> impl Iterator> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -24,7 +24,7 @@ LL | fn iter(&self) -> impl Iterator> { | ++++ error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/trait-object-nested-in-impl-trait.rs:41:31 + --> $DIR/trait-object-nested-in-impl-trait.rs:48:31 | LL | fn iter(&self) -> impl Iterator> + '_ { | ----- this data with an anonymous lifetime `'_`... @@ -35,7 +35,7 @@ LL | remaining: self.0.iter(), | ...is used here... | note: ...and is required to live as long as `'static` here - --> $DIR/trait-object-nested-in-impl-trait.rs:38:23 + --> $DIR/trait-object-nested-in-impl-trait.rs:44:23 | LL | fn iter(&self) -> impl Iterator> + '_ { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -45,7 +45,7 @@ LL | fn iter(&self) -> impl Iterator> + '_ { | ++++ error[E0759]: `self` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/trait-object-nested-in-impl-trait.rs:52:31 + --> $DIR/trait-object-nested-in-impl-trait.rs:61:31 | LL | fn iter<'a>(&'a self) -> impl Iterator> + 'a { | -------- this data with lifetime `'a`... @@ -56,7 +56,7 @@ LL | remaining: self.0.iter(), | ...is used here... | note: ...and is required to live as long as `'static` here - --> $DIR/trait-object-nested-in-impl-trait.rs:49:30 + --> $DIR/trait-object-nested-in-impl-trait.rs:57:30 | LL | fn iter<'a>(&'a self) -> impl Iterator> + 'a { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -66,7 +66,7 @@ LL | fn iter<'a>(&'a self) -> impl Iterator> + 'a { | ++++ error[E0759]: `self` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/trait-object-nested-in-impl-trait.rs:63:31 + --> $DIR/trait-object-nested-in-impl-trait.rs:74:31 | LL | fn iter<'a>(&'a self) -> impl Iterator> { | -------- this data with lifetime `'a`... @@ -77,7 +77,7 @@ LL | remaining: self.0.iter(), | ...is used here... | note: ...and is required to live as long as `'static` here - --> $DIR/trait-object-nested-in-impl-trait.rs:60:30 + --> $DIR/trait-object-nested-in-impl-trait.rs:70:30 | LL | fn iter<'a>(&'a self) -> impl Iterator> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.nll.stderr b/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.nll.stderr index 6c65e4f0175..989f18e7182 100644 --- a/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.nll.stderr +++ b/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.nll.stderr @@ -1,11 +1,13 @@ error: lifetime may not live long enough - --> $DIR/trait-object-nested-in-impl-trait.rs:28:9 + --> $DIR/trait-object-nested-in-impl-trait.rs:32:9 | LL | fn iter(&self) -> impl Iterator> { | - let's call the lifetime of this reference `'1` LL | / Iter { +LL | | LL | | current: None, LL | | remaining: self.0.iter(), +LL | | LL | | } | |_________^ returning this value requires that `'1` must outlive `'static` | @@ -19,13 +21,15 @@ LL | fn iter(&self) -> impl Iterator> { | ++++ error: lifetime may not live long enough - --> $DIR/trait-object-nested-in-impl-trait.rs:39:9 + --> $DIR/trait-object-nested-in-impl-trait.rs:45:9 | LL | fn iter(&self) -> impl Iterator> + '_ { | - let's call the lifetime of this reference `'1` LL | / Iter { +LL | | LL | | current: None, LL | | remaining: self.0.iter(), +LL | | LL | | } | |_________^ returning this value requires that `'1` must outlive `'static` | @@ -35,13 +39,15 @@ LL | fn iter(&self) -> impl Iterator> + '_ { | ++++ error: lifetime may not live long enough - --> $DIR/trait-object-nested-in-impl-trait.rs:50:9 + --> $DIR/trait-object-nested-in-impl-trait.rs:58:9 | LL | fn iter<'a>(&'a self) -> impl Iterator> + 'a { | -- lifetime `'a` defined here LL | / Iter { +LL | | LL | | current: None, LL | | remaining: self.0.iter(), +LL | | LL | | } | |_________^ returning this value requires that `'a` must outlive `'static` | @@ -51,13 +57,15 @@ LL | fn iter<'a>(&'a self) -> impl Iterator> + 'a { | ++++ error: lifetime may not live long enough - --> $DIR/trait-object-nested-in-impl-trait.rs:61:9 + --> $DIR/trait-object-nested-in-impl-trait.rs:71:9 | LL | fn iter<'a>(&'a self) -> impl Iterator> { | -- lifetime `'a` defined here LL | / Iter { +LL | | LL | | current: None, LL | | remaining: self.0.iter(), +LL | | LL | | } | |_________^ returning this value requires that `'a` must outlive `'static` | diff --git a/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.rs b/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.rs index d8446e58dbb..5d868a58c0f 100644 --- a/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.rs +++ b/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait Foo {} impl<'a, T: Foo> Foo for &'a T {} impl Foo for Box {} @@ -26,8 +30,10 @@ struct Bar(Vec>); impl Bar { fn iter(&self) -> impl Iterator> { Iter { + //[nll]~^ ERROR lifetime may not live long enough current: None, - remaining: self.0.iter(), //~ ERROR E0759 + remaining: self.0.iter(), + //[base]~^ ERROR E0759 } } } @@ -37,8 +43,10 @@ struct Baz(Vec>); impl Baz { fn iter(&self) -> impl Iterator> + '_ { Iter { + //[nll]~^ ERROR lifetime may not live long enough current: None, - remaining: self.0.iter(), //~ ERROR E0759 + remaining: self.0.iter(), + //[base]~^ ERROR E0759 } } } @@ -48,8 +56,10 @@ struct Bat(Vec>); impl Bat { fn iter<'a>(&'a self) -> impl Iterator> + 'a { Iter { + //[nll]~^ ERROR lifetime may not live long enough current: None, - remaining: self.0.iter(), //~ ERROR E0759 + remaining: self.0.iter(), + //[base]~^ ERROR E0759 } } } @@ -59,8 +69,10 @@ struct Ban(Vec>); impl Ban { fn iter<'a>(&'a self) -> impl Iterator> { Iter { + //[nll]~^ ERROR lifetime may not live long enough current: None, - remaining: self.0.iter(), //~ ERROR E0759 + remaining: self.0.iter(), + //[base]~^ ERROR E0759 } } } diff --git a/src/test/ui/suggestions/suggest-impl-trait-lifetime-nll.fixed b/src/test/ui/suggestions/suggest-impl-trait-lifetime-nll.fixed new file mode 100644 index 00000000000..c363cc2d0e1 --- /dev/null +++ b/src/test/ui/suggestions/suggest-impl-trait-lifetime-nll.fixed @@ -0,0 +1,24 @@ +// FIXME(nll): On NLL stabilization, this should be replace +// `suggest-impl-trait-lifetime.rs`. Compiletest has +// problems with rustfix and revisions. +// ignore-compare-mode-nll +// compile-flags: -Zborrowck=mir + +// run-rustfix + +use std::fmt::Debug; + +fn foo(d: impl Debug + 'static) { +//~^ HELP consider adding an explicit lifetime bound... + bar(d); +//~^ ERROR the parameter type `impl Debug` may not live long enough +//~| NOTE ...so that the type `impl Debug` will meet its required lifetime bounds +} + +fn bar(d: impl Debug + 'static) { + println!("{:?}", d) +} + +fn main() { + foo("hi"); +} diff --git a/src/test/ui/suggestions/suggest-impl-trait-lifetime-nll.rs b/src/test/ui/suggestions/suggest-impl-trait-lifetime-nll.rs new file mode 100644 index 00000000000..dd275f6630b --- /dev/null +++ b/src/test/ui/suggestions/suggest-impl-trait-lifetime-nll.rs @@ -0,0 +1,24 @@ +// FIXME(nll): On NLL stabilization, this should be replace +// `suggest-impl-trait-lifetime.rs`. Compiletest has +// problems with rustfix and revisions. +// ignore-compare-mode-nll +// compile-flags: -Zborrowck=mir + +// run-rustfix + +use std::fmt::Debug; + +fn foo(d: impl Debug) { +//~^ HELP consider adding an explicit lifetime bound... + bar(d); +//~^ ERROR the parameter type `impl Debug` may not live long enough +//~| NOTE ...so that the type `impl Debug` will meet its required lifetime bounds +} + +fn bar(d: impl Debug + 'static) { + println!("{:?}", d) +} + +fn main() { + foo("hi"); +} diff --git a/src/test/ui/suggestions/suggest-impl-trait-lifetime.nll.stderr b/src/test/ui/suggestions/suggest-impl-trait-lifetime-nll.stderr similarity index 89% rename from src/test/ui/suggestions/suggest-impl-trait-lifetime.nll.stderr rename to src/test/ui/suggestions/suggest-impl-trait-lifetime-nll.stderr index cf912f4aac2..41226fdf9fe 100644 --- a/src/test/ui/suggestions/suggest-impl-trait-lifetime.nll.stderr +++ b/src/test/ui/suggestions/suggest-impl-trait-lifetime-nll.stderr @@ -1,5 +1,5 @@ error[E0310]: the parameter type `impl Debug` may not live long enough - --> $DIR/suggest-impl-trait-lifetime.rs:7:5 + --> $DIR/suggest-impl-trait-lifetime-nll.rs:13:5 | LL | bar(d); | ^^^^^^ ...so that the type `impl Debug` will meet its required lifetime bounds diff --git a/src/test/ui/suggestions/suggest-impl-trait-lifetime.fixed b/src/test/ui/suggestions/suggest-impl-trait-lifetime.fixed index 65aab97d3d7..75ff26c0435 100644 --- a/src/test/ui/suggestions/suggest-impl-trait-lifetime.fixed +++ b/src/test/ui/suggestions/suggest-impl-trait-lifetime.fixed @@ -1,3 +1,8 @@ +// FIXME(nll): On NLL stabilization, this should be replaced by +// `suggest-impl-trait-lifetime-nll.rs`. Compiletest has +// problems with rustfix and revisions. +// ignore-compare-mode-nll + // run-rustfix use std::fmt::Debug; diff --git a/src/test/ui/suggestions/suggest-impl-trait-lifetime.rs b/src/test/ui/suggestions/suggest-impl-trait-lifetime.rs index fb1848d130f..b93fe103a4a 100644 --- a/src/test/ui/suggestions/suggest-impl-trait-lifetime.rs +++ b/src/test/ui/suggestions/suggest-impl-trait-lifetime.rs @@ -1,3 +1,8 @@ +// FIXME(nll): On NLL stabilization, this should be replaced by +// `suggest-impl-trait-lifetime-nll.rs`. Compiletest has +// problems with rustfix and revisions. +// ignore-compare-mode-nll + // run-rustfix use std::fmt::Debug; diff --git a/src/test/ui/suggestions/suggest-impl-trait-lifetime.stderr b/src/test/ui/suggestions/suggest-impl-trait-lifetime.stderr index 4a99c3a14d7..85f36ea78aa 100644 --- a/src/test/ui/suggestions/suggest-impl-trait-lifetime.stderr +++ b/src/test/ui/suggestions/suggest-impl-trait-lifetime.stderr @@ -1,11 +1,11 @@ error[E0310]: the parameter type `impl Debug` may not live long enough - --> $DIR/suggest-impl-trait-lifetime.rs:7:5 + --> $DIR/suggest-impl-trait-lifetime.rs:12:5 | LL | bar(d); | ^^^ ...so that the type `impl Debug` will meet its required lifetime bounds... | note: ...that is required by this bound - --> $DIR/suggest-impl-trait-lifetime.rs:12:24 + --> $DIR/suggest-impl-trait-lifetime.rs:17:24 | LL | fn bar(d: impl Debug + 'static) { | ^^^^^^^