bless existing test with compare-mode=nll and remove test

This commit is contained in:
b-naber 2022-05-23 09:50:32 +02:00
parent ca9d72540b
commit 99fa123f66
8 changed files with 66 additions and 237 deletions

View File

@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/project-fn-ret-invariant-nll.rs:63:5
--> $DIR/project-fn-ret-invariant-nll.rs:64:5
|
LL | fn transmute<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
| -- -- lifetime `'b` defined here
@ -15,7 +15,7 @@ LL | (a, b)
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error: lifetime may not live long enough
--> $DIR/project-fn-ret-invariant-nll.rs:63:5
--> $DIR/project-fn-ret-invariant-nll.rs:64:5
|
LL | fn transmute<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
| -- -- lifetime `'b` defined here

View File

@ -15,19 +15,19 @@ LL | let a = bar(f, x);
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error: lifetime may not live long enough
--> $DIR/project-fn-ret-invariant-nll.rs:47:13
--> $DIR/project-fn-ret-invariant-nll.rs:46:13
|
LL | fn baz<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
| -- -- lifetime `'b` defined here
| |
| lifetime `'a` defined here
...
LL | let b = bar(f, y);
LL | let f = foo; // <-- No consistent type can be inferred for `f` here.
LL | let a = bar(f, x);
| ^^^^^^^^^ argument requires that `'b` must outlive `'a`
|
= help: consider adding the following bound: `'b: 'a`
= note: requirement occurs because of the type `Type<'_>`, which makes the generic argument `'_` invariant
= note: the struct `Type<'a>` is invariant over the parameter `'a`
= note: requirement occurs because of a function pointer to `foo`
= note: the function `foo` is invariant over the parameter `'a`
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
help: `'a` and `'b` must be the same: replace one with the other

View File

@ -44,7 +44,8 @@ fn baz<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
fn baz<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
let f = foo; // <-- No consistent type can be inferred for `f` here.
let a = bar(f, x); //[oneuse]~ ERROR lifetime may not live long enough
let b = bar(f, y); //[oneuse]~ ERROR lifetime may not live long enough
//[oneuse]~^ ERROR lifetime may not live long enough
let b = bar(f, y);
(a, b)
}

View File

