-error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
- --> $DIR/trait-object-nested-in-impl-trait.rs:30:31
+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`
|
-LL | fn iter(&self) -> impl Iterator<Item = Box<dyn Foo>> {
- | ----- this data with an anonymous lifetime `'_`...
-...
-LL | remaining: self.0.iter(),
- | ------ ^^^^
- | |
- | ...is used here...
- |
-note: ...and is required to live as long as `'static` here
- --> $DIR/trait-object-nested-in-impl-trait.rs:27:23
- |
-LL | fn iter(&self) -> impl Iterator<Item = Box<dyn Foo>> {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: to declare that the `impl Trait` captures data from argument `self`, you can add an explicit `'_` lifetime bound
|
LL | fn iter(&self) -> impl Iterator<Item = Box<dyn Foo>> + '_ {
LL | fn iter(&self) -> impl Iterator<Item = Box<dyn Foo + '_>> {
| ++++
-error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
- --> $DIR/trait-object-nested-in-impl-trait.rs:41:31
- |
-LL | fn iter(&self) -> impl Iterator<Item = Box<dyn Foo>> + '_ {
- | ----- this data with an anonymous lifetime `'_`...
-...
-LL | remaining: self.0.iter(),
- | ------ ^^^^
- | |
- | ...is used here...
- |
-note: ...and is required to live as long as `'static` here
- --> $DIR/trait-object-nested-in-impl-trait.rs:38:23
+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`
|
-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[E0759]: `self` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
- --> $DIR/trait-object-nested-in-impl-trait.rs:52:31
+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`
|
-LL | fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo>> + 'a {
- | -------- this data with lifetime `'a`...
-...
-LL | remaining: self.0.iter(),
- | ------ ^^^^
- | |
- | ...is used here...
- |
-note: ...and is required to live as long as `'static` here
- --> $DIR/trait-object-nested-in-impl-trait.rs:49:30
- |
-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>> + 'a {
| ++++
-error[E0759]: `self` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
- --> $DIR/trait-object-nested-in-impl-trait.rs:63:31
- |
-LL | fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo>> {
- | -------- this data with lifetime `'a`...
-...
-LL | remaining: self.0.iter(),
- | ------ ^^^^
- | |
- | ...is used here...
- |
-note: ...and is required to live as long as `'static` here
- --> $DIR/trait-object-nested-in-impl-trait.rs:60:30
+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`
|
-LL | fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo>> {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: to declare that the `impl Trait` 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
-For more information about this error, try `rustc --explain E0759`.