diff --git a/src/test/compile-fail/issue-16747.rs b/src/test/compile-fail/issue-16747.rs index a3529c9ea90..dd7e8a869ec 100644 --- a/src/test/compile-fail/issue-16747.rs +++ b/src/test/compile-fail/issue-16747.rs @@ -15,10 +15,10 @@ trait ListItem<'a> { trait Collection { fn len(&self) -> usize; } struct List<'a, T: ListItem<'a>> { + slice: &'a [T] //~^ ERROR the parameter type `T` may not live long enough //~| HELP consider adding an explicit lifetime bound //~| NOTE ...so that the reference type `&'a [T]` does not outlive the data it points at - slice: &'a [T] } impl<'a, T: ListItem<'a>> Collection for List<'a, T> { fn len(&self) -> usize { diff --git a/src/test/compile-fail/issue-19380.rs b/src/test/compile-fail/issue-19380.rs index e24e6bbeb7b..aae77c90b6b 100644 --- a/src/test/compile-fail/issue-19380.rs +++ b/src/test/compile-fail/issue-19380.rs @@ -18,11 +18,11 @@ impl Qiz for Foo { } struct Bar { -//~^ ERROR E0038 foos: &'static [&'static (Qiz + 'static)] } const FOO : Foo = Foo; const BAR : Bar = Bar { foos: &[&FOO]}; +//~^ ERROR E0038 fn main() { } diff --git a/src/test/compile-fail/object-safety-issue-22040.rs b/src/test/compile-fail/object-safety-issue-22040.rs index f49ed42fe44..de419a259a2 100644 --- a/src/test/compile-fail/object-safety-issue-22040.rs +++ b/src/test/compile-fail/object-safety-issue-22040.rs @@ -18,13 +18,14 @@ trait Expr: Debug + PartialEq { //#[derive(PartialEq)] #[derive(Debug)] -struct SExpr<'x> { //~ ERROR E0038 +struct SExpr<'x> { elements: Vec>, } impl<'x> PartialEq for SExpr<'x> { fn eq(&self, other:&SExpr<'x>) -> bool { println!("L1: {} L2: {}", self.elements.len(), other.elements.len()); + //~^ ERROR E0038 let result = self.elements.len() == other.elements.len(); println!("Got compare {}", result); @@ -43,8 +44,8 @@ impl <'x> Expr for SExpr<'x> { } fn main() { - let a: Box = Box::new(SExpr::new()); - let b: Box = Box::new(SExpr::new()); + let a: Box = Box::new(SExpr::new()); //~ ERROR E0038 + let b: Box = Box::new(SExpr::new()); //~ ERROR E0038 - assert_eq!(a , b); + // assert_eq!(a , b); } diff --git a/src/test/compile-fail/regions-enum-not-wf.rs b/src/test/compile-fail/regions-enum-not-wf.rs index 3be99817872..e21f92bc9b8 100644 --- a/src/test/compile-fail/regions-enum-not-wf.rs +++ b/src/test/compile-fail/regions-enum-not-wf.rs @@ -12,13 +12,13 @@ #![allow(dead_code)] -enum Ref1<'a, T> { //~ ERROR the parameter type `T` may not live long enough - Ref1Variant1(&'a T) +enum Ref1<'a, T> { + Ref1Variant1(&'a T) //~ ERROR the parameter type `T` may not live long enough } -enum Ref2<'a, T> { //~ ERROR the parameter type `T` may not live long enough +enum Ref2<'a, T> { Ref2Variant1, - Ref2Variant2(isize, &'a T), + Ref2Variant2(isize, &'a T), //~ ERROR the parameter type `T` may not live long enough } enum RefOk<'a, T:'a> { @@ -26,13 +26,13 @@ enum RefOk<'a, T:'a> { } enum RefIndirect<'a, T> { - //~^ ERROR the parameter type `T` may not live long enough RefIndirectVariant1(isize, RefOk<'a,T>) + //~^ ERROR the parameter type `T` may not live long enough } enum RefDouble<'a, 'b, T> { - //~^ ERROR reference has a longer lifetime than the data RefDoubleVariant1(&'a &'b T) + //~^ ERROR reference has a longer lifetime than the data } fn main() { } diff --git a/src/test/compile-fail/regions-outlives-nominal-type-struct.rs b/src/test/compile-fail/regions-outlives-nominal-type-enum-region-rev.rs similarity index 56% rename from src/test/compile-fail/regions-outlives-nominal-type-struct.rs rename to src/test/compile-fail/regions-outlives-nominal-type-enum-region-rev.rs index fb3fdddae88..db25a0698fe 100644 --- a/src/test/compile-fail/regions-outlives-nominal-type-struct.rs +++ b/src/test/compile-fail/regions-outlives-nominal-type-enum-region-rev.rs @@ -16,39 +16,12 @@ #![feature(rustc_attrs)] #![allow(dead_code)] -mod variant_struct_region { - struct Foo<'a> { - x: &'a i32, - } - struct Bar<'a,'b> { //~ ERROR reference has a longer lifetime - f: &'a Foo<'b> - } -} - mod rev_variant_struct_region { struct Foo<'a> { x: fn(&'a i32), } - struct Bar<'a,'b> { //~ ERROR reference has a longer lifetime - f: &'a Foo<'b> - } -} - -mod variant_struct_type { - struct Foo { - x: T - } - struct Bar<'a,'b> { //~ ERROR reference has a longer lifetime - f: &'a Foo<&'b i32> - } -} - -mod rev_variant_struct_type { - struct Foo { - x: fn(T) - } - struct Bar<'a,'b> { //~ ERROR reference has a longer lifetime - f: &'a Foo<&'b i32> + enum Bar<'a,'b> { + V(&'a Foo<'b>) //~ ERROR reference has a longer lifetime } } diff --git a/src/test/compile-fail/regions-outlives-nominal-type-enum.rs b/src/test/compile-fail/regions-outlives-nominal-type-enum-region.rs similarity index 50% rename from src/test/compile-fail/regions-outlives-nominal-type-enum.rs rename to src/test/compile-fail/regions-outlives-nominal-type-enum-region.rs index 6fb409326f1..403757042d2 100644 --- a/src/test/compile-fail/regions-outlives-nominal-type-enum.rs +++ b/src/test/compile-fail/regions-outlives-nominal-type-enum-region.rs @@ -16,39 +16,12 @@ #![feature(rustc_attrs)] #![allow(dead_code)] -mod variant_enum_region { - enum Foo<'a> { - V { x: &'a i32 } +mod variant_struct_region { + struct Foo<'a> { + x: &'a i32, } - struct Bar<'a,'b> { //~ ERROR reference has a longer lifetime - f: &'a Foo<'b> - } -} - -mod rev_variant_enum_region { - enum Foo<'a> { - V { x: fn(&'a i32) } - } - struct Bar<'a,'b> { //~ ERROR reference has a longer lifetime - f: &'a Foo<'b> - } -} - -mod variant_enum_type { - enum Foo { - V { x: T } - } - struct Bar<'a,'b> { //~ ERROR reference has a longer lifetime - f: &'a Foo<&'b i32> - } -} - -mod rev_variant_enum_type { - enum Foo { - V { x: fn(T) } - } - struct Bar<'a,'b> { //~ ERROR reference has a longer lifetime - f: &'a Foo<&'b i32> + enum Bar<'a,'b> { + V(&'a Foo<'b>) //~ ERROR reference has a longer lifetime } } diff --git a/src/test/compile-fail/regions-outlives-nominal-type-enum-type-rev.rs b/src/test/compile-fail/regions-outlives-nominal-type-enum-type-rev.rs new file mode 100644 index 00000000000..cc294651db7 --- /dev/null +++ b/src/test/compile-fail/regions-outlives-nominal-type-enum-type-rev.rs @@ -0,0 +1,29 @@ +// Copyright 2014 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. + +// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its +// arguments (like `'a`) outlive `'b`. +// +// Rule OutlivesNominalType from RFC 1214. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +mod rev_variant_struct_type { + struct Foo { + x: fn(T) + } + enum Bar<'a,'b> { + V(&'a Foo<&'b i32>) //~ ERROR reference has a longer lifetime + } +} + +#[rustc_error] +fn main() { } diff --git a/src/test/compile-fail/regions-outlives-nominal-type-enum-type.rs b/src/test/compile-fail/regions-outlives-nominal-type-enum-type.rs new file mode 100644 index 00000000000..e269767cc16 --- /dev/null +++ b/src/test/compile-fail/regions-outlives-nominal-type-enum-type.rs @@ -0,0 +1,29 @@ +// Copyright 2014 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. + +// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its +// arguments (like `'a`) outlive `'b`. +// +// Rule OutlivesNominalType from RFC 1214. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +mod variant_struct_type { + struct Foo { + x: T + } + enum Bar<'a,'b> { + F(&'a Foo<&'b i32>) //~ ERROR reference has a longer lifetime + } +} + +#[rustc_error] +fn main() { } diff --git a/src/test/compile-fail/regions-outlives-nominal-type-struct-region-rev.rs b/src/test/compile-fail/regions-outlives-nominal-type-struct-region-rev.rs new file mode 100644 index 00000000000..c7e6ace8b92 --- /dev/null +++ b/src/test/compile-fail/regions-outlives-nominal-type-struct-region-rev.rs @@ -0,0 +1,29 @@ +// Copyright 2014 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. + +// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its +// arguments (like `'a`) outlive `'b`. +// +// Rule OutlivesNominalType from RFC 1214. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +mod rev_variant_struct_region { + struct Foo<'a> { + x: fn(&'a i32), + } + struct Bar<'a,'b> { + f: &'a Foo<'b> //~ ERROR reference has a longer lifetime + } +} + +#[rustc_error] +fn main() { } diff --git a/src/test/compile-fail/regions-outlives-nominal-type-struct-region.rs b/src/test/compile-fail/regions-outlives-nominal-type-struct-region.rs new file mode 100644 index 00000000000..2fe6444c33a --- /dev/null +++ b/src/test/compile-fail/regions-outlives-nominal-type-struct-region.rs @@ -0,0 +1,29 @@ +// Copyright 2014 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. + +// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its +// arguments (like `'a`) outlive `'b`. +// +// Rule OutlivesNominalType from RFC 1214. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +mod variant_struct_region { + struct Foo<'a> { + x: &'a i32, + } + struct Bar<'a,'b> { + f: &'a Foo<'b> //~ ERROR reference has a longer lifetime + } +} + +#[rustc_error] +fn main() { } diff --git a/src/test/compile-fail/regions-outlives-nominal-type-struct-type-rev.rs b/src/test/compile-fail/regions-outlives-nominal-type-struct-type-rev.rs new file mode 100644 index 00000000000..c4b631bce98 --- /dev/null +++ b/src/test/compile-fail/regions-outlives-nominal-type-struct-type-rev.rs @@ -0,0 +1,29 @@ +// Copyright 2014 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. + +// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its +// arguments (like `'a`) outlive `'b`. +// +// Rule OutlivesNominalType from RFC 1214. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +mod rev_variant_struct_type { + struct Foo { + x: fn(T) + } + struct Bar<'a,'b> { + f: &'a Foo<&'b i32> //~ ERROR reference has a longer lifetime + } +} + +#[rustc_error] +fn main() { } diff --git a/src/test/compile-fail/regions-outlives-nominal-type-struct-type.rs b/src/test/compile-fail/regions-outlives-nominal-type-struct-type.rs new file mode 100644 index 00000000000..1c9489444a6 --- /dev/null +++ b/src/test/compile-fail/regions-outlives-nominal-type-struct-type.rs @@ -0,0 +1,29 @@ +// Copyright 2014 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. + +// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its +// arguments (like `'a`) outlive `'b`. +// +// Rule OutlivesNominalType from RFC 1214. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +mod variant_struct_type { + struct Foo { + x: T + } + struct Bar<'a,'b> { + f: &'a Foo<&'b i32> //~ ERROR reference has a longer lifetime + } +} + +#[rustc_error] +fn main() { } diff --git a/src/test/compile-fail/regions-struct-not-wf.rs b/src/test/compile-fail/regions-struct-not-wf.rs index 17831266f7e..a7f18289703 100644 --- a/src/test/compile-fail/regions-struct-not-wf.rs +++ b/src/test/compile-fail/regions-struct-not-wf.rs @@ -13,8 +13,8 @@ #![allow(dead_code)] struct Ref<'a, T> { - //~^ ERROR the parameter type `T` may not live long enough field: &'a T + //~^ ERROR the parameter type `T` may not live long enough } struct RefOk<'a, T:'a> { @@ -22,13 +22,13 @@ struct RefOk<'a, T:'a> { } struct RefIndirect<'a, T> { - //~^ ERROR the parameter type `T` may not live long enough field: RefOk<'a, T> + //~^ ERROR the parameter type `T` may not live long enough } struct DoubleRef<'a, 'b, T> { - //~^ ERROR reference has a longer lifetime than the data it references field: &'a &'b T + //~^ ERROR reference has a longer lifetime than the data it references } fn main() { } diff --git a/src/test/compile-fail/regions-wf-trait-object.rs b/src/test/compile-fail/regions-wf-trait-object.rs index 2ad1163052b..e1f1fdaeb34 100644 --- a/src/test/compile-fail/regions-wf-trait-object.rs +++ b/src/test/compile-fail/regions-wf-trait-object.rs @@ -14,8 +14,8 @@ trait TheTrait<'t>: 't { } struct Foo<'a,'b> { - //~^ ERROR lifetime bound not satisfied x: Box+'b> + //~^ ERROR reference has a longer lifetime } fn main() { } diff --git a/src/test/compile-fail/wf-array-elem-sized.rs b/src/test/compile-fail/wf-array-elem-sized.rs index aaae41c7667..c8b7f35b3aa 100644 --- a/src/test/compile-fail/wf-array-elem-sized.rs +++ b/src/test/compile-fail/wf-array-elem-sized.rs @@ -13,8 +13,8 @@ #![feature(rustc_attrs)] #![allow(dead_code)] -struct Foo { //~ WARN E0277 - foo: [[u8]], +struct Foo { + foo: [[u8]], //~ WARN E0277 } #[rustc_error] diff --git a/src/test/compile-fail/wf-enum-fields-struct-variant.rs b/src/test/compile-fail/wf-enum-fields-struct-variant.rs new file mode 100644 index 00000000000..5eb53e7edde --- /dev/null +++ b/src/test/compile-fail/wf-enum-fields-struct-variant.rs @@ -0,0 +1,28 @@ +// Copyright 2014 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. + +// Test that we check struct fields for WFedness. + +#![feature(associated_type_defaults)] +#![feature(rustc_attrs)] +#![allow(dead_code)] + +struct IsCopy { + value: T +} + +enum AnotherEnum { + AnotherVariant { + f: IsCopy //~ ERROR E0277 + } +} + +#[rustc_error] +fn main() { } diff --git a/src/test/compile-fail/wf-enum-fields.rs b/src/test/compile-fail/wf-enum-fields.rs index 40a93935082..76ad40f8457 100644 --- a/src/test/compile-fail/wf-enum-fields.rs +++ b/src/test/compile-fail/wf-enum-fields.rs @@ -22,11 +22,5 @@ enum SomeEnum { SomeVariant(IsCopy) //~ ERROR E0277 } -enum AnotherEnum { //~ ERROR E0277 - AnotherVariant { - f: IsCopy - } -} - #[rustc_error] fn main() { } diff --git a/src/test/compile-fail/wf-in-fn-type-static.rs b/src/test/compile-fail/wf-in-fn-type-static.rs index 08853c69d6d..593c9435f6c 100644 --- a/src/test/compile-fail/wf-in-fn-type-static.rs +++ b/src/test/compile-fail/wf-in-fn-type-static.rs @@ -18,12 +18,12 @@ struct MustBeCopy { t: T } -struct Foo { //~ WARN E0310 +struct Foo { // needs T: 'static x: fn() -> &'static T //~ WARN E0310 } -struct Bar { //~ WARN E0310 +struct Bar { // needs T: Copy x: fn(&'static T) //~ WARN E0310 } diff --git a/src/test/compile-fail/wf-in-obj-type-static.rs b/src/test/compile-fail/wf-in-obj-type-static.rs index 36c8f5be308..c697dfd50ad 100644 --- a/src/test/compile-fail/wf-in-obj-type-static.rs +++ b/src/test/compile-fail/wf-in-obj-type-static.rs @@ -19,7 +19,7 @@ struct MustBeCopy { t: T } -struct Foo { //~ WARN E0310 +struct Foo { // needs T: 'static x: Object<&'static T> //~ WARN E0310 } diff --git a/src/test/compile-fail/wf-outlives-ty-in-fn-or-trait.rs b/src/test/compile-fail/wf-outlives-ty-in-fn-or-trait.rs index eca128f4a13..dc0cbeff153 100644 --- a/src/test/compile-fail/wf-outlives-ty-in-fn-or-trait.rs +++ b/src/test/compile-fail/wf-outlives-ty-in-fn-or-trait.rs @@ -18,13 +18,11 @@ trait Trait { } struct Foo<'a,T> { - //~^ WARN E0309 f: &'a fn(T), //~^ WARN E0309 } struct Bar<'a,T> { - //~^ WARN E0309 f: &'a Trait, //~^ WARN E0309 }