about summary refs log tree commit diff
path: root/tests/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.stderr
blob: 6effaf61099ecd6520e7bd8bbf7487b9688020cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
error[E0521]: borrowed data escapes outside of function
  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:21:9
   |
LL |     fn use_it<'a, T>(val: &'a dyn ObjectTrait<T>) -> impl OtherTrait<'a> + 'a {
   |               --     --- `val` is a reference that is only valid in the function body
   |               |
   |               lifetime `'a` defined here
LL |         val.use_self::<T>()
   |         ^^^^^^^^^^^^^^^^^^^
   |         |
   |         `val` escapes the function body here
   |         argument requires that `'a` must outlive `'static`
   |
note: the used `impl` has a `'static` requirement
  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:15:32
   |
LL |     impl<T> MyTrait<T> for dyn ObjectTrait<T> {
   |                                ^^^^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
LL |         fn use_self<K>(&self) -> &() { panic!() }
   |            -------- calling this method introduces the `impl`'s `'static` requirement
help: consider relaxing the implicit `'static` requirement
   |
LL |     impl<T> MyTrait<T> for dyn ObjectTrait<T> + '_ {
   |                                               ++++

error[E0521]: borrowed data escapes outside of function
  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:72:9
   |
LL |     fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a {
   |               --  --- `val` is a reference that is only valid in the function body
   |               |
   |               lifetime `'a` defined here
LL |         val.use_self()
   |         ^^^^^^^^^^^^^^
   |         |
   |         `val` escapes the function body here
   |         argument requires that `'a` must outlive `'static`
   |
note: the used `impl` has a `'static` requirement
  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:67:14
   |
LL |     impl dyn ObjectTrait {
   |              ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
LL |         fn use_self(&self) -> &() { panic!() }
   |            -------- calling this method introduces the `impl`'s `'static` requirement
help: consider relaxing the implicit `'static` requirement
   |
LL |     impl dyn ObjectTrait + '_ {
   |                          ++++

error[E0521]: borrowed data escapes outside of function
  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:92:9
   |
LL |     fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> {
   |               --  --- `val` is a reference that is only valid in the function body
   |               |
   |               lifetime `'a` defined here
LL |         val.use_self()
   |         ^^^^^^^^^^^^^^
   |         |
   |         `val` escapes the function body here
   |         argument requires that `'a` must outlive `'static`
   |
note: the used `impl` has a `'static` requirement
  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:89:26
   |
LL |         fn use_self(&self) -> &() { panic!() }
   |            -------- calling this method introduces the `impl`'s `'static` requirement
...
LL |     impl MyTrait for dyn ObjectTrait {}
   |                          ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
help: consider relaxing the implicit `'static` requirement
   |
LL |     impl MyTrait for dyn ObjectTrait + '_ {}
   |                                      ++++

error[E0521]: borrowed data escapes outside of function
  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:112:9
   |
LL |     fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a {
   |               --  --- `val` is a reference that is only valid in the function body
   |               |
   |               lifetime `'a` defined here
LL |         MyTrait::use_self(val)
   |         ^^^^^^^^^^^^^^^^^^^^^^
   |         |
   |         `val` escapes the function body here
   |         argument requires that `'a` must outlive `'static`
   |
note: the used `impl` has a `'static` requirement
  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:108:26
   |
LL |         fn use_self(&self) -> &() { panic!() }
   |            -------- calling this method introduces the `impl`'s `'static` requirement
...
LL |     impl MyTrait for dyn ObjectTrait {}
   |                          ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
help: consider relaxing the implicit `'static` requirement
   |
LL |     impl MyTrait for dyn ObjectTrait + '_ {}
   |                                      ++++

error[E0521]: borrowed data escapes outside of function
  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:38:9
   |
LL |     fn use_it<'a>(val: &'a dyn ObjectTrait) -> &'a () {
   |               --  --- `val` is a reference that is only valid in the function body
   |               |
   |               lifetime `'a` defined here
LL |         val.use_self()
   |         ^^^^^^^^^^^^^^
   |         |
   |         `val` escapes the function body here
   |         argument requires that `'a` must outlive `'static`
   |
note: the used `impl` has a `'static` requirement
  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:32:26
   |
LL |     impl MyTrait for dyn ObjectTrait {
   |                          ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
LL |         fn use_self(&self) -> &() { panic!() }
   |            -------- calling this method introduces the `impl`'s `'static` requirement
help: consider relaxing the implicit `'static` requirement
   |
LL |     impl MyTrait for dyn ObjectTrait + '_ {
   |                                      ++++

error[E0521]: borrowed data escapes outside of function
  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:56:9
   |
LL |     fn use_it<'a>(val: &'a Box<dyn ObjectTrait + 'a>) -> &'a () {
   |               --  --- `val` is a reference that is only valid in the function body
   |               |
   |               lifetime `'a` defined here
LL |         val.use_self()
   |         ^^^^^^^^^^^^^^
   |         |
   |         `val` escapes the function body here
   |         argument requires that `'a` must outlive `'static`
   |
note: the used `impl` has a `'static` requirement
  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:50:30
   |
LL |     impl MyTrait for Box<dyn ObjectTrait> {
   |                              ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
LL |         fn use_self(&self) -> &() { panic!() }
   |            -------- calling this method introduces the `impl`'s `'static` requirement
help: consider relaxing the implicit `'static` requirement
   |
LL |     impl MyTrait for Box<dyn ObjectTrait + '_> {
   |                                          ++++

error: aborting due to 6 previous errors

For more information about this error, try `rustc --explain E0521`.