]> git.lizzy.rs Git - rust.git/blob - tests/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.stderr
Rollup merge of #107255 - lcnr:implied-b-hr, r=oli-obk
[rust.git] / tests / ui / suggestions / lifetimes / trait-object-nested-in-impl-trait.stderr
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`
12    |
13 help: to declare that `impl Iterator<Item = Box<(dyn Foo + 'static)>>` captures data from argument `self`, you can add an explicit `'_` lifetime bound
14    |
15 LL |     fn iter(&self) -> impl Iterator<Item = Box<dyn Foo>> + '_ {
16    |                                                          ++++
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 + '_>> {
20    |                                                        ++++
21
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`
33    |
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 + '_>> + '_ {
37    |                                                        ++++
38
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`
50    |
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 {
54    |                                                               ++++
55
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`
67    |
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
69    |
70 LL |     fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo>> + 'a {
71    |                                                                 ++++
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>> {
75    |                                                               ++++
76
77 error: aborting due to 4 previous errors
78