about summary refs log tree commit diff
path: root/src/test/ui/lifetime-errors
diff options
context:
space:
mode:
authorgaurikholkar <f2013002@goa.bits-pilani.ac.in>2017-08-06 04:09:43 +0530
committergaurikholkar <f2013002@goa.bits-pilani.ac.in>2017-09-12 10:06:29 +0530
commit2f50c33290c81a548ea3237447cef0d1dbdc1a61 (patch)
tree184f7ccab5c16e1e47d0e235a233f9c8a45e71cd /src/test/ui/lifetime-errors
parent11f64d8f881a8bd994210efc1d3ff1982abf9df3 (diff)
Adding E0623 for structs
Diffstat (limited to 'src/test/ui/lifetime-errors')
-rw-r--r--src/test/ui/lifetime-errors/ex3-both-anon-regions-4.stderr18
-rw-r--r--src/test/ui/lifetime-errors/ex3-both-anon-regions-both-are-structs-4.rs19
-rw-r--r--src/test/ui/lifetime-errors/ex3-both-anon-regions-both-are-structs-4.stderr12
-rw-r--r--src/test/ui/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.rs4
-rw-r--r--src/test/ui/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.rs17
-rw-r--r--src/test/ui/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.stderr10
6 files changed, 80 insertions, 0 deletions
diff --git a/src/test/ui/lifetime-errors/ex3-both-anon-regions-4.stderr b/src/test/ui/lifetime-errors/ex3-both-anon-regions-4.stderr
new file mode 100644
index 00000000000..b159e147869
--- /dev/null
+++ b/src/test/ui/lifetime-errors/ex3-both-anon-regions-4.stderr
@@ -0,0 +1,18 @@
+error[E0623]: lifetime mismatch
+  --> $DIR/ex3-both-anon-regions-4.rs:12:13
+   |
+11 | fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) {
+   |                     ---                 --- these references are declared with different lifetimes...
+12 |     z.push((x,y));
+   |             ^ ...but data flows into `z` here
+
+error[E0623]: lifetime mismatch
+  --> $DIR/ex3-both-anon-regions-4.rs:12:15
+   |
+11 | fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) {
+   |                         ---                  --- these references are declared with different lifetimes...
+12 |     z.push((x,y));
+   |               ^ ...but data flows into `z` here
+
+error: aborting due to 2 previous errors
+
diff --git a/src/test/ui/lifetime-errors/ex3-both-anon-regions-both-are-structs-4.rs b/src/test/ui/lifetime-errors/ex3-both-anon-regions-both-are-structs-4.rs
new file mode 100644
index 00000000000..606e611865f
--- /dev/null
+++ b/src/test/ui/lifetime-errors/ex3-both-anon-regions-both-are-structs-4.rs
@@ -0,0 +1,19 @@
+// 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.
+struct Ref<'a, 'b> {
+    a: &'a u32,
+    b: &'b u32,
+}
+
+fn foo(mut x: Ref) {
+    x.a = x.b;
+}
+
+fn main() {}
diff --git a/src/test/ui/lifetime-errors/ex3-both-anon-regions-both-are-structs-4.stderr b/src/test/ui/lifetime-errors/ex3-both-anon-regions-both-are-structs-4.stderr
new file mode 100644
index 00000000000..2ef1cd507f1
--- /dev/null
+++ b/src/test/ui/lifetime-errors/ex3-both-anon-regions-both-are-structs-4.stderr
@@ -0,0 +1,12 @@
+error[E0623]: lifetime mismatch
+  --> $DIR/ex3-both-anon-regions-both-are-structs-4.rs:16:11
+   |
+15 | fn foo(mut x: Ref) {
+   |               ---
+   |               |
+   |               these two types are declared with different lifetimes...
+16 |     x.a = x.b;
+   |           ^^^ ...but data with one lifetime flows into the other here
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.rs b/src/test/ui/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.rs
index 4933dbb7e7a..5920eeed6b1 100644
--- a/src/test/ui/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.rs
+++ b/src/test/ui/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.rs
@@ -11,7 +11,11 @@
 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-one-is-struct-4.rs b/src/test/ui/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.rs
new file mode 100644
index 00000000000..4933dbb7e7a
--- /dev/null
+++ b/src/test/ui/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.rs
@@ -0,0 +1,17 @@
+// 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.
+
+struct Ref<'a, 'b> { a: &'a u32, b: &'b u32 }
+
+fn foo(mut y: Ref, x: &u32) {
+    y.b = x;
+}
+
+fn main() { }
diff --git a/src/test/ui/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.stderr b/src/test/ui/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.stderr
new file mode 100644
index 00000000000..40f026bcb1b
--- /dev/null
+++ b/src/test/ui/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.stderr
@@ -0,0 +1,10 @@
+error[E0623]: lifetime mismatch
+  --> $DIR/ex3-both-anon-regions-one-is-struct-4.rs:14:11
+   |
+13 | fn foo(mut y: Ref, x: &u32) {
+   |               ---     ---- these two types are declared with different lifetimes...
+14 |     y.b = x;
+   |           ^ ...but data from `x` flows into `y` here
+
+error: aborting due to previous error
+