Skip to content

Commit

Permalink
Use revisions for NLL in suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
jackh726 committed May 22, 2022
1 parent b391b32 commit fe91cfd
Show file tree
Hide file tree
Showing 23 changed files with 330 additions and 93 deletions.
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
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`...
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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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() {}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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)]

Expand Down
Original file line number Diff line number Diff line change
@@ -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)]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
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`...
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
Expand All @@ -19,15 +19,15 @@ 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`...
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
Expand All @@ -39,15 +39,15 @@ 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`...
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
Expand All @@ -64,20 +64,20 @@ 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`...
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
Expand All @@ -90,15 +90,15 @@ 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`...
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
Expand All @@ -110,15 +110,15 @@ 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`...
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
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
| ^^
Expand Down
Loading

0 comments on commit fe91cfd

Please sign in to comment.