Fix rustup fallout: lifetimes false positives

This commit is contained in:
Manish Goregaokar 2015-09-30 20:10:54 +05:30
parent 4fc17e7faf
commit f76f4d52c2
2 changed files with 14 additions and 0 deletions

View file

@ -89,6 +89,9 @@ fn could_use_elision(func: &FnDecl, slf: Option<&ExplicitSelf>,
// extract lifetimes in input argument types // extract lifetimes in input argument types
for arg in &func.inputs { for arg in &func.inputs {
walk_ty(&mut input_visitor, &arg.ty); walk_ty(&mut input_visitor, &arg.ty);
if let TyRptr(None, _) = arg.ty.node {
input_visitor.record(&None);
}
} }
// extract lifetimes in output type // extract lifetimes in output type
if let Return(ref ty) = func.output { if let Return(ref ty) = func.output {
@ -181,6 +184,13 @@ impl<'v> Visitor<'v> for RefVisitor {
fn visit_lifetime(&mut self, lifetime: &'v Lifetime) { fn visit_lifetime(&mut self, lifetime: &'v Lifetime) {
self.record(&Some(*lifetime)); self.record(&Some(*lifetime));
} }
fn visit_ty(&mut self, ty: &'v Ty) {
if let TyRptr(None, _) = ty.node {
self.record(&None);
}
walk_ty(self, ty);
}
} }
/// Are any lifetimes mentioned in the `where` clause? If yes, we don't try to /// Are any lifetimes mentioned in the `where` clause? If yes, we don't try to

View file

@ -81,5 +81,9 @@ impl<'a> Foo<'a> {
fn self_bound_lifetime<'b: 'a>(&self, _: &'b u8) {} // no error, bounds exist fn self_bound_lifetime<'b: 'a>(&self, _: &'b u8) {} // no error, bounds exist
} }
fn already_elided<'a>(_: &u8, _: &'a u8) -> &'a u8 {
unimplemented!()
}
fn main() { fn main() {
} }