]> git.lizzy.rs Git - rust.git/commitdiff
add ui test for fn items, tidy fixes
authorgaurikholkar <f2013002@goa.bits-pilani.ac.in>
Tue, 12 Sep 2017 11:18:01 +0000 (16:48 +0530)
committergaurikholkar <f2013002@goa.bits-pilani.ac.in>
Tue, 12 Sep 2017 11:18:18 +0000 (16:48 +0530)
src/librustc/infer/error_reporting/different_lifetimes.rs
src/test/ui/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.rs
src/test/ui/lifetime-errors/ex3-both-anon-regions-using-fn-items.rs [new file with mode: 0644]
src/test/ui/lifetime-errors/ex3-both-anon-regions-using-fn-items.stderr [new file with mode: 0644]

index 9546d8a4dd2c8d3ecf9c05e61594eb25f0ea43c9..a54e75857dd918f0fd0565ed3c292c9eb5631747 100644 (file)
@@ -210,7 +210,7 @@ fn visit_ty(&mut self, arg: &'gcx hir::Ty) {
                 self.depth -= 1;
                 return;
             }
-            
+
             hir::TyRptr(ref lifetime, _) => {
                 // the lifetime of the TyRptr
                 let hir_id = self.infcx.tcx.hir.node_to_hir_id(lifetime.id);
index 5920eeed6b1d841950828f437546465e9a57c653..4933dbb7e7a7a2c3ec95ffb312fa34dcd9875ee4 100644 (file)
 struct Ref<'a, 'b> { a: &'a u32, b: &'b u32 }
 
 fn foo(mut y: Ref, x: &u32) {
-<<<<<<< HEAD
     y.b = x;
-=======
-    x = y.b;
->>>>>>> Adding E0623 for structs
 }
 
 fn main() { }
diff --git a/src/test/ui/lifetime-errors/ex3-both-anon-regions-using-fn-items.rs b/src/test/ui/lifetime-errors/ex3-both-anon-regions-using-fn-items.rs
new file mode 100644 (file)
index 0000000..9220c34
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+fn foo(x:fn(&u8, &u8), y: Vec<&u8>, z: &u8) {
+  y.push(z);
+}
+
+fn main() { }
diff --git a/src/test/ui/lifetime-errors/ex3-both-anon-regions-using-fn-items.stderr b/src/test/ui/lifetime-errors/ex3-both-anon-regions-using-fn-items.stderr
new file mode 100644 (file)
index 0000000..0913aba
--- /dev/null
@@ -0,0 +1,10 @@
+error[E0623]: lifetime mismatch
+  --> src/test/ui/lifetime-errors/ex3-both-anon-regions-using-fn-items.rs:11:10
+   |
+10 | fn foo(x:fn(&u8, &u8), y: Vec<&u8>, z: &u8) {
+   |                               ---      --- these two types are declared with different lifetimes...
+11 |   y.push(z);
+   |          ^ ...but data from `z` flows into `y` here
+
+error: aborting due to previous error
+