]>
Commit | Line | Data |
---|---|---|
923072b8 FG |
1 | error: lifetime may not live long enough |
2 | --> $DIR/trait-object-nested-in-impl-trait.rs:28:9 | |
3 | | | |
4 | LL | fn iter(&self) -> impl Iterator<Item = Box<dyn Foo>> { | |
5 | | - let's call the lifetime of this reference `'1` | |
6 | LL | / Iter { | |
7 | LL | | | |
8 | LL | | current: None, | |
9 | LL | | remaining: self.0.iter(), | |
10 | LL | | } | |
11 | | |_________^ returning this value requires that `'1` must outlive `'static` | |
f035d41b | 12 | | |
2b03887a | 13 | help: to declare that `impl Iterator<Item = Box<(dyn Foo + 'static)>>` captures data from argument `self`, you can add an explicit `'_` lifetime bound |
f035d41b XL |
14 | | |
15 | LL | fn iter(&self) -> impl Iterator<Item = Box<dyn Foo>> + '_ { | |
94222f64 | 16 | | ++++ |
f035d41b XL |
17 | help: to declare that the trait object captures data from argument `self`, you can add an explicit `'_` lifetime bound |
18 | | | |
19 | LL | fn iter(&self) -> impl Iterator<Item = Box<dyn Foo + '_>> { | |
94222f64 | 20 | | ++++ |
f035d41b | 21 | |
923072b8 FG |
22 | error: lifetime may not live long enough |
23 | --> $DIR/trait-object-nested-in-impl-trait.rs:40:9 | |
24 | | | |
25 | LL | fn iter(&self) -> impl Iterator<Item = Box<dyn Foo>> + '_ { | |
26 | | - let's call the lifetime of this reference `'1` | |
27 | LL | / Iter { | |
28 | LL | | | |
29 | LL | | current: None, | |
30 | LL | | remaining: self.0.iter(), | |
31 | LL | | } | |
32 | | |_________^ returning this value requires that `'1` must outlive `'static` | |
f035d41b | 33 | | |
f035d41b XL |
34 | help: to declare that the trait object captures data from argument `self`, you can add an explicit `'_` lifetime bound |
35 | | | |
36 | LL | fn iter(&self) -> impl Iterator<Item = Box<dyn Foo + '_>> + '_ { | |
94222f64 | 37 | | ++++ |
f035d41b | 38 | |
923072b8 FG |
39 | error: lifetime may not live long enough |
40 | --> $DIR/trait-object-nested-in-impl-trait.rs:52:9 | |
41 | | | |
42 | LL | fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo>> + 'a { | |
43 | | -- lifetime `'a` defined here | |
44 | LL | / Iter { | |
45 | LL | | | |
46 | LL | | current: None, | |
47 | LL | | remaining: self.0.iter(), | |
48 | LL | | } | |
49 | | |_________^ returning this value requires that `'a` must outlive `'static` | |
f035d41b | 50 | | |
f035d41b XL |
51 | help: to declare that the trait object captures data from argument `self`, you can add an explicit `'a` lifetime bound |
52 | | | |
53 | LL | fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo + 'a>> + 'a { | |
94222f64 | 54 | | ++++ |
f035d41b | 55 | |
923072b8 FG |
56 | error: lifetime may not live long enough |
57 | --> $DIR/trait-object-nested-in-impl-trait.rs:64:9 | |
58 | | | |
59 | LL | fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo>> { | |
60 | | -- lifetime `'a` defined here | |
61 | LL | / Iter { | |
62 | LL | | | |
63 | LL | | current: None, | |
64 | LL | | remaining: self.0.iter(), | |
65 | LL | | } | |
66 | | |_________^ returning this value requires that `'a` must outlive `'static` | |
f035d41b | 67 | | |
2b03887a | 68 | help: to declare that `impl Iterator<Item = Box<(dyn Foo + 'static)>>` captures data from argument `self`, you can add an explicit `'a` lifetime bound |
f035d41b XL |
69 | | |
70 | LL | fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo>> + 'a { | |
94222f64 | 71 | | ++++ |
f035d41b XL |
72 | help: to declare that the trait object captures data from argument `self`, you can add an explicit `'a` lifetime bound |
73 | | | |
74 | LL | fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo + 'a>> { | |
94222f64 | 75 | | ++++ |
f035d41b XL |
76 | |
77 | error: aborting due to 4 previous errors | |
78 |