| error[E0597]: `val` does not live long enough |
| --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:21:9 |
| | |
| LL | fn use_it<'a>(val: Box<dyn ObjectTrait<Assoc = i32>>) -> impl OtherTrait<'a> { |
| | -- lifetime `'a` defined here ------------------- opaque type requires that `val` is borrowed for `'a` |
| LL | val.use_self() |
| | ^^^ borrowed value does not live long enough |
| LL | } |
| | - `val` dropped here while still borrowed |
| | |
| help: you can add a bound to the opaque type to make it last less than `'static` and match `'a` |
| | |
| LL | fn use_it<'a>(val: Box<dyn ObjectTrait<Assoc = i32>>) -> impl OtherTrait<'a> + 'a { |
| | ++++ |
| |
| error[E0515]: cannot return value referencing function parameter `val` |
| --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:43:9 |
| | |
| LL | val.use_self() |
| | ---^^^^^^^^^^^ |
| | | |
| | returns a value referencing data owned by the current function |
| | `val` is borrowed here |
| |
| error[E0515]: cannot return value referencing function parameter `val` |
| --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:109:9 |
| | |
| LL | val.use_self() |
| | ---^^^^^^^^^^^ |
| | | |
| | returns a value referencing data owned by the current function |
| | `val` is borrowed here |
| |
| 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 |
| | |
| LL | fn use_it<'a>(val: Box<dyn ObjectTrait<Assoc = i32> + 'a>) -> &'a () { |
| | -------------------------------------- this data with lifetime `'a`... |
| LL | val.use_self() |
| | ^^^^^^^^ ...is captured 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 |
| | |
| LL | impl MyTrait for Box<dyn ObjectTrait<Assoc = i32>> { |
| | ^^^^^^^^^^^^^^^^^^^^^^^^ 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<Assoc = i32> + '_> { |
| | ++++ |
| |
| error: aborting due to 4 previous errors |
| |
| Some errors have detailed explanations: E0515, E0597. |
| For more information about an error, try `rustc --explain E0515`. |