Adding E0623 for structs

This commit is contained in:
gaurikholkar 2017-08-06 04:09:43 +05:30
parent 11f64d8f88
commit 2f50c33290
8 changed files with 413 additions and 0 deletions

View file

@ -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

View file

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

View file

@ -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

View file

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

View file

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

View file

@ -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