]> git.lizzy.rs Git - rust.git/blob - src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.stderr
Merge commit '0eff589afc83e21a03a168497bbab6b4dfbb4ef6' into clippyup
[rust.git] / src / test / ui / suggestions / impl-on-dyn-trait-with-implicit-static-bound.stderr
1 error[E0759]: `val` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
2   --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:20:13
3    |
4 LL |     fn use_it<'a, T>(val: &'a dyn ObjectTrait<T>) -> impl OtherTrait<'a> + 'a {
5    |                           ---------------------- this data with lifetime `'a`...
6 LL |         val.use_self::<T>()
7    |             ^^^^^^^^ ...is used and required to live as long as `'static` here
8    |
9 note: the used `impl` has a `'static` requirement
10   --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:14:32
11    |
12 LL |     impl<T> MyTrait<T> for dyn ObjectTrait<T> {
13    |                                ^^^^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
14 LL |         fn use_self<K>(&self) -> &() { panic!() }
15    |            -------- calling this method introduces the `impl`'s 'static` requirement
16 help: consider relaxing the implicit `'static` requirement
17    |
18 LL |     impl<T> MyTrait<T> for dyn ObjectTrait<T> + '_ {
19    |                                               ++++
20
21 error[E0772]: `val` has lifetime `'a` but calling `use_self` introduces an implicit `'static` lifetime requirement
22   --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:69:13
23    |
24 LL |     fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a {
25    |                        ------------------- this data with lifetime `'a`...
26 LL |         val.use_self()
27    |             ^^^^^^^^ ...is used and required to live as long as `'static` here because of an implicit lifetime bound on the inherent `impl`
28    |
29 note: the used `impl` has a `'static` requirement
30   --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:64:14
31    |
32 LL |     impl dyn ObjectTrait {
33    |              ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
34 LL |         fn use_self(&self) -> &() { panic!() }
35    |            -------- calling this method introduces the `impl`'s 'static` requirement
36 help: consider relaxing the implicit `'static` requirement
37    |
38 LL |     impl dyn ObjectTrait + '_ {
39    |                          ++++
40
41 error[E0759]: `val` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
42   --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:88:13
43    |
44 LL |     fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> {
45    |                        ------------------- this data with lifetime `'a`...
46 LL |         val.use_self()
47    |             ^^^^^^^^ ...is used and required to live as long as `'static` here
48    |
49 note: the used `impl` has a `'static` requirement
50   --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:85:26
51    |
52 LL |         fn use_self(&self) -> &() { panic!() }
53    |            -------- calling this method introduces the `impl`'s 'static` requirement
54 ...
55 LL |     impl MyTrait for dyn ObjectTrait {}
56    |                          ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
57 help: consider relaxing the implicit `'static` requirement
58    |
59 LL |     impl MyTrait for dyn ObjectTrait + '_ {}
60    |                                      ++++
61 help: to declare that the `impl Trait` captures data from argument `val`, you can add an explicit `'a` lifetime bound
62    |
63 LL |     fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a {
64    |                                                                    ++++
65
66 error[E0759]: `val` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
67   --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:108:27
68    |
69 LL |     fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a {
70    |                        ------------------- this data with lifetime `'a`...
71 LL |         MyTrait::use_self(val)
72    |                           ^^^ ...is used here...
73    |
74 note: ...and is required to live as long as `'static` here
75   --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:108:9
76    |
77 LL |         MyTrait::use_self(val)
78    |         ^^^^^^^^^^^^^^^^^
79 note: the used `impl` has a `'static` requirement
80   --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:104:26
81    |
82 LL |         fn use_self(&self) -> &() { panic!() }
83    |            -------- calling this method introduces the `impl`'s 'static` requirement
84 ...
85 LL |     impl MyTrait for dyn ObjectTrait {}
86    |                          ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
87 help: consider relaxing the implicit `'static` requirement
88    |
89 LL |     impl MyTrait for dyn ObjectTrait + '_ {}
90    |                                      ++++
91
92 error[E0772]: `val` has lifetime `'a` but calling `use_self` introduces an implicit `'static` lifetime requirement
93   --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:37:13
94    |
95 LL |     fn use_it<'a>(val: &'a dyn ObjectTrait) -> &'a () {
96    |                        ------------------- this data with lifetime `'a`...
97 LL |         val.use_self()
98    |             ^^^^^^^^ ...is used and required to live as long as `'static` here
99    |
100 note: the used `impl` has a `'static` requirement
101   --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:31:26
102    |
103 LL |     impl MyTrait for dyn ObjectTrait {
104    |                          ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
105 LL |         fn use_self(&self) -> &() { panic!() }
106    |            -------- calling this method introduces the `impl`'s 'static` requirement
107 help: consider relaxing the implicit `'static` requirement
108    |
109 LL |     impl MyTrait for dyn ObjectTrait + '_ {
110    |                                      ++++
111
112 error[E0772]: `val` has lifetime `'a` but calling `use_self` introduces an implicit `'static` lifetime requirement
113   --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:54:13
114    |
115 LL |     fn use_it<'a>(val: &'a Box<dyn ObjectTrait + 'a>) -> &'a () {
116    |                        ----------------------------- this data with lifetime `'a`...
117 LL |         val.use_self()
118    |             ^^^^^^^^ ...is used and required to live as long as `'static` here
119    |
120 note: the used `impl` has a `'static` requirement
121   --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:48:30
122    |
123 LL |     impl MyTrait for Box<dyn ObjectTrait> {
124    |                              ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
125 LL |         fn use_self(&self) -> &() { panic!() }
126    |            -------- calling this method introduces the `impl`'s 'static` requirement
127 help: consider relaxing the implicit `'static` requirement
128    |
129 LL |     impl MyTrait for Box<dyn ObjectTrait + '_> {
130    |                                          ++++
131
132 error: aborting due to 6 previous errors
133
134 For more information about this error, try `rustc --explain E0759`.