fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
4.5 KiB105 linesraw
1error[E0521]: borrowed data escapes outside of function
2  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:21:9
3   |
4LL |     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
8LL |         val.use_self::<T>()
9   |         ^^^^^^^^^^^^^^^^^^^
10   |         |
11   |         `val` escapes the function body here
12   |         argument requires that `'a` must outlive `'static`
13   |
14note: the used `impl` has a `'static` requirement
15  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:15:32
16   |
17LL |     impl<T> MyTrait<T> for dyn ObjectTrait<T> {
18   |                                ^^^^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
19LL |         fn use_self<K>(&self) -> &() { panic!() }
20   |            -------- calling this method introduces the `impl`'s `'static` requirement
21help: consider relaxing the implicit `'static` requirement
22   |
23LL |     impl<T> MyTrait<T> for dyn ObjectTrait<T> + '_ {
24   |                                               ++++
25
26error[E0521]: borrowed data escapes outside of function
27  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:70:9
28   |
29LL |     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
33LL |         val.use_self()
34   |         ^^^^^^^^^^^^^^
35   |         |
36   |         `val` escapes the function body here
37   |         argument requires that `'a` must outlive `'static`
38   |
39note: the used `impl` has a `'static` requirement
40  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:65:14
41   |
42LL |     impl dyn ObjectTrait {
43   |              ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
44LL |         fn use_self(&self) -> &() { panic!() }
45   |            -------- calling this method introduces the `impl`'s `'static` requirement
46help: consider relaxing the implicit `'static` requirement
47   |
48LL |     impl dyn ObjectTrait + '_ {
49   |                          ++++
50
51error[E0521]: borrowed data escapes outside of function
52  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:90:9
53   |
54LL |     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
58LL |         val.use_self()
59   |         ^^^^^^^^^^^^^^
60   |         |
61   |         `val` escapes the function body here
62   |         argument requires that `'a` must outlive `'static`
63   |
64note: the used `impl` has a `'static` requirement
65  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:87:26
66   |
67LL |         fn use_self(&self) -> &() { panic!() }
68   |            -------- calling this method introduces the `impl`'s `'static` requirement
69...
70LL |     impl MyTrait for dyn ObjectTrait {}
71   |                          ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
72help: consider relaxing the implicit `'static` requirement
73   |
74LL |     impl MyTrait for dyn ObjectTrait + '_ {}
75   |                                      ++++
76
77error[E0521]: borrowed data escapes outside of function
78  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:110:9
79   |
80LL |     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
84LL |         MyTrait::use_self(val)
85   |         ^^^^^^^^^^^^^^^^^^^^^^
86   |         |
87   |         `val` escapes the function body here
88   |         argument requires that `'a` must outlive `'static`
89   |
90note: the used `impl` has a `'static` requirement
91  --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:106:26
92   |
93LL |         fn use_self(&self) -> &() { panic!() }
94   |            -------- calling this method introduces the `impl`'s `'static` requirement
95...
96LL |     impl MyTrait for dyn ObjectTrait {}
97   |                          ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
98help: consider relaxing the implicit `'static` requirement
99   |
100LL |     impl MyTrait for dyn ObjectTrait + '_ {}
101   |                                      ++++
102
103error: aborting due to 4 previous errors
104
105For more information about this error, try `rustc --explain E0521`.