Adding E0623, to detect missing lifetimes when both regions are anonymous

This commit is contained in:
gaurikholkar 2017-06-29 12:40:04 -07:00
parent 8a78a12a55
commit 4fb1808ab6
13 changed files with 462 additions and 125 deletions

View 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() { }

View 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

View 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() { }

View 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

View 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));
}

View 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

View 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() { }

View 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