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
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
9 note: the used `impl` has a `'static` requirement
10 --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:14:32
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
18 LL | impl<T> MyTrait<T> for dyn ObjectTrait<T> + '_ {
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
24 LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a {
25 | ------------------- this data with lifetime `'a`...
27 | ^^^^^^^^ ...is used and required to live as long as `'static` here because of an implicit lifetime bound on the inherent `impl`
29 note: the used `impl` has a `'static` requirement
30 --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:64:14
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
38 LL | impl dyn ObjectTrait + '_ {
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
44 LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> {
45 | ------------------- this data with lifetime `'a`...
47 | ^^^^^^^^ ...is used and required to live as long as `'static` here
49 note: the used `impl` has a `'static` requirement
50 --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:85:26
52 LL | fn use_self(&self) -> &() { panic!() }
53 | -------- calling this method introduces the `impl`'s 'static` requirement
55 LL | impl MyTrait for dyn ObjectTrait {}
56 | ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
57 help: consider relaxing the implicit `'static` requirement
59 LL | impl MyTrait for dyn ObjectTrait + '_ {}
61 help: to declare that the `impl Trait` captures data from argument `val`, you can add an explicit `'a` lifetime bound
63 LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a {
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
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...
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
77 LL | MyTrait::use_self(val)
79 note: the used `impl` has a `'static` requirement
80 --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:104:26
82 LL | fn use_self(&self) -> &() { panic!() }
83 | -------- calling this method introduces the `impl`'s 'static` requirement
85 LL | impl MyTrait for dyn ObjectTrait {}
86 | ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
87 help: consider relaxing the implicit `'static` requirement
89 LL | impl MyTrait for dyn ObjectTrait + '_ {}
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
95 LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> &'a () {
96 | ------------------- this data with lifetime `'a`...
98 | ^^^^^^^^ ...is used and required to live as long as `'static` here
100 note: the used `impl` has a `'static` requirement
101 --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:31:26
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
109 LL | impl MyTrait for dyn ObjectTrait + '_ {
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
115 LL | fn use_it<'a>(val: &'a Box<dyn ObjectTrait + 'a>) -> &'a () {
116 | ----------------------------- this data with lifetime `'a`...
118 | ^^^^^^^^ ...is used and required to live as long as `'static` here
120 note: the used `impl` has a `'static` requirement
121 --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:48:30
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
129 LL | impl MyTrait for Box<dyn ObjectTrait + '_> {
132 error: aborting due to 6 previous errors
134 Some errors have detailed explanations: E0759, E0772.
135 For more information about an error, try `rustc --explain E0759`.