1 error[E0521]: borrowed data escapes outside of function
2 --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:21:9
4 LL | fn use_it<'a, T>(val: &'a dyn ObjectTrait<T>) -> impl OtherTrait<'a> + 'a {
5 | -- --- `val` is a reference that is only valid in the function body
7 | lifetime `'a` defined here
8 LL | val.use_self::<T>()
11 | `val` escapes the function body here
12 | argument requires that `'a` must outlive `'static`
14 note: the used `impl` has a `'static` requirement
15 --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:15:32
17 LL | impl<T> MyTrait<T> for dyn ObjectTrait<T> {
18 | ^^^^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
19 LL | fn use_self<K>(&self) -> &() { panic!() }
20 | -------- calling this method introduces the `impl`'s 'static` requirement
21 help: consider relaxing the implicit `'static` requirement
23 LL | impl<T> MyTrait<T> for dyn ObjectTrait<T> + '_ {
26 error[E0521]: borrowed data escapes outside of function
27 --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:70:9
29 LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a {
30 | -- --- `val` is a reference that is only valid in the function body
32 | lifetime `'a` defined here
36 | `val` escapes the function body here
37 | argument requires that `'a` must outlive `'static`
39 note: the used `impl` has a `'static` requirement
40 --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:65:14
42 LL | impl dyn ObjectTrait {
43 | ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
44 LL | fn use_self(&self) -> &() { panic!() }
45 | -------- calling this method introduces the `impl`'s 'static` requirement
46 help: consider relaxing the implicit `'static` requirement
48 LL | impl dyn ObjectTrait + '_ {
51 error[E0521]: borrowed data escapes outside of function
52 --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:90:9
54 LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> {
55 | -- --- `val` is a reference that is only valid in the function body
57 | lifetime `'a` defined here
61 | `val` escapes the function body here
62 | argument requires that `'a` must outlive `'static`
64 note: the used `impl` has a `'static` requirement
65 --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:87:26
67 LL | fn use_self(&self) -> &() { panic!() }
68 | -------- calling this method introduces the `impl`'s 'static` requirement
70 LL | impl MyTrait for dyn ObjectTrait {}
71 | ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
72 help: consider relaxing the implicit `'static` requirement
74 LL | impl MyTrait for dyn ObjectTrait + '_ {}
77 error[E0521]: borrowed data escapes outside of function
78 --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:110:9
80 LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a {
81 | -- --- `val` is a reference that is only valid in the function body
83 | lifetime `'a` defined here
84 LL | MyTrait::use_self(val)
85 | ^^^^^^^^^^^^^^^^^^^^^^
87 | `val` escapes the function body here
88 | argument requires that `'a` must outlive `'static`
90 note: the used `impl` has a `'static` requirement
91 --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:106:26
93 LL | fn use_self(&self) -> &() { panic!() }
94 | -------- calling this method introduces the `impl`'s 'static` requirement
96 LL | impl MyTrait for dyn ObjectTrait {}
97 | ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
98 help: consider relaxing the implicit `'static` requirement
100 LL | impl MyTrait for dyn ObjectTrait + '_ {}
103 error: aborting due to 4 previous errors
105 For more information about this error, try `rustc --explain E0521`.