Skip to content

Commit 157422a

Browse files
committed
Update test error messages based on changes to wfcheck; also, break
apart the tests that tested many things at once.
1 parent 2b2a113 commit 157422a

20 files changed

+231
-90
lines changed

src/test/compile-fail/issue-16747.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ trait ListItem<'a> {
1515
trait Collection { fn len(&self) -> usize; }
1616

1717
struct List<'a, T: ListItem<'a>> {
18+
slice: &'a [T]
1819
//~^ ERROR the parameter type `T` may not live long enough
1920
//~| HELP consider adding an explicit lifetime bound
2021
//~| NOTE ...so that the reference type `&'a [T]` does not outlive the data it points at
21-
slice: &'a [T]
2222
}
2323
impl<'a, T: ListItem<'a>> Collection for List<'a, T> {
2424
fn len(&self) -> usize {

src/test/compile-fail/issue-19380.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ impl Qiz for Foo {
1818
}
1919

2020
struct Bar {
21-
//~^ ERROR E0038
2221
foos: &'static [&'static (Qiz + 'static)]
2322
}
2423

2524
const FOO : Foo = Foo;
2625
const BAR : Bar = Bar { foos: &[&FOO]};
26+
//~^ ERROR E0038
2727

2828
fn main() { }

src/test/compile-fail/object-safety-issue-22040.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@ trait Expr: Debug + PartialEq {
1818

1919
//#[derive(PartialEq)]
2020
#[derive(Debug)]
21-
struct SExpr<'x> { //~ ERROR E0038
21+
struct SExpr<'x> {
2222
elements: Vec<Box<Expr+ 'x>>,
2323
}
2424

2525
impl<'x> PartialEq for SExpr<'x> {
2626
fn eq(&self, other:&SExpr<'x>) -> bool {
2727
println!("L1: {} L2: {}", self.elements.len(), other.elements.len());
28+
//~^ ERROR E0038
2829
let result = self.elements.len() == other.elements.len();
2930

3031
println!("Got compare {}", result);
@@ -43,8 +44,8 @@ impl <'x> Expr for SExpr<'x> {
4344
}
4445

4546
fn main() {
46-
let a: Box<Expr> = Box::new(SExpr::new());
47-
let b: Box<Expr> = Box::new(SExpr::new());
47+
let a: Box<Expr> = Box::new(SExpr::new()); //~ ERROR E0038
48+
let b: Box<Expr> = Box::new(SExpr::new()); //~ ERROR E0038
4849

49-
assert_eq!(a , b);
50+
// assert_eq!(a , b);
5051
}

src/test/compile-fail/regions-enum-not-wf.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,27 @@
1212

1313
#![allow(dead_code)]
1414

15-
enum Ref1<'a, T> { //~ ERROR the parameter type `T` may not live long enough
16-
Ref1Variant1(&'a T)
15+
enum Ref1<'a, T> {
16+
Ref1Variant1(&'a T) //~ ERROR the parameter type `T` may not live long enough
1717
}
1818

19-
enum Ref2<'a, T> { //~ ERROR the parameter type `T` may not live long enough
19+
enum Ref2<'a, T> {
2020
Ref2Variant1,
21-
Ref2Variant2(isize, &'a T),
21+
Ref2Variant2(isize, &'a T), //~ ERROR the parameter type `T` may not live long enough
2222
}
2323

2424
enum RefOk<'a, T:'a> {
2525
RefOkVariant1(&'a T)
2626
}
2727

2828
enum RefIndirect<'a, T> {
29-
//~^ ERROR the parameter type `T` may not live long enough
3029
RefIndirectVariant1(isize, RefOk<'a,T>)
30+
//~^ ERROR the parameter type `T` may not live long enough
3131
}
3232

3333
enum RefDouble<'a, 'b, T> {
34-
//~^ ERROR reference has a longer lifetime than the data
3534
RefDoubleVariant1(&'a &'b T)
35+
//~^ ERROR reference has a longer lifetime than the data
3636
}
3737

3838
fn main() { }

src/test/compile-fail/regions-outlives-nominal-type-struct.rs renamed to src/test/compile-fail/regions-outlives-nominal-type-enum-region-rev.rs

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,39 +16,12 @@
1616
#![feature(rustc_attrs)]
1717
#![allow(dead_code)]
1818

19-
mod variant_struct_region {
20-
struct Foo<'a> {
21-
x: &'a i32,
22-
}
23-
struct Bar<'a,'b> { //~ ERROR reference has a longer lifetime
24-
f: &'a Foo<'b>
25-
}
26-
}
27-
2819
mod rev_variant_struct_region {
2920
struct Foo<'a> {
3021
x: fn(&'a i32),
3122
}
32-
struct Bar<'a,'b> { //~ ERROR reference has a longer lifetime
33-
f: &'a Foo<'b>
34-
}
35-
}
36-
37-
mod variant_struct_type {
38-
struct Foo<T> {
39-
x: T
40-
}
41-
struct Bar<'a,'b> { //~ ERROR reference has a longer lifetime
42-
f: &'a Foo<&'b i32>
43-
}
44-
}
45-
46-
mod rev_variant_struct_type {
47-
struct Foo<T> {
48-
x: fn(T)
49-
}
50-
struct Bar<'a,'b> { //~ ERROR reference has a longer lifetime
51-
f: &'a Foo<&'b i32>
23+
enum Bar<'a,'b> {
24+
V(&'a Foo<'b>) //~ ERROR reference has a longer lifetime
5225
}
5326
}
5427

src/test/compile-fail/regions-outlives-nominal-type-enum.rs renamed to src/test/compile-fail/regions-outlives-nominal-type-enum-region.rs

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,39 +16,12 @@
1616
#![feature(rustc_attrs)]
1717
#![allow(dead_code)]
1818

19-
mod variant_enum_region {
20-
enum Foo<'a> {
21-
V { x: &'a i32 }
19+
mod variant_struct_region {
20+
struct Foo<'a> {
21+
x: &'a i32,
2222
}
23-
struct Bar<'a,'b> { //~ ERROR reference has a longer lifetime
24-
f: &'a Foo<'b>
25-
}
26-
}
27-
28-
mod rev_variant_enum_region {
29-
enum Foo<'a> {
30-
V { x: fn(&'a i32) }
31-
}
32-
struct Bar<'a,'b> { //~ ERROR reference has a longer lifetime
33-
f: &'a Foo<'b>
34-
}
35-
}
36-
37-
mod variant_enum_type {
38-
enum Foo<T> {
39-
V { x: T }
40-
}
41-
struct Bar<'a,'b> { //~ ERROR reference has a longer lifetime
42-
f: &'a Foo<&'b i32>
43-
}
44-
}
45-
46-
mod rev_variant_enum_type {
47-
enum Foo<T> {
48-
V { x: fn(T) }
49-
}
50-
struct Bar<'a,'b> { //~ ERROR reference has a longer lifetime
51-
f: &'a Foo<&'b i32>
23+
enum Bar<'a,'b> {
24+
V(&'a Foo<'b>) //~ ERROR reference has a longer lifetime
5225
}
5326
}
5427

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its
12+
// arguments (like `'a`) outlive `'b`.
13+
//
14+
// Rule OutlivesNominalType from RFC 1214.
15+
16+
#![feature(rustc_attrs)]
17+
#![allow(dead_code)]
18+
19+
mod rev_variant_struct_type {
20+
struct Foo<T> {
21+
x: fn(T)
22+
}
23+
enum Bar<'a,'b> {
24+
V(&'a Foo<&'b i32>) //~ ERROR reference has a longer lifetime
25+
}
26+
}
27+
28+
#[rustc_error]
29+
fn main() { }
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its
12+
// arguments (like `'a`) outlive `'b`.
13+
//
14+
// Rule OutlivesNominalType from RFC 1214.
15+
16+
#![feature(rustc_attrs)]
17+
#![allow(dead_code)]
18+
19+
mod variant_struct_type {
20+
struct Foo<T> {
21+
x: T
22+
}
23+
enum Bar<'a,'b> {
24+
F(&'a Foo<&'b i32>) //~ ERROR reference has a longer lifetime
25+
}
26+
}
27+
28+
#[rustc_error]
29+
fn main() { }
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its
12+
// arguments (like `'a`) outlive `'b`.
13+
//
14+
// Rule OutlivesNominalType from RFC 1214.
15+
16+
#![feature(rustc_attrs)]
17+
#![allow(dead_code)]
18+
19+
mod rev_variant_struct_region {
20+
struct Foo<'a> {
21+
x: fn(&'a i32),
22+
}
23+
struct Bar<'a,'b> {
24+
f: &'a Foo<'b> //~ ERROR reference has a longer lifetime
25+
}
26+
}
27+
28+
#[rustc_error]
29+
fn main() { }
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its
12+
// arguments (like `'a`) outlive `'b`.
13+
//
14+
// Rule OutlivesNominalType from RFC 1214.
15+
16+
#![feature(rustc_attrs)]
17+
#![allow(dead_code)]
18+
19+
mod variant_struct_region {
20+
struct Foo<'a> {
21+
x: &'a i32,
22+
}
23+
struct Bar<'a,'b> {
24+
f: &'a Foo<'b> //~ ERROR reference has a longer lifetime
25+
}
26+
}
27+
28+
#[rustc_error]
29+
fn main() { }
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its
12+
// arguments (like `'a`) outlive `'b`.
13+
//
14+
// Rule OutlivesNominalType from RFC 1214.
15+
16+
#![feature(rustc_attrs)]
17+
#![allow(dead_code)]
18+
19+
mod rev_variant_struct_type {
20+
struct Foo<T> {
21+
x: fn(T)
22+
}
23+
struct Bar<'a,'b> {
24+
f: &'a Foo<&'b i32> //~ ERROR reference has a longer lifetime
25+
}
26+
}
27+
28+
#[rustc_error]
29+
fn main() { }
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its
12+
// arguments (like `'a`) outlive `'b`.
13+
//
14+
// Rule OutlivesNominalType from RFC 1214.
15+
16+
#![feature(rustc_attrs)]
17+
#![allow(dead_code)]
18+
19+
mod variant_struct_type {
20+
struct Foo<T> {
21+
x: T
22+
}
23+
struct Bar<'a,'b> {
24+
f: &'a Foo<&'b i32> //~ ERROR reference has a longer lifetime
25+
}
26+
}
27+
28+
#[rustc_error]
29+
fn main() { }

src/test/compile-fail/regions-struct-not-wf.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@
1313
#![allow(dead_code)]
1414

1515
struct Ref<'a, T> {
16-
//~^ ERROR the parameter type `T` may not live long enough
1716
field: &'a T
17+
//~^ ERROR the parameter type `T` may not live long enough
1818
}
1919

2020
struct RefOk<'a, T:'a> {
2121
field: &'a T
2222
}
2323

2424
struct RefIndirect<'a, T> {
25-
//~^ ERROR the parameter type `T` may not live long enough
2625
field: RefOk<'a, T>
26+
//~^ ERROR the parameter type `T` may not live long enough
2727
}
2828

2929
struct DoubleRef<'a, 'b, T> {
30-
//~^ ERROR reference has a longer lifetime than the data it references
3130
field: &'a &'b T
31+
//~^ ERROR reference has a longer lifetime than the data it references
3232
}
3333

3434
fn main() { }

src/test/compile-fail/regions-wf-trait-object.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
trait TheTrait<'t>: 't { }
1515

1616
struct Foo<'a,'b> {
17-
//~^ ERROR lifetime bound not satisfied
1817
x: Box<TheTrait<'a>+'b>
18+
//~^ ERROR reference has a longer lifetime
1919
}
2020

2121
fn main() { }

0 commit comments

Comments
 (0)