]> git.lizzy.rs Git - rust.git/blob - tests/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.stderr
Rollup merge of #106670 - albertlarsan68:check-docs-in-pr-ci, r=Mark-Simulacrum
[rust.git] / tests / ui / suggestions / impl-on-dyn-trait-with-implicit-static-bound.stderr
1 error[E0521]: borrowed data escapes outside of function
2   --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:21:9
3    |
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
6    |               |
7    |               lifetime `'a` defined here
8 LL |         val.use_self::<T>()
9    |         ^^^^^^^^^^^^^^^^^^^
10    |         |
11    |         `val` escapes the function body here
12    |         argument requires that `'a` must outlive `'static`
13    |
14 note: the used `impl` has a `'static` requirement
15   --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:15:32
16    |
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
22    |
23 LL |     impl<T> MyTrait<T> for dyn ObjectTrait<T> + '_ {
24    |                                               ++++
25
26 error[E0521]: borrowed data escapes outside of function
27   --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:70:9
28    |
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
31    |               |
32    |               lifetime `'a` defined here
33 LL |         val.use_self()
34    |         ^^^^^^^^^^^^^^
35    |         |
36    |         `val` escapes the function body here
37    |         argument requires that `'a` must outlive `'static`
38    |
39 note: the used `impl` has a `'static` requirement
40   --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:65:14
41    |
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
47    |
48 LL |     impl dyn ObjectTrait + '_ {
49    |                          ++++
50
51 error[E0521]: borrowed data escapes outside of function
52   --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:90:9
53    |
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
56    |               |
57    |               lifetime `'a` defined here
58 LL |         val.use_self()
59    |         ^^^^^^^^^^^^^^
60    |         |
61    |         `val` escapes the function body here
62    |         argument requires that `'a` must outlive `'static`
63    |
64 note: the used `impl` has a `'static` requirement
65   --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:87:26
66    |
67 LL |         fn use_self(&self) -> &() { panic!() }
68    |            -------- calling this method introduces the `impl`'s 'static` requirement
69 ...
70 LL |     impl MyTrait for dyn ObjectTrait {}
71    |                          ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
72 help: consider relaxing the implicit `'static` requirement
73    |
74 LL |     impl MyTrait for dyn ObjectTrait + '_ {}
75    |                                      ++++
76
77 error[E0521]: borrowed data escapes outside of function
78   --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:110:9
79    |
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
82    |               |
83    |               lifetime `'a` defined here
84 LL |         MyTrait::use_self(val)
85    |         ^^^^^^^^^^^^^^^^^^^^^^
86    |         |
87    |         `val` escapes the function body here
88    |         argument requires that `'a` must outlive `'static`
89    |
90 note: the used `impl` has a `'static` requirement
91   --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:106:26
92    |
93 LL |         fn use_self(&self) -> &() { panic!() }
94    |            -------- calling this method introduces the `impl`'s 'static` requirement
95 ...
96 LL |     impl MyTrait for dyn ObjectTrait {}
97    |                          ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
98 help: consider relaxing the implicit `'static` requirement
99    |
100 LL |     impl MyTrait for dyn ObjectTrait + '_ {}
101    |                                      ++++
102
103 error: aborting due to 4 previous errors
104
105 For more information about this error, try `rustc --explain E0521`.