Use revisions for NLL in suggestions
This commit is contained in:
parent
b391b329f0
commit
fe91cfd684
23 changed files with 330 additions and 93 deletions
|
@ -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<dyn ObjectTrait<Assoc = i32> + '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<dyn ObjectTrait<Assoc = i32>> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
|
|
@ -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
|
||||
|
|
|
@ -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<dyn ObjectTrait<Assoc = i32> + 'a>) -> &'a () {
|
||||
val.use_self() //~ ERROR E0772
|
||||
val.use_self() //[base]~ ERROR E0772
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<T> {}
|
||||
trait MyTrait<T> {
|
||||
fn use_self<K>(&self) -> &();
|
||||
}
|
||||
trait Irrelevant {}
|
||||
|
||||
impl<T> MyTrait<T> for dyn ObjectTrait<T> {
|
||||
fn use_self<K>(&self) -> &() { panic!() }
|
||||
}
|
||||
impl<T> Irrelevant for dyn ObjectTrait<T> {}
|
||||
|
||||
fn use_it<'a, T>(val: &'a dyn ObjectTrait<T>) -> impl OtherTrait<'a> + 'a {
|
||||
val.use_self::<T>() //~ 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<dyn ObjectTrait> {
|
||||
fn use_self(&self) -> &() { panic!() }
|
||||
}
|
||||
impl Irrelevant for Box<dyn ObjectTrait> {}
|
||||
|
||||
fn use_it<'a>(val: &'a Box<dyn ObjectTrait + 'a>) -> &'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() {}
|
|
@ -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<T>) -> impl OtherTrait<'a> + 'a {
|
||||
| -- --- `val` is a reference that is only valid in the function body
|
||||
|
@ -12,7 +12,7 @@ LL | val.use_self::<T>()
|
|||
| 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
|
|
@ -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)]
|
||||
|
||||
|
|
|
@ -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)]
|
||||
|
||||
|
|
|
@ -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<T>) -> impl OtherTrait<'a> + 'a {
|
||||
| ---------------------- this data with lifetime `'a`...
|
||||
|
@ -7,7 +7,7 @@ LL | val.use_self::<T>()
|
|||
| ^^^^^^^^ ...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<T> MyTrait<T> for dyn ObjectTrait<T> {
|
||||
| ^^^^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
|
||||
|
@ -19,7 +19,7 @@ LL | impl<T> MyTrait<T> for dyn ObjectTrait<T> + '_ {
|
|||
| ++++
|
||||
|
||||
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<dyn ObjectTrait + 'a>) -> &'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<dyn ObjectTrait> {
|
||||
| ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
|
||||
|
|
|
@ -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<T: Test>(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,
|
||||
| ^^
|
|
@ -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<T: Test>(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 | |
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
// Regression test for #81650
|
||||
|
||||
struct Foo<'a> {
|
||||
|
|
|
@ -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: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
|
||||
| - ^^ undeclared lifetime
|
||||
|
@ -7,10 +7,10 @@ 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
|
||||
--> $DIR/missing-lifetimes-in-signature.rs:19:5
|
||||
--> $DIR/missing-lifetimes-in-signature.rs:23:5
|
||||
|
|
||||
LL | fn foo<G, T>(g: G, dest: &mut T) -> impl FnOnce()
|
||||
| ------ hidden type `[closure@$DIR/missing-lifetimes-in-signature.rs:19:5: 22:6]` captures the anonymous lifetime defined here
|
||||
| ------ 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, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
|
|||
| ++++
|
||||
|
||||
error[E0311]: the parameter type `G` may not live long enough
|
||||
--> $DIR/missing-lifetimes-in-signature.rs:26:37
|
||||
--> $DIR/missing-lifetimes-in-signature.rs:30:37
|
||||
|
|
||||
LL | fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the parameter type `G` must be valid for the anonymous lifetime defined here...
|
||||
--> $DIR/missing-lifetimes-in-signature.rs:26:26
|
||||
--> $DIR/missing-lifetimes-in-signature.rs:30:26
|
||||
|
|
||||
LL | fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
|
||||
| ^^^^^^
|
||||
note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs: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, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
@ -48,18 +48,18 @@ LL ~ G: Get<T> + '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<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ {
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the parameter type `G` must be valid for the anonymous lifetime defined here...
|
||||
--> $DIR/missing-lifetimes-in-signature.rs:60:47
|
||||
--> $DIR/missing-lifetimes-in-signature.rs:66:47
|
||||
|
|
||||
LL | fn qux<'b, G: Get<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ {
|
||||
| ^^^^^^
|
||||
note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs: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<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ {
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
@ -90,7 +90,7 @@ LL | fn qux<'c, 'b, G: Get<T> + '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...
|
||||
|
|
|
@ -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: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
|
||||
| - ^^ undeclared lifetime
|
||||
|
@ -7,10 +7,10 @@ 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
|
||||
--> $DIR/missing-lifetimes-in-signature.rs:19:5
|
||||
--> $DIR/missing-lifetimes-in-signature.rs:23:5
|
||||
|
|
||||
LL | fn foo<G, T>(g: G, dest: &mut T) -> impl FnOnce()
|
||||
| ------ hidden type `[closure@$DIR/missing-lifetimes-in-signature.rs:19:5: 22:6]` captures the anonymous lifetime defined here
|
||||
| ------ 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, 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: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, 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: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<T> + '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<T> + '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<T> + '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
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
pub trait Get<T> {
|
||||
fn get(self) -> T;
|
||||
}
|
||||
|
@ -24,11 +28,12 @@ where
|
|||
|
||||
// After applying suggestion for `foo`:
|
||||
fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
|
||||
//~^ ERROR the parameter type `G` may not live long enough
|
||||
//[base]~^ ERROR the parameter type `G` may not live long enough
|
||||
where
|
||||
G: Get<T>,
|
||||
{
|
||||
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<T>,
|
||||
{
|
||||
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<T> + '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<T>,
|
||||
{
|
||||
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<T>,
|
||||
{
|
||||
move || {
|
||||
//[nll]~^ ERROR the parameter type `G` may not live long enough
|
||||
*dest = g.get();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Item = Box<dyn Foo>> {
|
||||
| ----- 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<Item = Box<dyn Foo>> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -24,7 +24,7 @@ LL | fn iter(&self) -> impl Iterator<Item = Box<dyn Foo + '_>> {
|
|||
| ++++
|
||||
|
||||
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<Item = Box<dyn Foo>> + '_ {
|
||||
| ----- 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<Item = Box<dyn Foo>> + '_ {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -45,7 +45,7 @@ LL | fn iter(&self) -> impl Iterator<Item = Box<dyn Foo + '_>> + '_ {
|
|||
| ++++
|
||||
|
||||
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<Item = Box<dyn Foo>> + '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<Item = Box<dyn Foo>> + 'a {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -66,7 +66,7 @@ LL | fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo + 'a>> + '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<Item = Box<dyn Foo>> {
|
||||
| -------- 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<Item = Box<dyn Foo>> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
@ -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<Item = Box<dyn Foo>> {
|
||||
| - 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<Item = Box<dyn Foo + '_>> {
|
|||
| ++++
|
||||
|
||||
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<Item = Box<dyn Foo>> + '_ {
|
||||
| - 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<Item = Box<dyn Foo + '_>> + '_ {
|
|||
| ++++
|
||||
|
||||
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<Item = Box<dyn Foo>> + '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<Item = Box<dyn Foo + 'a>> + '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<Item = Box<dyn Foo>> {
|
||||
| -- 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`
|
||||
|
|
||||
|
|
|
@ -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<T: Foo + ?Sized> Foo for Box<T> {}
|
||||
|
@ -26,8 +30,10 @@ struct Bar(Vec<Box<dyn Foo>>);
|
|||
impl Bar {
|
||||
fn iter(&self) -> impl Iterator<Item = Box<dyn Foo>> {
|
||||
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<Box<dyn Foo>>);
|
|||
impl Baz {
|
||||
fn iter(&self) -> impl Iterator<Item = Box<dyn Foo>> + '_ {
|
||||
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<Box<dyn Foo>>);
|
|||
impl Bat {
|
||||
fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo>> + '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<Box<dyn Foo>>);
|
|||
impl Ban {
|
||||
fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo>> {
|
||||
Iter {
|
||||
//[nll]~^ ERROR lifetime may not live long enough
|
||||
current: None,
|
||||
remaining: self.0.iter(), //~ ERROR E0759
|
||||
remaining: self.0.iter(),
|
||||
//[base]~^ ERROR E0759
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
24
src/test/ui/suggestions/suggest-impl-trait-lifetime-nll.rs
Normal file
24
src/test/ui/suggestions/suggest-impl-trait-lifetime-nll.rs
Normal file
|
@ -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");
|
||||
}
|
|
@ -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
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
| ^^^^^^^
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue