Add more context to diagnostic

This commit is contained in:
Esteban Küber 2020-06-28 18:07:26 -07:00
parent 4e08bab87d
commit 6bac3dbfc2
2 changed files with 96 additions and 18 deletions

View file

@ -6,7 +6,14 @@ LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a {
LL | val.use_self()
| ^^^^^^^^ ...is captured and required to live as long as `'static` here
|
help: this `impl` introduces an implicit `'static` requirement, consider changing it
note: when using method `use_self` of trait `foo::MyTrait` on `foo::ObjectTrait`, an implicit `'static` requirement is introduced
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:14:26
|
LL | impl MyTrait for dyn ObjectTrait {
| ^^^^^^^^^^^ this trait object has an implicit `'static` lifetime requirement
LL | fn use_self(&self) -> &() { panic!() }
| -------- the `'static` requirement is introduced when calling this method
help: consider relaxing the implicit `'static` requirement
|
LL | impl MyTrait for dyn ObjectTrait + '_ {
| ^^^^
@ -19,7 +26,14 @@ LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a {
LL | val.use_self()
| ^^^^^^^^ ...is captured and required to live as long as `'static` here
|
help: this `impl` introduces an implicit `'static` requirement, consider changing it
note: when using method `use_self` on `bat::ObjectTrait`, an implicit `'static` requirement is introduced
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:64:14
|
LL | impl dyn ObjectTrait {
| ^^^^^^^^^^^ this trait object has an implicit `'static` lifetime requirement
LL | fn use_self(&self) -> &() { panic!() }
| -------- the `'static` requirement is introduced when calling this method
help: consider relaxing the implicit `'static` requirement
|
LL | impl dyn ObjectTrait + '_ {
| ^^^^
@ -32,7 +46,14 @@ LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> &'a () {
LL | val.use_self()
| ^^^^^^^^ ...is captured and required to live as long as `'static` here
|
help: this `impl` introduces an implicit `'static` requirement, consider changing it
note: when using method `use_self` of trait `bar::MyTrait` on `bar::ObjectTrait`, an implicit `'static` requirement is introduced
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:31:26
|
LL | impl MyTrait for dyn ObjectTrait {
| ^^^^^^^^^^^ this trait object has an implicit `'static` lifetime requirement
LL | fn use_self(&self) -> &() { panic!() }
| -------- the `'static` requirement is introduced when calling this method
help: consider relaxing the implicit `'static` requirement
|
LL | impl MyTrait for dyn ObjectTrait + '_ {
| ^^^^
@ -45,7 +66,14 @@ LL | fn use_it<'a>(val: &'a Box<dyn ObjectTrait + 'a>) -> &'a () {
LL | val.use_self()
| ^^^^^^^^ ...is captured and required to live as long as `'static` here
|
help: this `impl` introduces an implicit `'static` requirement, consider changing it
note: when using method `use_self` of trait `baz::MyTrait` on `baz::ObjectTrait`, an implicit `'static` requirement is introduced
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:48:30
|
LL | impl MyTrait for Box<dyn ObjectTrait> {
| ^^^^^^^^^^^ this trait object has an implicit `'static` lifetime requirement
LL | fn use_self(&self) -> &() { panic!() }
| -------- the `'static` requirement is introduced when calling this method
help: consider relaxing the implicit `'static` requirement
|
LL | impl MyTrait for Box<dyn ObjectTrait + '_> {
| ^^^^