]> git.lizzy.rs Git - rust.git/commitdiff
Fix rustup fallout: lifetimes false positives
authorManish Goregaokar <manishsmail@gmail.com>
Wed, 30 Sep 2015 14:40:54 +0000 (20:10 +0530)
committerManish Goregaokar <manishsmail@gmail.com>
Wed, 30 Sep 2015 14:40:54 +0000 (20:10 +0530)
src/lifetimes.rs
tests/compile-fail/lifetimes.rs

index e39a41316a0339869a5851bd74a805db714a30a2..206424de9b58fd1a9dfcd33e427f9bbd69f2d9d3 100644 (file)
@@ -89,6 +89,9 @@ fn could_use_elision(func: &FnDecl, slf: Option<&ExplicitSelf>,
     // extract lifetimes in input argument types
     for arg in &func.inputs {
         walk_ty(&mut input_visitor, &arg.ty);
+        if let TyRptr(None, _) = arg.ty.node {
+            input_visitor.record(&None);
+        }
     }
     // extract lifetimes in output type
     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) {
         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
index 0b24ca65241e92fe5f7147b9dcfe6905d3513f69..a654c45237970f8737d08df61357fadf43b9c0f6 100755 (executable)
@@ -81,5 +81,9 @@ fn self_shared_lifetime(&self, _: &'a u8) {} // no error, lifetime 'a not define
     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() {
 }