apart the tests that tested many things at once.
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 {
}
struct Bar {
-//~^ ERROR E0038
foos: &'static [&'static (Qiz + 'static)]
}
const FOO : Foo = Foo;
const BAR : Bar = Bar { foos: &[&FOO]};
+//~^ ERROR E0038
fn main() { }
//#[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);
}
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);
}
#![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> {
}
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() { }
--- /dev/null
+// 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),
+ }
+ enum Bar<'a,'b> {
+ V(&'a Foo<'b>) //~ ERROR reference has a longer lifetime
+ }
+}
+
+#[rustc_error]
+fn main() { }
--- /dev/null
+// 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,
+ }
+ enum Bar<'a,'b> {
+ V(&'a Foo<'b>) //~ ERROR reference has a longer lifetime
+ }
+}
+
+#[rustc_error]
+fn main() { }
--- /dev/null
+// 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() { }
--- /dev/null
+// 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() { }
+++ /dev/null
-// 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_enum_region {
- enum Foo<'a> {
- V { 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>
- }
-}
-
-#[rustc_error]
-fn main() { }
--- /dev/null
+// 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() { }
--- /dev/null
+// 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() { }
--- /dev/null
+// 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() { }
--- /dev/null
+// 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() { }
+++ /dev/null
-// 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> { //~ 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>
- }
-}
-
-#[rustc_error]
-fn main() { }
#![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> {
}
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() { }
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() { }
#![feature(rustc_attrs)]
#![allow(dead_code)]
-struct Foo { //~ WARN E0277
- foo: [[u8]],
+struct Foo {
+ foo: [[u8]], //~ WARN E0277
}
#[rustc_error]
--- /dev/null
+// 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() { }
SomeVariant(IsCopy<A>) //~ ERROR E0277
}
-enum AnotherEnum<A> { //~ ERROR E0277
- AnotherVariant {
- f: IsCopy<A>
- }
-}
-
#[rustc_error]
fn main() { }
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
}
t: T
}
-struct Foo<T> { //~ WARN E0310
+struct Foo<T> {
// needs T: 'static
x: Object<&'static T> //~ WARN E0310
}
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
}