Fix rustup fallout: lifetimes false positives
This commit is contained in:
parent
4fc17e7faf
commit
f76f4d52c2
|
@ -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
|
||||||
|
|
|
@ -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() {
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue