mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-02 01:52:51 +00:00
Update test error messages based on changes to wfcheck; also, break
apart the tests that tested many things at once.
This commit is contained in:
parent
2b2a113638
commit
157422a0c7
@ -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 {
|
||||
|
@ -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() { }
|
||||
|
@ -18,13 +18,14 @@ trait Expr: Debug + PartialEq {
|
||||
|
||||
//#[derive(PartialEq)]
|
||||
#[derive(Debug)]
|
||||
struct SExpr<'x> { //~ ERROR E0038
|
||||
struct SExpr<'x> {
|
||||
elements: Vec<Box<Expr+ 'x>>,
|
||||
}
|
||||
|
||||
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<Expr> = Box::new(SExpr::new());
|
||||
let b: Box<Expr> = Box::new(SExpr::new());
|
||||
let a: Box<Expr> = Box::new(SExpr::new()); //~ ERROR E0038
|
||||
let b: Box<Expr> = Box::new(SExpr::new()); //~ ERROR E0038
|
||||
|
||||
assert_eq!(a , b);
|
||||
// assert_eq!(a , b);
|
||||
}
|
||||
|
@ -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() { }
|
||||
|
@ -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<T> {
|
||||
x: T
|
||||
}
|
||||
struct Bar<'a,'b> { //~ ERROR reference has a longer lifetime
|
||||
f: &'a Foo<&'b i32>
|
||||
}
|
||||
}
|
||||
|
||||
mod rev_variant_struct_type {
|
||||
struct Foo<T> {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
@ -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<T> {
|
||||
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<T> {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
@ -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 <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.
|
||||
|
||||
// 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<T> {
|
||||
x: fn(T)
|
||||
}
|
||||
enum Bar<'a,'b> {
|
||||
V(&'a Foo<&'b i32>) //~ ERROR reference has a longer lifetime
|
||||
}
|
||||
}
|
||||
|
||||
#[rustc_error]
|
||||
fn main() { }
|
@ -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 <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.
|
||||
|
||||
// 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<T> {
|
||||
x: T
|
||||
}
|
||||
enum Bar<'a,'b> {
|
||||
F(&'a Foo<&'b i32>) //~ ERROR reference has a longer lifetime
|
||||
}
|
||||
}
|
||||
|
||||
#[rustc_error]
|
||||
fn main() { }
|
@ -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 <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.
|
||||
|
||||
// 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() { }
|
@ -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 <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.
|
||||
|
||||
// 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() { }
|
@ -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 <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.
|
||||
|
||||
// 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<T> {
|
||||
x: fn(T)
|
||||
}
|
||||
struct Bar<'a,'b> {
|
||||
f: &'a Foo<&'b i32> //~ ERROR reference has a longer lifetime
|
||||
}
|
||||
}
|
||||
|
||||
#[rustc_error]
|
||||
fn main() { }
|
@ -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 <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.
|
||||
|
||||
// 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<T> {
|
||||
x: T
|
||||
}
|
||||
struct Bar<'a,'b> {
|
||||
f: &'a Foo<&'b i32> //~ ERROR reference has a longer lifetime
|
||||
}
|
||||
}
|
||||
|
||||
#[rustc_error]
|
||||
fn main() { }
|
@ -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() { }
|
||||
|
@ -14,8 +14,8 @@
|
||||
trait TheTrait<'t>: 't { }
|
||||
|
||||
struct Foo<'a,'b> {
|
||||
//~^ ERROR lifetime bound not satisfied
|
||||
x: Box<TheTrait<'a>+'b>
|
||||
//~^ ERROR reference has a longer lifetime
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
@ -13,8 +13,8 @@
|
||||
#![feature(rustc_attrs)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
struct Foo { //~ WARN E0277
|
||||
foo: [[u8]],
|
||||
struct Foo {
|
||||
foo: [[u8]], //~ WARN E0277
|
||||
}
|
||||
|
||||
#[rustc_error]
|
||||
|
28
src/test/compile-fail/wf-enum-fields-struct-variant.rs
Normal file
28
src/test/compile-fail/wf-enum-fields-struct-variant.rs
Normal file
@ -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 <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.
|
||||
|
||||
// Test that we check struct fields for WFedness.
|
||||
|
||||
#![feature(associated_type_defaults)]
|
||||
#![feature(rustc_attrs)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
struct IsCopy<T:Copy> {
|
||||
value: T
|
||||
}
|
||||
|
||||
enum AnotherEnum<A> {
|
||||
AnotherVariant {
|
||||
f: IsCopy<A> //~ ERROR E0277
|
||||
}
|
||||
}
|
||||
|
||||
#[rustc_error]
|
||||
fn main() { }
|
@ -22,11 +22,5 @@ enum SomeEnum<A> {
|
||||
SomeVariant(IsCopy<A>) //~ ERROR E0277
|
||||
}
|
||||
|
||||
enum AnotherEnum<A> { //~ ERROR E0277
|
||||
AnotherVariant {
|
||||
f: IsCopy<A>
|
||||
}
|
||||
}
|
||||
|
||||
#[rustc_error]
|
||||
fn main() { }
|
||||
|
@ -18,12 +18,12 @@ struct MustBeCopy<T:Copy> {
|
||||
t: T
|
||||
}
|
||||
|
||||
struct Foo<T> { //~ WARN E0310
|
||||
struct Foo<T> {
|
||||
// needs T: 'static
|
||||
x: fn() -> &'static T //~ WARN E0310
|
||||
}
|
||||
|
||||
struct Bar<T> { //~ WARN E0310
|
||||
struct Bar<T> {
|
||||
// needs T: Copy
|
||||
x: fn(&'static T) //~ WARN E0310
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ struct MustBeCopy<T:Copy> {
|
||||
t: T
|
||||
}
|
||||
|
||||
struct Foo<T> { //~ WARN E0310
|
||||
struct Foo<T> {
|
||||
// needs T: 'static
|
||||
x: Object<&'static T> //~ WARN E0310
|
||||
}
|
||||
|
@ -18,13 +18,11 @@
|
||||
trait Trait<T> { }
|
||||
|
||||
struct Foo<'a,T> {
|
||||
//~^ WARN E0309
|
||||
f: &'a fn(T),
|
||||
//~^ WARN E0309
|
||||
}
|
||||
|
||||
struct Bar<'a,T> {
|
||||
//~^ WARN E0309
|
||||
f: &'a Trait<T>,
|
||||
//~^ WARN E0309
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user