]> git.lizzy.rs Git - rust.git/blob - src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.stderr
2961d8d7eacc99a9a0e59b6c3dc0d115dc2092d8
[rust.git] / src / test / ui / suggestions / impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.stderr
1 error[E0515]: cannot return reference to function parameter `val`
2   --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:21:9
3    |
4 LL |         val.use_self()
5    |         ^^^^^^^^^^^^^^ returns a reference to data owned by the current function
6
7 error[E0515]: cannot return reference to function parameter `val`
8   --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:43:9
9    |
10 LL |         val.use_self()
11    |         ^^^^^^^^^^^^^^ returns a reference to data owned by the current function
12
13 error[E0515]: cannot return reference to function parameter `val`
14   --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:109:9
15    |
16 LL |         val.use_self()
17    |         ^^^^^^^^^^^^^^ returns a reference to data owned by the current function
18
19 error[E0772]: `val` has lifetime `'a` but calling `use_self` introduces an implicit `'static` lifetime requirement
20   --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:66:13
21    |
22 LL |     fn use_it<'a>(val: Box<dyn ObjectTrait<Assoc = i32> + 'a>) -> &'a () {
23    |                        -------------------------------------- this data with lifetime `'a`...
24 LL |         val.use_self()
25    |             ^^^^^^^^ ...is captured and required to live as long as `'static` here
26    |
27 note: the used `impl` has a `'static` requirement
28   --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:60:30
29    |
30 LL |     impl MyTrait for Box<dyn ObjectTrait<Assoc = i32>> {
31    |                              ^^^^^^^^^^^^^^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
32 LL |         fn use_self(&self) -> &() { panic!() }
33    |            -------- calling this method introduces the `impl`'s 'static` requirement
34 help: consider relaxing the implicit `'static` requirement
35    |
36 LL |     impl MyTrait for Box<dyn ObjectTrait<Assoc = i32> + '_> {
37    |                                                       ++++
38
39 error: aborting due to 4 previous errors
40
41 For more information about this error, try `rustc --explain E0515`.