Closed
Description
I reduced a crater run failure of gluon_base
v0.8.0 to this standalone snippet:
#![feature(nll)]
use std::ops::Deref;
pub struct TypeFieldIterator<'a, T: 'a> {
typ: &'a T,
current: usize,
}
pub enum Type<Id, T> {
Unit,
Record(T),
ExtendRow {
types: Vec<(Id, T)>,
rest: T,
},
}
impl<'a, Id: 'a, T> Iterator for TypeFieldIterator<'a, T>
where
T: Deref<Target = Type<Id, T>>,
{
type Item = &'a (Id, T);
fn next(&mut self) -> Option<&'a (Id, T)> {
match **self.typ {
Type::Unit => None,
Type::Record(ref row) => {
self.typ = row;
self.next()
}
Type::ExtendRow { ref types, ref rest } => {
let current = self.current;
self.current += 1;
types.get(current).or_else(|| {
self.current = 0;
self.typ = rest;
self.next()
})
}
}
}
}
fn main() { }
this compiles without NLL; with NLL it fails with:
error[E0310]: the parameter type `Id` may not live long enough
--> src/main.rs:39:44
|
39 | types.get(current).or_else(|| {
| ____________________________________________^
40 | | self.current = 0;
41 | | self.typ = rest;
42 | | self.next()
43 | | })
| |_________________^
|
= help: consider adding an explicit lifetime bound `Id: 'static`...
I think this is some kind of failure from the "closure checking" code.