summaryrefslogtreecommitdiffstats
path: root/tests/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.stderr
blob: c77ef79e7ed18f47302360117013f27e7efeb2e5 (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
error: lifetime may not live long enough
  --> $DIR/trait-object-nested-in-impl-trait.rs:28:9
   |
LL |       fn iter(&self) -> impl Iterator<Item = Box<dyn Foo>> {
   |               - let's call the lifetime of this reference `'1`
LL | /         Iter {
LL | |
LL | |             current: None,
LL | |             remaining: self.0.iter(),
LL | |         }
   | |_________^ returning this value requires that `'1` must outlive `'static`
   |
help: to declare that `impl Iterator<Item = Box<(dyn Foo + 'static)>>` captures data from argument `self`, you can add an explicit `'_` lifetime bound
   |
LL |     fn iter(&self) -> impl Iterator<Item = Box<dyn Foo>> + '_ {
   |                                                          ++++
help: to declare that the trait object captures data from argument `self`, you can add an explicit `'_` lifetime bound
   |
LL |     fn iter(&self) -> impl Iterator<Item = Box<dyn Foo + '_>> {
   |                                                        ++++

error: lifetime may not live long enough
  --> $DIR/trait-object-nested-in-impl-trait.rs:40:9
   |
LL |       fn iter(&self) -> impl Iterator<Item = Box<dyn Foo>> + '_ {
   |               - let's call the lifetime of this reference `'1`
LL | /         Iter {
LL | |
LL | |             current: None,
LL | |             remaining: self.0.iter(),
LL | |         }
   | |_________^ returning this value requires that `'1` must outlive `'static`
   |
help: to declare that the trait object captures data from argument `self`, you can add an explicit `'_` lifetime bound
   |
LL |     fn iter(&self) -> impl Iterator<Item = Box<dyn Foo + '_>> + '_ {
   |                                                        ++++

error: lifetime may not live long enough
  --> $DIR/trait-object-nested-in-impl-trait.rs:52:9
   |
LL |       fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo>> + 'a {
   |               -- lifetime `'a` defined here
LL | /         Iter {
LL | |
LL | |             current: None,
LL | |             remaining: self.0.iter(),
LL | |         }
   | |_________^ returning this value requires that `'a` must outlive `'static`
   |
help: to declare that the trait object captures data from argument `self`, you can add an explicit `'a` lifetime bound
   |
LL |     fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo + 'a>> + 'a {
   |                                                               ++++

error: lifetime may not live long enough
  --> $DIR/trait-object-nested-in-impl-trait.rs:64:9
   |
LL |       fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo>> {
   |               -- lifetime `'a` defined here
LL | /         Iter {
LL | |
LL | |             current: None,
LL | |             remaining: self.0.iter(),
LL | |         }
   | |_________^ returning this value requires that `'a` must outlive `'static`
   |
help: to declare that `impl Iterator<Item = Box<(dyn Foo + 'static)>>` captures data from argument `self`, you can add an explicit `'a` lifetime bound
   |
LL |     fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo>> + 'a {
   |                                                                 ++++
help: to declare that the trait object captures data from argument `self`, you can add an explicit `'a` lifetime bound
   |
LL |     fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo + 'a>> {
   |                                                               ++++

error: aborting due to 4 previous errors