diff options
| author | gaurikholkar <f2013002@goa.bits-pilani.ac.in> | 2017-06-29 12:40:04 -0700 |
|---|---|---|
| committer | gaurikholkar <f2013002@goa.bits-pilani.ac.in> | 2017-07-28 08:51:58 +0530 |
| commit | 4fb1808ab6e8a232be17ba3e74e27fa08bd4f28d (patch) | |
| tree | ac7b3ce3b56a50c3b9865542d36905c1e79c3222 /src/test/ui/lifetime-errors | |
| parent | 8a78a12a55621f22475dedacc0f6b42bff87a4c1 (diff) | |
Adding E0623, to detect missing lifetimes when both regions are anonymous
Diffstat (limited to 'src/test/ui/lifetime-errors')
8 files changed, 108 insertions, 0 deletions
diff --git a/src/test/ui/lifetime-errors/ex3-both-anon-regions-2.rs b/src/test/ui/lifetime-errors/ex3-both-anon-regions-2.rs new file mode 100644 index 00000000000..905eae18d18 --- /dev/null +++ b/src/test/ui/lifetime-errors/ex3-both-anon-regions-2.rs @@ -0,0 +1,15 @@ +// Copyright 2016 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((v, w): (&u8, &u8), x: &u8) { + v = x; +} + +fn main() { } diff --git a/src/test/ui/lifetime-errors/ex3-both-anon-regions-2.stderr b/src/test/ui/lifetime-errors/ex3-both-anon-regions-2.stderr new file mode 100644 index 00000000000..8dd906afdc4 --- /dev/null +++ b/src/test/ui/lifetime-errors/ex3-both-anon-regions-2.stderr @@ -0,0 +1,10 @@ +error[E0623]: lifetime mismatch + --> $DIR/ex3-both-anon-regions-2.rs:12:9 + | +11 | fn foo((v, w): (&u8, &u8), x: &u8) { + | --- --- these references must have the same lifetime +12 | v = x; + | ^ data from `x` flows here + +error: aborting due to previous error + diff --git a/src/test/ui/lifetime-errors/ex3-both-anon-regions-3.rs b/src/test/ui/lifetime-errors/ex3-both-anon-regions-3.rs new file mode 100644 index 00000000000..7bd5ebf805f --- /dev/null +++ b/src/test/ui/lifetime-errors/ex3-both-anon-regions-3.rs @@ -0,0 +1,15 @@ +// Copyright 2016 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((v, w): (&u8, &u8), (x, y): (&u8, &u8)) { + v = x; +} + +fn main() { } diff --git a/src/test/ui/lifetime-errors/ex3-both-anon-regions-3.stderr b/src/test/ui/lifetime-errors/ex3-both-anon-regions-3.stderr new file mode 100644 index 00000000000..66c3ca45499 --- /dev/null +++ b/src/test/ui/lifetime-errors/ex3-both-anon-regions-3.stderr @@ -0,0 +1,10 @@ +error[E0623]: lifetime mismatch + --> $DIR/ex3-both-anon-regions-3.rs:12:9 + | +11 | fn foo((v, w): (&u8, &u8), (x, y): (&u8, &u8)) { + | --- --- these references must have the same lifetime +12 | v = x; + | ^ data flows here + +error: aborting due to previous error + diff --git a/src/test/ui/lifetime-errors/ex3-both-anon-regions-4.rs b/src/test/ui/lifetime-errors/ex3-both-anon-regions-4.rs new file mode 100644 index 00000000000..fdb010a04f4 --- /dev/null +++ b/src/test/ui/lifetime-errors/ex3-both-anon-regions-4.rs @@ -0,0 +1,13 @@ +// Copyright 2016 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(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) { + z.push((x,y)); +} 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..b969797b374 --- /dev/null +++ b/src/test/ui/lifetime-errors/ex3-both-anon-regions-4.stderr @@ -0,0 +1,20 @@ +error[E0601]: main function not found + +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 must have the same lifetime +12 | z.push((x,y)); + | ^ 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 must have the same lifetime +12 | z.push((x,y)); + | ^ data flows into `z` here + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/lifetime-errors/ex3-both-anon-regions.rs b/src/test/ui/lifetime-errors/ex3-both-anon-regions.rs new file mode 100644 index 00000000000..9ebff511876 --- /dev/null +++ b/src/test/ui/lifetime-errors/ex3-both-anon-regions.rs @@ -0,0 +1,15 @@ +// Copyright 2016 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: &mut Vec<&u8>, y: &u8) { + x.push(y); +} + +fn main() { } diff --git a/src/test/ui/lifetime-errors/ex3-both-anon-regions.stderr b/src/test/ui/lifetime-errors/ex3-both-anon-regions.stderr new file mode 100644 index 00000000000..e38e2ef07ad --- /dev/null +++ b/src/test/ui/lifetime-errors/ex3-both-anon-regions.stderr @@ -0,0 +1,10 @@ +error[E0623]: lifetime mismatch + --> $DIR/ex3-both-anon-regions.rs:12:12 + | +11 | fn foo(x: &mut Vec<&u8>, y: &u8) { + | --- --- these references must have the same lifetime +12 | x.push(y); + | ^ data from `y` flows into `x` here + +error: aborting due to previous error + |
