From cfc7cf39610bd8bacf26226fa8b8ee2e895061f0 Mon Sep 17 00:00:00 2001 From: gaurikholkar Date: Fri, 25 Aug 2017 11:51:22 +0530 Subject: adding E0623 for LateBound regions --- .../compile-fail/associated-types-subtyping-1.rs | 4 ++-- .../region-lifetime-bounds-on-fns-where-clause.rs | 2 +- ...-multiple-lifetime-bounds-on-fns-where-clause.rs | 4 ++-- .../regions-free-region-ordering-caller.rs | 10 +++------- .../regions-infer-contravariance-due-to-decl.rs | 2 +- .../regions-infer-covariance-due-to-decl.rs | 2 +- .../compile-fail/regions-lifetime-bounds-on-fns.rs | 2 +- ...ontravariant-use-covariant-in-second-position.rs | 2 +- .../regions-variance-contravariant-use-covariant.rs | 2 +- .../regions-variance-covariant-use-contravariant.rs | 2 +- .../regions-variance-invariant-use-contravariant.rs | 2 +- src/test/compile-fail/variance-cell-is-invariant.rs | 2 +- .../ex3-both-anon-regions-earlybound-regions.rs | 21 +++++++++++++++++++++ .../ex3-both-anon-regions-earlybound-regions.stderr | 11 +++++++++++ .../ex3-both-anon-regions-latebound-regions.rs | 15 +++++++++++++++ .../ex3-both-anon-regions-latebound-regions.stderr | 10 ++++++++++ 16 files changed, 73 insertions(+), 20 deletions(-) create mode 100644 src/test/ui/lifetime-errors/ex3-both-anon-regions-earlybound-regions.rs create mode 100644 src/test/ui/lifetime-errors/ex3-both-anon-regions-earlybound-regions.stderr create mode 100644 src/test/ui/lifetime-errors/ex3-both-anon-regions-latebound-regions.rs create mode 100644 src/test/ui/lifetime-errors/ex3-both-anon-regions-latebound-regions.stderr (limited to 'src/test') diff --git a/src/test/compile-fail/associated-types-subtyping-1.rs b/src/test/compile-fail/associated-types-subtyping-1.rs index f9106ba3960..64dcdd39e7c 100644 --- a/src/test/compile-fail/associated-types-subtyping-1.rs +++ b/src/test/compile-fail/associated-types-subtyping-1.rs @@ -31,7 +31,7 @@ fn method2<'a,'b,T>(x: &'a T, y: &'b T) // Note that &'static T <: &'a T. let a: >::Type = loop { }; let b: >::Type = loop { }; - let _: >::Type = a; //~ ERROR mismatched types + let _: >::Type = a; //~ ERROR E0623 } fn method3<'a,'b,T>(x: &'a T, y: &'b T) @@ -40,7 +40,7 @@ fn method3<'a,'b,T>(x: &'a T, y: &'b T) // Note that &'static T <: &'a T. let a: >::Type = loop { }; let b: >::Type = loop { }; - let _: >::Type = b; //~ ERROR mismatched types + let _: >::Type = b; //~ ERROR E0623 } fn method4<'a,'b,T>(x: &'a T, y: &'b T) diff --git a/src/test/compile-fail/region-lifetime-bounds-on-fns-where-clause.rs b/src/test/compile-fail/region-lifetime-bounds-on-fns-where-clause.rs index 6364db1f4b4..f886c0255cc 100644 --- a/src/test/compile-fail/region-lifetime-bounds-on-fns-where-clause.rs +++ b/src/test/compile-fail/region-lifetime-bounds-on-fns-where-clause.rs @@ -15,7 +15,7 @@ fn a<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) where 'b: 'a { fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) { // Illegal now because there is no `'b:'a` declaration. - *x = *y; //~ ERROR E0312 + *x = *y; //~ ERROR E0623 } fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) { diff --git a/src/test/compile-fail/region-multiple-lifetime-bounds-on-fns-where-clause.rs b/src/test/compile-fail/region-multiple-lifetime-bounds-on-fns-where-clause.rs index 154135eba38..bae9608c3f0 100644 --- a/src/test/compile-fail/region-multiple-lifetime-bounds-on-fns-where-clause.rs +++ b/src/test/compile-fail/region-multiple-lifetime-bounds-on-fns-where-clause.rs @@ -16,8 +16,8 @@ fn a<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) where fn b<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { // Illegal now because there is no `'b:'a` declaration. - *x = *y; //~ ERROR E0312 - *z = *y; //~ ERROR E0312 + *x = *y; //~ ERROR E0623 + *z = *y; //~ ERROR E0623 } fn c<'a,'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { diff --git a/src/test/compile-fail/regions-free-region-ordering-caller.rs b/src/test/compile-fail/regions-free-region-ordering-caller.rs index edca3b7ed41..66b16744cc7 100644 --- a/src/test/compile-fail/regions-free-region-ordering-caller.rs +++ b/src/test/compile-fail/regions-free-region-ordering-caller.rs @@ -15,20 +15,16 @@ struct Paramd<'a> { x: &'a usize } fn call2<'a, 'b>(a: &'a usize, b: &'b usize) { - let z: Option<&'b &'a usize> = None; - //~^ ERROR reference has a longer lifetime than the data it references + let z: Option<&'b &'a usize> = None;//~ ERROR E0623 } fn call3<'a, 'b>(a: &'a usize, b: &'b usize) { let y: Paramd<'a> = Paramd { x: a }; - let z: Option<&'b Paramd<'a>> = None; - //~^ ERROR reference has a longer lifetime than the data it references + let z: Option<&'b Paramd<'a>> = None;//~ ERROR E0623 } fn call4<'a, 'b>(a: &'a usize, b: &'b usize) { - let z: Option<&'a &'b usize> = None; - //~^ ERROR reference has a longer lifetime than the data it references + let z: Option<&'a &'b usize> = None;//~ ERROR E0623 } - fn main() {} diff --git a/src/test/compile-fail/regions-infer-contravariance-due-to-decl.rs b/src/test/compile-fail/regions-infer-contravariance-due-to-decl.rs index b7ef19d1e3b..6e1c765724b 100644 --- a/src/test/compile-fail/regions-infer-contravariance-due-to-decl.rs +++ b/src/test/compile-fail/regions-infer-contravariance-due-to-decl.rs @@ -32,7 +32,7 @@ fn use_<'short,'long>(c: Contravariant<'short>, // 'short <= 'long, this would be true if the Contravariant type were // covariant with respect to its parameter 'a. - let _: Contravariant<'long> = c; //~ ERROR mismatched types + let _: Contravariant<'long> = c; //~ ERROR E0623 } fn main() {} diff --git a/src/test/compile-fail/regions-infer-covariance-due-to-decl.rs b/src/test/compile-fail/regions-infer-covariance-due-to-decl.rs index 0d3d9dacbd6..1ab8ba4439b 100644 --- a/src/test/compile-fail/regions-infer-covariance-due-to-decl.rs +++ b/src/test/compile-fail/regions-infer-covariance-due-to-decl.rs @@ -29,7 +29,7 @@ fn use_<'short,'long>(c: Covariant<'long>, // 'short <= 'long, this would be true if the Covariant type were // contravariant with respect to its parameter 'a. - let _: Covariant<'short> = c; //~ ERROR mismatched types + let _: Covariant<'short> = c; //~ ERROR E0623 } fn main() {} diff --git a/src/test/compile-fail/regions-lifetime-bounds-on-fns.rs b/src/test/compile-fail/regions-lifetime-bounds-on-fns.rs index 89254516ac6..ef1c58bf972 100644 --- a/src/test/compile-fail/regions-lifetime-bounds-on-fns.rs +++ b/src/test/compile-fail/regions-lifetime-bounds-on-fns.rs @@ -15,7 +15,7 @@ fn a<'a, 'b:'a>(x: &mut &'a isize, y: &mut &'b isize) { fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) { // Illegal now because there is no `'b:'a` declaration. - *x = *y; //~ ERROR E0312 + *x = *y; //~ ERROR E0623 } fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) { diff --git a/src/test/compile-fail/regions-variance-contravariant-use-covariant-in-second-position.rs b/src/test/compile-fail/regions-variance-contravariant-use-covariant-in-second-position.rs index a7ef3ec9ac1..1dfebd54ec3 100644 --- a/src/test/compile-fail/regions-variance-contravariant-use-covariant-in-second-position.rs +++ b/src/test/compile-fail/regions-variance-contravariant-use-covariant-in-second-position.rs @@ -32,7 +32,7 @@ fn use_<'short,'long>(c: S<'long, 'short>, // 'short <= 'long, this would be true if the Contravariant type were // covariant with respect to its parameter 'a. - let _: S<'long, 'long> = c; //~ ERROR mismatched types + let _: S<'long, 'long> = c; //~ ERROR E0623 } fn main() {} diff --git a/src/test/compile-fail/regions-variance-contravariant-use-covariant.rs b/src/test/compile-fail/regions-variance-contravariant-use-covariant.rs index a79249ade4f..caf6a86fc0b 100644 --- a/src/test/compile-fail/regions-variance-contravariant-use-covariant.rs +++ b/src/test/compile-fail/regions-variance-contravariant-use-covariant.rs @@ -30,7 +30,7 @@ fn use_<'short,'long>(c: Contravariant<'short>, // 'short <= 'long, this would be true if the Contravariant type were // covariant with respect to its parameter 'a. - let _: Contravariant<'long> = c; //~ ERROR mismatched types + let _: Contravariant<'long> = c; //~ ERROR E0623 } fn main() {} diff --git a/src/test/compile-fail/regions-variance-covariant-use-contravariant.rs b/src/test/compile-fail/regions-variance-covariant-use-contravariant.rs index f42b7027d9e..60dc3d94a2e 100644 --- a/src/test/compile-fail/regions-variance-covariant-use-contravariant.rs +++ b/src/test/compile-fail/regions-variance-covariant-use-contravariant.rs @@ -30,7 +30,7 @@ fn use_<'short,'long>(c: Covariant<'long>, // 'short <= 'long, this would be true if the Covariant type were // contravariant with respect to its parameter 'a. - let _: Covariant<'short> = c; //~ ERROR mismatched types + let _: Covariant<'short> = c; //~ ERROR E0623 } fn main() {} diff --git a/src/test/compile-fail/regions-variance-invariant-use-contravariant.rs b/src/test/compile-fail/regions-variance-invariant-use-contravariant.rs index 71023b26c27..96478fa5909 100644 --- a/src/test/compile-fail/regions-variance-invariant-use-contravariant.rs +++ b/src/test/compile-fail/regions-variance-invariant-use-contravariant.rs @@ -27,7 +27,7 @@ fn use_<'short,'long>(c: Invariant<'long>, // 'short <= 'long, this would be true if the Invariant type were // contravariant with respect to its parameter 'a. - let _: Invariant<'short> = c; //~ ERROR mismatched types + let _: Invariant<'short> = c; //~ ERROR E0623 } fn main() { } diff --git a/src/test/compile-fail/variance-cell-is-invariant.rs b/src/test/compile-fail/variance-cell-is-invariant.rs index b8a8f9ad91c..1ddbcf4ab84 100644 --- a/src/test/compile-fail/variance-cell-is-invariant.rs +++ b/src/test/compile-fail/variance-cell-is-invariant.rs @@ -21,7 +21,7 @@ fn use_<'short,'long>(c: Foo<'short>, s: &'short isize, l: &'long isize, _where:Option<&'short &'long ()>) { - let _: Foo<'long> = c; //~ ERROR mismatched types + let _: Foo<'long> = c; //~ ERROR E0623 } fn main() { diff --git a/src/test/ui/lifetime-errors/ex3-both-anon-regions-earlybound-regions.rs b/src/test/ui/lifetime-errors/ex3-both-anon-regions-earlybound-regions.rs new file mode 100644 index 00000000000..5d182008209 --- /dev/null +++ b/src/test/ui/lifetime-errors/ex3-both-anon-regions-earlybound-regions.rs @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +trait Foo<'a> {} +impl<'a, T> Foo<'a> for T {} + +fn baz<'a, 'b, T>(x: &mut Vec<&'a T>, y: &T) + where i32: Foo<'a>, + u32: Foo<'b> +{ + x.push(y); +} +fn main() { +let x = baz; +} diff --git a/src/test/ui/lifetime-errors/ex3-both-anon-regions-earlybound-regions.stderr b/src/test/ui/lifetime-errors/ex3-both-anon-regions-earlybound-regions.stderr new file mode 100644 index 00000000000..58f2cb94cec --- /dev/null +++ b/src/test/ui/lifetime-errors/ex3-both-anon-regions-earlybound-regions.stderr @@ -0,0 +1,11 @@ +error[E0623]: lifetime mismatch + --> $DIR/ex3-both-anon-regions-earlybound-regions.rs:17:12 + | +13 | fn baz<'a, 'b, T>(x: &mut Vec<&'a T>, y: &T) + | ----- -- these two types are declared with different lifetimes... +... +17 | x.push(y); + | ^ ...but data from `y` flows into `x` here + +error: aborting due to previous error + diff --git a/src/test/ui/lifetime-errors/ex3-both-anon-regions-latebound-regions.rs b/src/test/ui/lifetime-errors/ex3-both-anon-regions-latebound-regions.rs new file mode 100644 index 00000000000..5abfc983f88 --- /dev/null +++ b/src/test/ui/lifetime-errors/ex3-both-anon-regions-latebound-regions.rs @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn foo<'a,'b>(x: &mut Vec<&'a u8>, y: &'b u8) { + x.push(y); +} + +fn main() { } \ No newline at end of file diff --git a/src/test/ui/lifetime-errors/ex3-both-anon-regions-latebound-regions.stderr b/src/test/ui/lifetime-errors/ex3-both-anon-regions-latebound-regions.stderr new file mode 100644 index 00000000000..be628f226d3 --- /dev/null +++ b/src/test/ui/lifetime-errors/ex3-both-anon-regions-latebound-regions.stderr @@ -0,0 +1,10 @@ +error[E0623]: lifetime mismatch + --> $DIR/ex3-both-anon-regions-latebound-regions.rs:12:12 + | +11 | fn foo<'a,'b>(x: &mut Vec<&'a u8>, y: &'b u8) { + | ------ ------ these two types are declared with different lifetimes... +12 | x.push(y); + | ^ ...but data from `y` flows into `x` here + +error: aborting due to previous error + -- cgit 1.4.1-3-g733a5