rust/tests/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.stderr

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

156 lines
6.6 KiB
Plaintext
Raw Normal View History

2022-04-01 12:13:25 -05:00
error[E0521]: borrowed data escapes outside of function
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:21:9
|
LL | fn use_it<'a, T>(val: &'a dyn ObjectTrait<T>) -> impl OtherTrait<'a> + 'a {
2022-04-01 12:13:25 -05:00
| -- --- `val` is a reference that is only valid in the function body
| |
| lifetime `'a` defined here
LL | val.use_self::<T>()
2022-04-01 12:13:25 -05:00
| ^^^^^^^^^^^^^^^^^^^
| |
| `val` escapes the function body here
| argument requires that `'a` must outlive `'static`
|
note: the used `impl` has a `'static` requirement
2022-04-01 12:13:25 -05:00
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:15:32
2020-06-28 20:07:26 -05:00
|
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
2020-06-28 20:07:26 -05:00
help: consider relaxing the implicit `'static` requirement
|
LL | impl<T> MyTrait<T> for dyn ObjectTrait<T> + '_ {
| ++++
2022-04-01 12:13:25 -05:00
error[E0521]: borrowed data escapes outside of function
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:72:9
|
LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a {
2022-04-01 12:13:25 -05:00
| -- --- `val` is a reference that is only valid in the function body
| |
| lifetime `'a` defined here
LL | val.use_self()
2022-04-01 12:13:25 -05:00
| ^^^^^^^^^^^^^^
| |
| `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.rs:67:14
2020-06-28 20:07:26 -05:00
|
LL | impl dyn ObjectTrait {
| ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
2020-06-28 20:07:26 -05:00
LL | fn use_self(&self) -> &() { panic!() }
| -------- calling this method introduces the `impl`'s `'static` requirement
2020-06-28 20:07:26 -05:00
help: consider relaxing the implicit `'static` requirement
|
LL | impl dyn ObjectTrait + '_ {
| ++++
2022-04-01 12:13:25 -05:00
error[E0521]: borrowed data escapes outside of function
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:92:9
|
LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> {
2022-04-01 12:13:25 -05:00
| -- --- `val` is a reference that is only valid in the function body
| |
| lifetime `'a` defined here
LL | val.use_self()
2022-04-01 12:13:25 -05:00
| ^^^^^^^^^^^^^^
| |
| `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.rs:89: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 + '_ {}
| ++++
2022-04-01 12:13:25 -05:00
error[E0521]: borrowed data escapes outside of function
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:112:9
|
LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a {
2022-04-01 12:13:25 -05:00
| -- --- `val` is a reference that is only valid in the function body
| |
| lifetime `'a` defined here
LL | MyTrait::use_self(val)
2022-04-01 12:13:25 -05:00
| ^^^^^^^^^^^^^^^^^^^^^^
| |
| `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.rs:108: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.rs:38:9
|
LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> &'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-on-dyn-trait-with-implicit-static-bound.rs:32:26
|
LL | impl MyTrait for 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 MyTrait for dyn ObjectTrait + '_ {
| ++++
error[E0521]: borrowed data escapes outside of function
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:56:9
|
LL | fn use_it<'a>(val: &'a Box<dyn ObjectTrait + '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-on-dyn-trait-with-implicit-static-bound.rs:50:30
|
LL | impl MyTrait for Box<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 MyTrait for Box<dyn ObjectTrait + '_> {
| ++++
error: aborting due to 6 previous errors
2022-04-01 12:13:25 -05:00
For more information about this error, try `rustc --explain E0521`.