@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/project-fn-ret-invariant-nll.rs:56:5
--> $DIR/project-fn-ret-invariant-nll.rs:57:5
|
LL | fn baz<'a, 'b>(x: Type<'a>) -> Type<'static> {
| -- lifetime `'a` defined here

View File

@ -1,5 +1,5 @@
error[E0521]: borrowed data escapes outside of associated function
--> $DIR/issue-72312.rs:20:24
--> $DIR/issue-72312.rs:20:9
|
LL | pub async fn start(&self) {
| -----
@ -7,18 +7,17 @@ LL | pub async fn start(&self) {
| `self` is a reference that is only valid in the associated function body
| let's call the lifetime of this reference `'1`
...
LL | require_static(async move {
| ________________________^
LL | / require_static(async move {
LL | |
LL | |
LL | |
LL | |
LL | | &self;
LL | | });
| | ^
| | |
| |_________`self` escapes the associated function body here
| argument requires that `'1` must outlive `'static`
| | ^
| | |
| |__________`self` escapes the associated function body here
| argument requires that `'1` must outlive `'static`
error: aborting due to previous error

View File

@ -1,116 +0,0 @@
#![allow(dead_code)]
#![feature(nll)]
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 outside
}
}
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 outside
}
}
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 outside
}
}
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 outside
}
}
fn main() {}

View File

@ -1,105 +0,0 @@
error[E0521]: borrowed data escapes outside of function
--> $DIR/impl-dyn-trait-static-bound.rs:20: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
| |
| lifetime `'a` defined here
LL | val.use_self::<T>()
| ^^^^^^^^^^^^^^^^^^^
| |
| `val` escapes the function body here
| argument requires that `'a` must outlive `'static`
|
note: the used `impl` has a `'static` requirement
--> $DIR/impl-dyn-trait-static-bound.rs:14:32
|
LL | impl<T> MyTrait<T> for dyn ObjectTrait<T> {
| ^^^^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
LL | fn use_self<K>(&self) -> &() { panic!() }
| -------- calling this method introduces the `impl`'s 'static` requirement
help: consider relaxing the implicit `'static` requirement
|
LL | impl<T> MyTrait<T> for dyn ObjectTrait<T> + '_ {
| ++++
error[E0521]: borrowed data escapes outside of function
--> $DIR/impl-dyn-trait-static-bound.rs:70: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
| |
| lifetime `'a` defined here
LL | val.use_self()
| ^^^^^^^^^^^^^^
| |
| `val` escapes the function body here
| argument requires that `'a` must outlive `'static`
|
note: the used `impl` has a `'static` requirement
--> $DIR/impl-dyn-trait-static-bound.rs:65:14
|
LL | impl dyn ObjectTrait {
| ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
LL | fn use_self(&self) -> &() { panic!() }
| -------- calling this method introduces the `impl`'s 'static` requirement
help: consider relaxing the implicit `'static` requirement
|
LL | impl dyn ObjectTrait + '_ {
| ++++
error[E0521]: borrowed data escapes outside of function
--> $DIR/impl-dyn-trait-static-bound.rs:90: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
| |
| lifetime `'a` defined here
LL | val.use_self()
| ^^^^^^^^^^^^^^
| |
| `val` escapes the function body here
| argument requires that `'a` must outlive `'static`
|
note: the used `impl` has a `'static` requirement
--> $DIR/impl-dyn-trait-static-bound.rs:87:26
|
LL | fn use_self(&self) -> &() { panic!() }
| -------- calling this method introduces the `impl`'s 'static` requirement
...
LL | impl MyTrait for dyn ObjectTrait {}
| ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
help: consider relaxing the implicit `'static` requirement
|
LL | impl MyTrait for dyn ObjectTrait + '_ {}
| ++++
error[E0521]: borrowed data escapes outside of function
--> $DIR/impl-dyn-trait-static-bound.rs:111: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
| |
| lifetime `'a` defined here
LL | MyTrait::use_self(val)
| ^^^^^^^^^^^^^^^^^^^^^^
| |
| `val` escapes the function body here
| argument requires that `'a` must outlive `'static`
|
note: the used `impl` has a `'static` requirement
--> $DIR/impl-dyn-trait-static-bound.rs:107:26
|
LL | fn use_self(&self) -> &() { panic!() }
| -------- calling this method introduces the `impl`'s 'static` requirement
...
LL | impl MyTrait for dyn ObjectTrait {}
| ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
help: consider relaxing the implicit `'static` requirement
|
LL | impl MyTrait for dyn ObjectTrait + '_ {}
| ++++
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0521`.

View File

@ -10,6 +10,18 @@ LL | val.use_self::<T>()
| |
| `val` escapes the function body here
| argument requires that `'a` must outlive `'static`
|
note: the used `impl` has a `'static` requirement
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound-nll.rs:19:32
|
LL | impl<T> MyTrait<T> for dyn ObjectTrait<T> {
| ^^^^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
LL | fn use_self<K>(&self) -> &() { panic!() }
| -------- calling this method introduces the `impl`'s 'static` requirement
help: consider relaxing the implicit `'static` requirement
|
LL | impl<T> MyTrait<T> for dyn ObjectTrait<T> + '_ {
| ++++
error[E0521]: borrowed data escapes outside of function
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound-nll.rs:74:9
@ -23,6 +35,18 @@ LL | val.use_self()
| |
| `val` escapes the function body here
| argument requires that `'a` must outlive `'static`
|
note: the used `impl` has a `'static` requirement
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound-nll.rs:69:14
|
LL | impl dyn ObjectTrait {
| ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
LL | fn use_self(&self) -> &() { panic!() }
| -------- calling this method introduces the `impl`'s 'static` requirement
help: consider relaxing the implicit `'static` requirement
|
LL | impl dyn ObjectTrait + '_ {
| ++++
error[E0521]: borrowed data escapes outside of function
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound-nll.rs:94:9
@ -36,6 +60,19 @@ LL | val.use_self()
| |
| `val` escapes the function body here
| argument requires that `'a` must outlive `'static`
|
note: the used `impl` has a `'static` requirement
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound-nll.rs:91:26
|
LL | fn use_self(&self) -> &() { panic!() }
| -------- calling this method introduces the `impl`'s 'static` requirement
...
LL | impl MyTrait for dyn ObjectTrait {}
| ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
help: consider relaxing the implicit `'static` requirement
|
LL | impl MyTrait for dyn ObjectTrait + '_ {}
| ++++
error[E0521]: borrowed data escapes outside of function
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound-nll.rs:114:9
@ -49,6 +86,19 @@ LL | MyTrait::use_self(val)
| |
| `val` escapes the function body here
| argument requires that `'a` must outlive `'static`
|
note: the used `impl` has a `'static` requirement
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound-nll.rs:110:26
|
LL | fn use_self(&self) -> &() { panic!() }
| -------- calling this method introduces the `impl`'s 'static` requirement
...
LL | impl MyTrait for dyn ObjectTrait {}
| ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
help: consider relaxing the implicit `'static` requirement
|
LL | impl MyTrait for dyn ObjectTrait + '_ {}
| ++++
error: aborting due to 4 previous errors