summary refs log tree commit diff
path: root/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.stderr
blob: 55a1bbf18ab9fbfee2ad49631fbcf3dd7d0e07f7 (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
error[E0759]: `val` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:20:13
   |
LL |     fn use_it<'a, T>(val: &'a dyn ObjectTrait<T>) -> impl OtherTrait<'a> + 'a {
   |                           ---------------------- this data with lifetime `'a`...
LL |         val.use_self::<T>()
   |             ^^^^^^^^ ...is used and required to live as long as `'static` here
   |
note: the used `impl` has a `'static` requirement
  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:14: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[E0772]: `val` has lifetime `'a` but calling `use_self` introduces an implicit `'static` lifetime requirement
  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:69:13
   |
LL |     fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a {
   |                        ------------------- this data with lifetime `'a`...
LL |         val.use_self()
   |             ^^^^^^^^ ...is used and required to live as long as `'static` here because of an implicit lifetime bound on the inherent `impl`
   |
note: the used `impl` has a `'static` requirement
  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:64: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[E0759]: `val` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:88:13
   |
LL |     fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> {
   |                        ------------------- this data with lifetime `'a`...
LL |         val.use_self()
   |             ^^^^^^^^ ...is used and required to live as long as `'static` here
   |
note: the used `impl` has a `'static` requirement
  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:85: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 + '_ {}
   |                                      ++++
help: to declare that the `impl Trait` captures data from argument `val`, you can add an explicit `'a` lifetime bound
   |
LL |     fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a {
   |                                                                    ++++

error[E0759]: `val` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:108:27
   |
LL |     fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a {
   |                        ------------------- this data with lifetime `'a`...
LL |         MyTrait::use_self(val)
   |                           ^^^ ...is used here...
   |
note: ...and is required to live as long as `'static` here
  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:108:9
   |
LL |         MyTrait::use_self(val)
   |         ^^^^^^^^^^^^^^^^^
note: the used `impl` has a `'static` requirement
  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:104: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[E0772]: `val` has lifetime `'a` but calling `use_self` introduces an implicit `'static` lifetime requirement
  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:37:13
   |
LL |     fn use_it<'a>(val: &'a dyn ObjectTrait) -> &'a () {
   |                        ------------------- this data with lifetime `'a`...
LL |         val.use_self()
   |             ^^^^^^^^ ...is used and required to live as long as `'static` here
   |
note: the used `impl` has a `'static` requirement
  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:31: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[E0772]: `val` has lifetime `'a` but calling `use_self` introduces an implicit `'static` lifetime requirement
  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:54:13
   |
LL |     fn use_it<'a>(val: &'a Box<dyn ObjectTrait + 'a>) -> &'a () {
   |                        ----------------------------- this data with lifetime `'a`...
LL |         val.use_self()
   |             ^^^^^^^^ ...is used and required to live as long as `'static` here
   |
note: the used `impl` has a `'static` requirement
  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:48: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 E0759`.