Closed
Description
Spawned off of issue #55850 and PR #56460
Consider code like this (it is issue-55850.rs from PR #56460):
#![allow(unused_mut)]
#![feature(generators, generator_trait)]
use std::ops::Generator;
use std::ops::GeneratorState::Yielded;
pub struct GenIter<G>(G);
impl <G> Iterator for GenIter<G>
where
G: Generator,
{
type Item = G::Yield;
fn next(&mut self) -> Option<Self::Item> {
unsafe {
match self.0.resume() {
Yielded(y) => Some(y),
_ => None
}
}
}
}
fn bug<'a>() -> impl Iterator<Item = &'a str> {
GenIter(move || {
let mut s = String::new();
yield &s[..]
})
}
fn main() {
bug();
}
Right now, AST-borrowck includes this note:
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 35:8...
--> $DIR/issue-55850.rs:35:8
|
LL | fn bug<'a>() -> impl Iterator<Item = &'a str> {
| ^^
but even after PR #56460 lands (fixing an ICE), NLL does not include such a note.