Open
Description
struct Event;
struct Span;
impl Event {
fn span(&self) -> &Span {
&Span
}
}
impl Span {
fn fields(&self) -> impl '_ + Iterator<Item = (&'static str, &'_ str)> {
None.into_iter()
}
}
fn show_event<'a>(event: &'a Event) {
show_fields(event.span().fields());
}
fn show_fields<'a, 'data>(fields: impl 'a + Iterator<Item = (&'data str, &'data str)>) {
for (_name, _value) in fields {
todo!();
}
}
The current output is:
error[E0759]: `event` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
--> src/lib.rs:17:23
|
16 | fn show_event<'a>(event: &'a Event) {
| --------- this data with lifetime `'a`...
17 | show_fields(event.span().fields());
| ----- ^^^^
| |
| ...is captured here...
|
note: ...and is required to live as long as `'static` here
--> src/lib.rs:17:5
|
17 | show_fields(event.span().fields());
| ^^^^^^^^^^^
It's not immediately clear from this error where the 'static
bound is introduced, especially when not as reduced. I only noticed that the 'static
was probably being introduced by the APIT during reduction to file this issue.
It would be helpful to have a note/hint on the argument of the function that introduces the 'static bound. (And, as a side note, I'm not even sure if the 'static
bound can be eliminated.)
This was tested to be the output on 1.56.0-nightly (2021-09-01 50171c3).