Adding E0623, to detect missing lifetimes when both regions are anonymous
This commit is contained in:
parent
8a78a12a55
commit
4fb1808ab6
13 changed files with 462 additions and 125 deletions
15
src/test/ui/lifetime-errors/ex3-both-anon-regions-2.rs
Normal file
15
src/test/ui/lifetime-errors/ex3-both-anon-regions-2.rs
Normal file
|
|
@ -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() { }
|
||||
10
src/test/ui/lifetime-errors/ex3-both-anon-regions-2.stderr
Normal file
10
src/test/ui/lifetime-errors/ex3-both-anon-regions-2.stderr
Normal file
|
|
@ -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
|
||||
|
||||
15
src/test/ui/lifetime-errors/ex3-both-anon-regions-3.rs
Normal file
15
src/test/ui/lifetime-errors/ex3-both-anon-regions-3.rs
Normal file
|
|
@ -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() { }
|
||||
10
src/test/ui/lifetime-errors/ex3-both-anon-regions-3.stderr
Normal file
10
src/test/ui/lifetime-errors/ex3-both-anon-regions-3.stderr
Normal file
|
|
@ -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
|
||||
|
||||
13
src/test/ui/lifetime-errors/ex3-both-anon-regions-4.rs
Normal file
13
src/test/ui/lifetime-errors/ex3-both-anon-regions-4.rs
Normal file
|
|
@ -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));
|
||||
}
|
||||
20
src/test/ui/lifetime-errors/ex3-both-anon-regions-4.stderr
Normal file
20
src/test/ui/lifetime-errors/ex3-both-anon-regions-4.stderr
Normal file
|
|
@ -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
|
||||
|
||||
15
src/test/ui/lifetime-errors/ex3-both-anon-regions.rs
Normal file
15
src/test/ui/lifetime-errors/ex3-both-anon-regions.rs
Normal file
|
|
@ -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() { }
|
||||
10
src/test/ui/lifetime-errors/ex3-both-anon-regions.stderr
Normal file
10
src/test/ui/lifetime-errors/ex3-both-anon-regions.stderr
Normal file
|
|
@ -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
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue