diff options
Diffstat (limited to 'src/test/compile-fail')
249 files changed, 1313 insertions, 1758 deletions
diff --git a/src/test/compile-fail/ascii-only-character-escape.rs b/src/test/compile-fail/ascii-only-character-escape.rs deleted file mode 100644 index 1ba25a827a5..00000000000 --- a/src/test/compile-fail/ascii-only-character-escape.rs +++ /dev/null @@ -1,17 +0,0 @@ -// 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. - -fn main() { - let x = "\x80"; //~ ERROR may only be used - let y = "\xff"; //~ ERROR may only be used - let z = "\xe2"; //~ ERROR may only be used - let a = b"\x00e2"; // ok because byte literal -} - diff --git a/src/test/compile-fail/associated-types-ICE-when-projecting-out-of-err.rs b/src/test/compile-fail/associated-types-ICE-when-projecting-out-of-err.rs index 621f5ec9660..edd1b8255cc 100644 --- a/src/test/compile-fail/associated-types-ICE-when-projecting-out-of-err.rs +++ b/src/test/compile-fail/associated-types-ICE-when-projecting-out-of-err.rs @@ -16,8 +16,12 @@ #![feature(no_std)] #![no_std] +#[lang="phantom_fn"] +pub trait PhantomFn<A:?Sized,R:?Sized=()> { } +impl<A:?Sized, R:?Sized, U:?Sized> PhantomFn<A,R> for U { } + #[lang="sized"] -pub trait Sized { +pub trait Sized : PhantomFn<Self> { // Empty. } diff --git a/src/test/compile-fail/associated-types-coherence-failure.rs b/src/test/compile-fail/associated-types-coherence-failure.rs index 95a68dd6698..b7a16c68a34 100644 --- a/src/test/compile-fail/associated-types-coherence-failure.rs +++ b/src/test/compile-fail/associated-types-coherence-failure.rs @@ -11,9 +11,10 @@ // Test that coherence detects overlap when some of the types in the // impls are projections of associated type. Issue #20624. +use std::marker::PhantomData; use std::ops::Deref; -pub struct Cow<'a, B: ?Sized>; +pub struct Cow<'a, B: ?Sized>(PhantomData<(&'a (),B)>); /// Trait for moving into a `Cow` pub trait IntoCow<'a, B: ?Sized> { diff --git a/src/test/compile-fail/associated-types-eq-expr-path.rs b/src/test/compile-fail/associated-types-eq-expr-path.rs index 9baa7f1ad5a..c48f9972ebc 100644 --- a/src/test/compile-fail/associated-types-eq-expr-path.rs +++ b/src/test/compile-fail/associated-types-eq-expr-path.rs @@ -10,7 +10,7 @@ // Check that an associated type cannot be bound in an expression path. -trait Foo { +trait Foo : ::std::marker::MarkerTrait { type A; fn bar() -> isize; } diff --git a/src/test/compile-fail/associated-types-issue-17359.rs b/src/test/compile-fail/associated-types-issue-17359.rs index fa09ae793bf..625f4cdb8ef 100644 --- a/src/test/compile-fail/associated-types-issue-17359.rs +++ b/src/test/compile-fail/associated-types-issue-17359.rs @@ -11,7 +11,7 @@ // Test that we do not ICE when an impl is missing an associated type (and that we report // a useful error, of course). -trait Trait { +trait Trait : ::std::marker::MarkerTrait { type Type; } diff --git a/src/test/compile-fail/associated-types-multiple-types-one-trait.rs b/src/test/compile-fail/associated-types-multiple-types-one-trait.rs index 9436f825de8..5632f148da6 100644 --- a/src/test/compile-fail/associated-types-multiple-types-one-trait.rs +++ b/src/test/compile-fail/associated-types-multiple-types-one-trait.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait Foo { +trait Foo : ::std::marker::MarkerTrait { type X; type Y; } diff --git a/src/test/compile-fail/associated-types-no-suitable-supertrait.rs b/src/test/compile-fail/associated-types-no-suitable-supertrait.rs index a3f2850b294..2b84c38f80b 100644 --- a/src/test/compile-fail/associated-types-no-suitable-supertrait.rs +++ b/src/test/compile-fail/associated-types-no-suitable-supertrait.rs @@ -11,7 +11,7 @@ // Check that we get an error when you use `<Self as Get>::Value` in // the trait definition but `Self` does not, in fact, implement `Get`. -trait Get { +trait Get : ::std::marker::MarkerTrait { type Value; } diff --git a/src/test/compile-fail/associated-types-path-2.rs b/src/test/compile-fail/associated-types-path-2.rs index 51a37b517dd..b9a62ff4e41 100644 --- a/src/test/compile-fail/associated-types-path-2.rs +++ b/src/test/compile-fail/associated-types-path-2.rs @@ -12,6 +12,8 @@ pub trait Foo { type A; + + fn dummy(&self) { } } impl Foo for i32 { diff --git a/src/test/compile-fail/associated-types-unconstrained.rs b/src/test/compile-fail/associated-types-unconstrained.rs index aecbf217a5b..8832028f9ab 100644 --- a/src/test/compile-fail/associated-types-unconstrained.rs +++ b/src/test/compile-fail/associated-types-unconstrained.rs @@ -10,7 +10,7 @@ // Check that an associated type cannot be bound in an expression path. -trait Foo { +trait Foo : ::std::marker::MarkerTrait { type A; fn bar() -> isize; } diff --git a/src/test/compile-fail/attr-before-eof.rs b/src/test/compile-fail/attr-before-eof.rs deleted file mode 100644 index e34756229bd..00000000000 --- a/src/test/compile-fail/attr-before-eof.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2012 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. - -#[derive(Debug)] //~ERROR expected item after attributes diff --git a/src/test/compile-fail/attr-before-ext.rs b/src/test/compile-fail/attr-before-ext.rs deleted file mode 100644 index 098c5aaec54..00000000000 --- a/src/test/compile-fail/attr-before-ext.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2012 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. - -fn main() { - #[attr] //~ ERROR expected item after attributes - println!("hi"); -} diff --git a/src/test/compile-fail/attr-before-let.rs b/src/test/compile-fail/attr-before-let.rs deleted file mode 100644 index b4a90e35c40..00000000000 --- a/src/test/compile-fail/attr-before-let.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2012 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. - -fn main() { - #[attr] //~ ERROR expected item - let __isize = 0; -} diff --git a/src/test/compile-fail/attrs-after-extern-mod.rs b/src/test/compile-fail/attrs-after-extern-mod.rs deleted file mode 100644 index df747618696..00000000000 --- a/src/test/compile-fail/attrs-after-extern-mod.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2013 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. - -// Constants (static variables) can be used to match in patterns, but mutable -// statics cannot. This ensures that there's some form of error if this is -// attempted. - -extern crate libc; - -extern { - static mut rust_dbg_static_mut: libc::c_int; - pub fn rust_dbg_static_mut_check_four(); - #[cfg(stage37)] //~ ERROR expected item after attributes -} - -pub fn main() {} diff --git a/src/test/compile-fail/bad-char-literals.rs b/src/test/compile-fail/bad-char-literals.rs deleted file mode 100644 index 2a358ae8307..00000000000 --- a/src/test/compile-fail/bad-char-literals.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2013 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. - -// ignore-tidy-cr -// ignore-tidy-tab -fn main() { - // these literals are just silly. - '''; - //~^ ERROR: character constant must be escaped: \' - - // note that this is a literal "\n" byte - ' -'; - //~^^ ERROR: character constant must be escaped: \n - - // note that this is a literal "\r" byte - ' '; //~ ERROR: character constant must be escaped: \r - - // note that this is a literal tab character here - ' '; - //~^ ERROR: character constant must be escaped: \t -} diff --git a/src/test/compile-fail/bad-lit-suffixes.rs b/src/test/compile-fail/bad-lit-suffixes.rs deleted file mode 100644 index d10337e768c..00000000000 --- a/src/test/compile-fail/bad-lit-suffixes.rs +++ /dev/null @@ -1,41 +0,0 @@ -// 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. - - -extern crate - "foo"suffix //~ ERROR extern crate name with a suffix is illegal - as foo; - -extern - "C"suffix //~ ERROR ABI spec with a suffix is illegal - fn foo() {} - -extern - "C"suffix //~ ERROR ABI spec with a suffix is illegal -{} - -fn main() { - ""suffix; //~ ERROR str literal with a suffix is illegal - b""suffix; //~ ERROR binary str literal with a suffix is illegal - r#""#suffix; //~ ERROR str literal with a suffix is illegal - br#""#suffix; //~ ERROR binary str literal with a suffix is illegal - 'a'suffix; //~ ERROR char literal with a suffix is illegal - b'a'suffix; //~ ERROR byte literal with a suffix is illegal - - 1234u1024; //~ ERROR illegal width `1024` for integer literal - 1234i1024; //~ ERROR illegal width `1024` for integer literal - 1234f1024; //~ ERROR illegal width `1024` for float literal - 1234.5f1024; //~ ERROR illegal width `1024` for float literal - - 1234suffix; //~ ERROR illegal suffix `suffix` for numeric literal - 0b101suffix; //~ ERROR illegal suffix `suffix` for numeric literal - 1.0suffix; //~ ERROR illegal suffix `suffix` for float literal - 1.0e10suffix; //~ ERROR illegal suffix `suffix` for float literal -} diff --git a/src/test/compile-fail/bad-mid-path-type-params.rs b/src/test/compile-fail/bad-mid-path-type-params.rs index c91849ca53e..3e02a11c378 100644 --- a/src/test/compile-fail/bad-mid-path-type-params.rs +++ b/src/test/compile-fail/bad-mid-path-type-params.rs @@ -10,13 +10,6 @@ // ignore-tidy-linelength -#![feature(no_std)] -#![no_std] -#![feature(lang_items)] - -#[lang="sized"] -pub trait Sized {} - struct S<T> { contents: T, } diff --git a/src/test/compile-fail/bad-sized.rs b/src/test/compile-fail/bad-sized.rs index 69be6414e4c..1944acbe1f3 100644 --- a/src/test/compile-fail/bad-sized.rs +++ b/src/test/compile-fail/bad-sized.rs @@ -12,7 +12,7 @@ use std::cell::RefCell; -trait Trait {} +trait Trait : ::std::marker::MarkerTrait {} pub fn main() { let x: Vec<Trait + Sized> = Vec::new(); diff --git a/src/test/compile-fail/bad-value-ident-false.rs b/src/test/compile-fail/bad-value-ident-false.rs deleted file mode 100644 index ca10bdd9848..00000000000 --- a/src/test/compile-fail/bad-value-ident-false.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2012 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. - -fn false() { } //~ ERROR expected identifier, found keyword `false` -fn main() { } diff --git a/src/test/compile-fail/bad-value-ident-true.rs b/src/test/compile-fail/bad-value-ident-true.rs deleted file mode 100644 index 4508d5219a2..00000000000 --- a/src/test/compile-fail/bad-value-ident-true.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2012 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. - -fn true() { } //~ ERROR expected identifier, found keyword `true` -fn main() { } diff --git a/src/test/compile-fail/coherence-blanket-conflicts-with-blanket-implemented.rs b/src/test/compile-fail/coherence-blanket-conflicts-with-blanket-implemented.rs index 27d97d18c94..d4decb71349 100644 --- a/src/test/compile-fail/coherence-blanket-conflicts-with-blanket-implemented.rs +++ b/src/test/compile-fail/coherence-blanket-conflicts-with-blanket-implemented.rs @@ -10,6 +10,7 @@ use std::fmt::Show; use std::default::Default; +use std::marker::MarkerTrait; // Test that two blanket impls conflict (at least without negative // bounds). After all, some other crate could implement Even or Odd @@ -19,9 +20,9 @@ trait MyTrait { fn get(&self) -> usize; } -trait Even { } +trait Even : MarkerTrait { } -trait Odd { } +trait Odd : MarkerTrait { } impl Even for isize { } diff --git a/src/test/compile-fail/coherence-blanket-conflicts-with-blanket-unimplemented.rs b/src/test/compile-fail/coherence-blanket-conflicts-with-blanket-unimplemented.rs index 0f233b78c72..b1ee1762b6e 100644 --- a/src/test/compile-fail/coherence-blanket-conflicts-with-blanket-unimplemented.rs +++ b/src/test/compile-fail/coherence-blanket-conflicts-with-blanket-unimplemented.rs @@ -19,9 +19,9 @@ trait MyTrait { fn get(&self) -> usize; } -trait Even { } +trait Even : ::std::marker::MarkerTrait { } -trait Odd { } +trait Odd : ::std::marker::MarkerTrait { } impl<T:Even> MyTrait for T { //~ ERROR E0119 fn get(&self) -> usize { 0 } diff --git a/src/test/compile-fail/coherence-conflicting-negative-trait-impl.rs b/src/test/compile-fail/coherence-conflicting-negative-trait-impl.rs index c9dfb8201a9..a225f6cf473 100644 --- a/src/test/compile-fail/coherence-conflicting-negative-trait-impl.rs +++ b/src/test/compile-fail/coherence-conflicting-negative-trait-impl.rs @@ -10,18 +10,18 @@ #![feature(optin_builtin_traits)] -trait MyTrait {} +trait MyTrait : ::std::marker::MarkerTrait {} -struct TestType<T>; +struct TestType<T>(::std::marker::PhantomData<T>); -unsafe impl<T: MyTrait> Send for TestType<T> {} +unsafe impl<T: MyTrait+'static> Send for TestType<T> {} //~^ ERROR conflicting implementations for trait `core::marker::Send` //~^^ ERROR conflicting implementations for trait `core::marker::Send` impl<T: MyTrait> !Send for TestType<T> {} //~^ ERROR conflicting implementations for trait `core::marker::Send` -unsafe impl<T> Send for TestType<T> {} +unsafe impl<T:'static> Send for TestType<T> {} //~^ ERROR error: conflicting implementations for trait `core::marker::Send` impl !Send for TestType<i32> {} diff --git a/src/test/compile-fail/coherence-subtyping.rs b/src/test/compile-fail/coherence-subtyping.rs new file mode 100644 index 00000000000..897cb083f84 --- /dev/null +++ b/src/test/compile-fail/coherence-subtyping.rs @@ -0,0 +1,50 @@ +// Copyright 2015 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 two distinct impls which match subtypes of one another +// yield coherence errors (or not) depending on the variance. + +trait Contravariant { + fn foo(&self) { } +} + +impl Contravariant for for<'a,'b> fn(&'a u8, &'b u8) { + //~^ ERROR E0119 +} + +impl Contravariant for for<'a> fn(&'a u8, &'a u8) { +} + +/////////////////////////////////////////////////////////////////////////// + +trait Covariant { + fn foo(&self) { } +} + +impl Covariant for for<'a,'b> fn(&'a u8, &'b u8) { + //~^ ERROR E0119 +} + +impl Covariant for for<'a> fn(&'a u8, &'a u8) { +} + +/////////////////////////////////////////////////////////////////////////// + +trait Invariant { + fn foo(&self) -> Self { } +} + +impl Invariant for for<'a,'b> fn(&'a u8, &'b u8) { +} + +impl Invariant for for<'a> fn(&'a u8, &'a u8) { +} + +fn main() { } diff --git a/src/test/compile-fail/cross-borrow-trait.rs b/src/test/compile-fail/cross-borrow-trait.rs index 86b7a8c8918..6bd21101a60 100644 --- a/src/test/compile-fail/cross-borrow-trait.rs +++ b/src/test/compile-fail/cross-borrow-trait.rs @@ -14,7 +14,7 @@ #![feature(box_syntax)] struct Foo; -trait Trait {} +trait Trait { fn foo(&self) {} } impl Trait for Foo {} pub fn main() { diff --git a/src/test/compile-fail/destructure-trait-ref.rs b/src/test/compile-fail/destructure-trait-ref.rs index f2e068cc4ff..4161cce2843 100644 --- a/src/test/compile-fail/destructure-trait-ref.rs +++ b/src/test/compile-fail/destructure-trait-ref.rs @@ -14,7 +14,7 @@ #![feature(box_patterns)] #![feature(box_syntax)] -trait T {} +trait T { fn foo(&self) {} } impl T for isize {} fn main() { diff --git a/src/test/compile-fail/doc-before-attr.rs b/src/test/compile-fail/doc-before-attr.rs deleted file mode 100644 index bb44a6a8abb..00000000000 --- a/src/test/compile-fail/doc-before-attr.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2012 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. - -/// hi -#[derive(Debug)] //~ERROR expected item after attributes diff --git a/src/test/compile-fail/doc-before-eof.rs b/src/test/compile-fail/doc-before-eof.rs deleted file mode 100644 index e6dd4102462..00000000000 --- a/src/test/compile-fail/doc-before-eof.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2012 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. - -/// hi //~ERROR expected item after doc comment diff --git a/src/test/compile-fail/doc-before-extern-rbrace.rs b/src/test/compile-fail/doc-before-extern-rbrace.rs deleted file mode 100644 index 5afd1b2c6b8..00000000000 --- a/src/test/compile-fail/doc-before-extern-rbrace.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2012 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. - -extern { - /// hi -} -//~^^ ERROR expected item after doc comment diff --git a/src/test/compile-fail/doc-before-macro.rs b/src/test/compile-fail/doc-before-macro.rs deleted file mode 100644 index 8dc6c546500..00000000000 --- a/src/test/compile-fail/doc-before-macro.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 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. - -fn main() { - /// hi - println!("hi"); - //~^^ ERROR expected item after doc comment -} diff --git a/src/test/compile-fail/doc-before-rbrace.rs b/src/test/compile-fail/doc-before-rbrace.rs deleted file mode 100644 index 6d05064277d..00000000000 --- a/src/test/compile-fail/doc-before-rbrace.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2012 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. - -fn main() { - println!("Hi"); /// hi - //~^ ERROR expected item after doc comment -} diff --git a/src/test/compile-fail/doc-before-semi.rs b/src/test/compile-fail/doc-before-semi.rs deleted file mode 100644 index 8b0300edce0..00000000000 --- a/src/test/compile-fail/doc-before-semi.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 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. - -fn main() { - /// hi - ; - //~^^ ERROR expected item after doc comment -} diff --git a/src/test/compile-fail/dst-bad-coerce1.rs b/src/test/compile-fail/dst-bad-coerce1.rs index 2b96c5ebe12..ddc92901771 100644 --- a/src/test/compile-fail/dst-bad-coerce1.rs +++ b/src/test/compile-fail/dst-bad-coerce1.rs @@ -15,7 +15,7 @@ struct Fat<T: ?Sized> { } struct Foo; -trait Bar {} +trait Bar { fn bar(&self) {} } pub fn main() { // With a vec of isize. diff --git a/src/test/compile-fail/dst-bad-coerce2.rs b/src/test/compile-fail/dst-bad-coerce2.rs index 160197368d6..aa687266acb 100644 --- a/src/test/compile-fail/dst-bad-coerce2.rs +++ b/src/test/compile-fail/dst-bad-coerce2.rs @@ -15,7 +15,7 @@ struct Fat<T: ?Sized> { } struct Foo; -trait Bar {} +trait Bar : ::std::marker::MarkerTrait {} impl Bar for Foo {} pub fn main() { diff --git a/src/test/compile-fail/dst-bad-coerce3.rs b/src/test/compile-fail/dst-bad-coerce3.rs index 347a2d2ecbe..7bad3bd69d3 100644 --- a/src/test/compile-fail/dst-bad-coerce3.rs +++ b/src/test/compile-fail/dst-bad-coerce3.rs @@ -15,7 +15,7 @@ struct Fat<T: ?Sized> { } struct Foo; -trait Bar {} +trait Bar { fn bar(&self) {} } impl Bar for Foo {} fn baz<'a>() { diff --git a/src/test/compile-fail/dst-bad-coercions.rs b/src/test/compile-fail/dst-bad-coercions.rs index b30eada162b..8ec1034bc4d 100644 --- a/src/test/compile-fail/dst-bad-coercions.rs +++ b/src/test/compile-fail/dst-bad-coercions.rs @@ -10,8 +10,10 @@ // Test implicit coercions involving DSTs and raw pointers. +use std::marker::MarkerTrait; + struct S; -trait T {} +trait T : MarkerTrait {} impl T for S {} struct Foo<T: ?Sized> { diff --git a/src/test/compile-fail/dst-object-from-unsized-type.rs b/src/test/compile-fail/dst-object-from-unsized-type.rs index 87ff4291f50..b4fd45845f7 100644 --- a/src/test/compile-fail/dst-object-from-unsized-type.rs +++ b/src/test/compile-fail/dst-object-from-unsized-type.rs @@ -10,7 +10,7 @@ // Test that we cannot create objects from unsized types. -trait Foo {} +trait Foo { fn foo(&self) {} } impl Foo for str {} fn test1<T: ?Sized + Foo>(t: &T) { diff --git a/src/test/compile-fail/exclusive-drop-and-copy.rs b/src/test/compile-fail/exclusive-drop-and-copy.rs index 17453bc677f..f47f14d5879 100644 --- a/src/test/compile-fail/exclusive-drop-and-copy.rs +++ b/src/test/compile-fail/exclusive-drop-and-copy.rs @@ -20,7 +20,7 @@ impl Drop for Foo { } #[derive(Copy)] //~ ERROR the trait `Copy` may not be implemented -struct Bar<T>; +struct Bar<T>(::std::marker::PhantomData<T>); #[unsafe_destructor] impl<T> Drop for Bar<T> { diff --git a/src/test/compile-fail/extern-crate-as-no-string-help.rs b/src/test/compile-fail/extern-crate-as-no-string-help.rs deleted file mode 100644 index 5cc52f6f6db..00000000000 --- a/src/test/compile-fail/extern-crate-as-no-string-help.rs +++ /dev/null @@ -1,15 +0,0 @@ -// 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. - -// Tests that the proper help is displayed in the error message - -extern crate foo as bar; -//~^ ERROR expected `;`, found `as` -//~^^ HELP perhaps you meant to enclose the crate name `foo` in a string? diff --git a/src/test/compile-fail/generic-impl-less-params-with-defaults.rs b/src/test/compile-fail/generic-impl-less-params-with-defaults.rs index 02f09749d61..9fea5e609d1 100644 --- a/src/test/compile-fail/generic-impl-less-params-with-defaults.rs +++ b/src/test/compile-fail/generic-impl-less-params-with-defaults.rs @@ -8,10 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct Foo<A, B, C = (A, B)>; +use std::marker; + +struct Foo<A, B, C = (A, B)>( + marker::PhantomData<(A,B,C)>); impl<A, B, C = (A, B)> Foo<A, B, C> { - fn new() -> Foo<A, B, C> {Foo} + fn new() -> Foo<A, B, C> {Foo(marker::PhantomData)} } fn main() { diff --git a/src/test/compile-fail/generic-impl-more-params-with-defaults.rs b/src/test/compile-fail/generic-impl-more-params-with-defaults.rs index d88da2625c1..73c19aa012d 100644 --- a/src/test/compile-fail/generic-impl-more-params-with-defaults.rs +++ b/src/test/compile-fail/generic-impl-more-params-with-defaults.rs @@ -8,12 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::marker; + struct Heap; -struct Vec<T, A = Heap>; +struct Vec<T, A = Heap>( + marker::PhantomData<(T,A)>); impl<T, A = Heap> Vec<T, A> { - fn new() -> Vec<T, A> {Vec} + fn new() -> Vec<T, A> {Vec(marker::PhantomData)} } fn main() { diff --git a/src/test/compile-fail/generic-lifetime-trait-impl.rs b/src/test/compile-fail/generic-lifetime-trait-impl.rs index fc54002820e..9b9f09f4777 100644 --- a/src/test/compile-fail/generic-lifetime-trait-impl.rs +++ b/src/test/compile-fail/generic-lifetime-trait-impl.rs @@ -16,9 +16,12 @@ // // Regression test for issue #16218. -trait Bar<'a> {} +trait Bar<'a> { + fn dummy(&'a self); +} trait Foo<'a> { + fn dummy(&'a self) { } fn bar<'b, T: Bar<'b>>(self) -> &'b str; } diff --git a/src/test/compile-fail/generic-non-trailing-defaults.rs b/src/test/compile-fail/generic-non-trailing-defaults.rs deleted file mode 100644 index 0cfb05b9332..00000000000 --- a/src/test/compile-fail/generic-non-trailing-defaults.rs +++ /dev/null @@ -1,17 +0,0 @@ -// 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. - -struct Heap; - -struct Vec<A = Heap, T>; //~ ERROR type parameters with a default must be trailing - -struct Foo<A, B = Vec<C>, C>; //~ ERROR type parameters with a default must be trailing - -fn main() {} diff --git a/src/test/compile-fail/generic-type-less-params-with-defaults.rs b/src/test/compile-fail/generic-type-less-params-with-defaults.rs index f25d8f99b8d..37737fda474 100644 --- a/src/test/compile-fail/generic-type-less-params-with-defaults.rs +++ b/src/test/compile-fail/generic-type-less-params-with-defaults.rs @@ -8,9 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::marker; + struct Heap; -struct Vec<T, A = Heap>; +struct Vec<T, A = Heap>( + marker::PhantomData<(T,A)>); fn main() { let _: Vec; //~ ERROR wrong number of type arguments: expected at least 1, found 0 diff --git a/src/test/compile-fail/generic-type-more-params-with-defaults.rs b/src/test/compile-fail/generic-type-more-params-with-defaults.rs index 19d303488ac..ad7e4f190c5 100644 --- a/src/test/compile-fail/generic-type-more-params-with-defaults.rs +++ b/src/test/compile-fail/generic-type-more-params-with-defaults.rs @@ -8,9 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::marker; + struct Heap; -struct Vec<T, A = Heap>; +struct Vec<T, A = Heap>( + marker::PhantomData<(T,A)>); fn main() { let _: Vec<isize, Heap, bool>; diff --git a/src/test/compile-fail/generic-type-params-name-repr.rs b/src/test/compile-fail/generic-type-params-name-repr.rs index 3e34344d78b..a452cd35f94 100644 --- a/src/test/compile-fail/generic-type-params-name-repr.rs +++ b/src/test/compile-fail/generic-type-params-name-repr.rs @@ -8,13 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::marker; + struct A; struct B; struct C; -struct Foo<T = A, U = B, V = C>; +struct Foo<T = A, U = B, V = C>(marker::PhantomData<(T,U,V)>); -struct Hash<T>; -struct HashMap<K, V, H = Hash<K>>; +struct Hash<T>(marker::PhantomData<T>); +struct HashMap<K, V, H = Hash<K>>(marker::PhantomData<(K,V,H)>); fn main() { // Ensure that the printed type doesn't include the default type params... diff --git a/src/test/compile-fail/int-literal-too-large-span.rs b/src/test/compile-fail/int-literal-too-large-span.rs deleted file mode 100644 index 8a496c934b9..00000000000 --- a/src/test/compile-fail/int-literal-too-large-span.rs +++ /dev/null @@ -1,17 +0,0 @@ -// 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. - -// issue #17123 - -fn main() { - 100000000000000000000000000000000 //~ ERROR int literal is too large - - ; // the span shouldn't point to this. -} diff --git a/src/test/compile-fail/issue-10412.rs b/src/test/compile-fail/issue-10412.rs deleted file mode 100644 index 8a99633b4fc..00000000000 --- a/src/test/compile-fail/issue-10412.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2013 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. - - -trait Serializable<'self, T> { //~ ERROR no longer a special lifetime - fn serialize(val : &'self T) -> Vec<u8> ; //~ ERROR no longer a special lifetime - fn deserialize(repr : &[u8]) -> &'self T; //~ ERROR no longer a special lifetime -} - -impl<'self> Serializable<str> for &'self str { //~ ERROR no longer a special lifetime - //~^ ERROR no longer a special lifetime - fn serialize(val : &'self str) -> Vec<u8> { //~ ERROR no longer a special lifetime - vec!(1) - } - fn deserialize(repr: &[u8]) -> &'self str { //~ ERROR no longer a special lifetime - "hi" - } -} - -fn main() { - println!("hello"); - let x = "foo".to_string(); - let y = x; - println!("{}", y); -} diff --git a/src/test/compile-fail/issue-11515.rs b/src/test/compile-fail/issue-11515.rs index f0089b0ae5b..4ff574e939d 100644 --- a/src/test/compile-fail/issue-11515.rs +++ b/src/test/compile-fail/issue-11515.rs @@ -10,7 +10,7 @@ #![feature(box_syntax)] -struct Test<'s> { +struct Test { func: Box<FnMut()+'static> } diff --git a/src/test/compile-fail/issue-12560-1.rs b/src/test/compile-fail/issue-12560-1.rs deleted file mode 100644 index ea2043e6703..00000000000 --- a/src/test/compile-fail/issue-12560-1.rs +++ /dev/null @@ -1,23 +0,0 @@ -// 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. - -// For style and consistency reasons, non-parametrized enum variants must -// be used simply as `ident` instead of `ident ()`. -// This test-case covers enum declaration. - -enum Foo { - Bar(), //~ ERROR nullary enum variants are written with no trailing `( )` - Baz(), //~ ERROR nullary enum variants are written with no trailing `( )` - Bazar -} - -fn main() { - println!("{}", match Bar { Bar => 1, Baz => 2, Bazar => 3 }) -} diff --git a/src/test/compile-fail/issue-13853-2.rs b/src/test/compile-fail/issue-13853-2.rs index ea0d880f4a1..dc697e4784f 100644 --- a/src/test/compile-fail/issue-13853-2.rs +++ b/src/test/compile-fail/issue-13853-2.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait FromStructReader<'a> { } +use std::marker::PhantomFn; + +trait FromStructReader<'a> : PhantomFn<(Self,&'a ())> { } trait ResponseHook { fn get<'a, T: FromStructReader<'a>>(&'a self); } diff --git a/src/test/compile-fail/issue-13853-3.rs b/src/test/compile-fail/issue-13853-3.rs index f10c47b594e..7ca158c3e32 100644 --- a/src/test/compile-fail/issue-13853-3.rs +++ b/src/test/compile-fail/issue-13853-3.rs @@ -10,6 +10,8 @@ #![crate_type = "lib"] +use std::marker::PhantomData; + enum NodeContents<'a> { Children(Vec<Node<'a>>), } @@ -22,11 +24,12 @@ impl<'a> Drop for NodeContents<'a> { struct Node<'a> { contents: NodeContents<'a>, + marker: PhantomData<&'a ()>, } impl<'a> Node<'a> { fn noName(contents: NodeContents<'a>) -> Node<'a> { - Node{ contents: contents,} + Node { contents: contents, marker: PhantomData } } } diff --git a/src/test/compile-fail/issue-13853.rs b/src/test/compile-fail/issue-13853.rs index 251da2c6b3e..cd3f337c4ab 100644 --- a/src/test/compile-fail/issue-13853.rs +++ b/src/test/compile-fail/issue-13853.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait Node { +use std::marker::MarkerTrait; + +trait Node : MarkerTrait { fn zomg(); } diff --git a/src/test/compile-fail/issue-14285.rs b/src/test/compile-fail/issue-14285.rs index cbf4412a81d..3a5df9e805b 100644 --- a/src/test/compile-fail/issue-14285.rs +++ b/src/test/compile-fail/issue-14285.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait Foo {} +trait Foo { + fn dummy(&self) { } +} struct A; diff --git a/src/test/compile-fail/issue-14853.rs b/src/test/compile-fail/issue-14853.rs index 51deb99a4f2..0b846651acf 100644 --- a/src/test/compile-fail/issue-14853.rs +++ b/src/test/compile-fail/issue-14853.rs @@ -9,8 +9,9 @@ // except according to those terms. use std::fmt::Debug; +use std::marker::MarkerTrait; -trait Str {} +trait Str : MarkerTrait {} trait Something { fn yay<T: Debug>(_: Option<Self>, thing: &[T]); diff --git a/src/test/compile-fail/issue-16747.rs b/src/test/compile-fail/issue-16747.rs index 814b885e3aa..a213234b89b 100644 --- a/src/test/compile-fail/issue-16747.rs +++ b/src/test/compile-fail/issue-16747.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait ListItem<'a> { +use std::marker::MarkerTrait; + +trait ListItem<'a> : MarkerTrait { fn list_name() -> &'a str; } diff --git a/src/test/compile-fail/issue-17431-4.rs b/src/test/compile-fail/issue-17431-4.rs index 1e27f025564..22aaa796ad0 100644 --- a/src/test/compile-fail/issue-17431-4.rs +++ b/src/test/compile-fail/issue-17431-4.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct Foo<T> { foo: Option<Option<Foo<T>>> } +use std::marker; + +struct Foo<T> { foo: Option<Option<Foo<T>>>, marker: marker::PhantomData<T> } //~^ ERROR illegal recursive struct type; wrap the inner value in a box to make it representable impl<T> Foo<T> { fn bar(&self) {} } diff --git a/src/test/compile-fail/issue-17431-5.rs b/src/test/compile-fail/issue-17431-5.rs index d22d79ecaa5..cc9cc2e3c03 100644 --- a/src/test/compile-fail/issue-17431-5.rs +++ b/src/test/compile-fail/issue-17431-5.rs @@ -8,8 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::marker; + struct Foo { foo: Bar<Foo> } -struct Bar<T> { x: Bar<Foo> } +struct Bar<T> { x: Bar<Foo> , marker: marker::PhantomData<T> } //~^ ERROR illegal recursive struct type; wrap the inner value in a box to make it representable impl Foo { fn foo(&self) {} } diff --git a/src/test/compile-fail/issue-17551.rs b/src/test/compile-fail/issue-17551.rs index e037ba92b4a..5781cb74117 100644 --- a/src/test/compile-fail/issue-17551.rs +++ b/src/test/compile-fail/issue-17551.rs @@ -10,9 +10,11 @@ #![feature(unboxed_closures)] -struct B<T>; +use std::marker; + +struct B<T>(marker::PhantomData<T>); fn main() { - let foo = B; //~ ERROR: unable to infer enough type information + let foo = B(marker::PhantomData); //~ ERROR unable to infer enough type information let closure = || foo; } diff --git a/src/test/compile-fail/issue-17718-const-mut.rs b/src/test/compile-fail/issue-17718-const-mut.rs deleted file mode 100644 index 5177ebbc188..00000000000 --- a/src/test/compile-fail/issue-17718-const-mut.rs +++ /dev/null @@ -1,18 +0,0 @@ -// 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. - -const -mut //~ ERROR: const globals cannot be mutable -//~^ HELP did you mean to declare a static? -FOO: usize = 3; - -fn main() { -} - diff --git a/src/test/compile-fail/attr.rs b/src/test/compile-fail/issue-17904-2.rs index 4bd61412731..a33ec23a16a 100644 --- a/src/test/compile-fail/attr.rs +++ b/src/test/compile-fail/issue-17904-2.rs @@ -8,9 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(lang_items)] +// Test that we can parse a unit struct with a where clause, even if +// it leads to a error later on since `T` is unused. -fn main() {} +struct Foo<T> where T: Copy; //~ ERROR parameter `T` is never used -#![lang(foo)] //~ ERROR an inner attribute is not permitted in this context -fn foo() {} +fn main() {} diff --git a/src/test/compile-fail/issue-1802-2.rs b/src/test/compile-fail/issue-1802-2.rs deleted file mode 100644 index f6da2fc82c3..00000000000 --- a/src/test/compile-fail/issue-1802-2.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2012 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. - -// error-pattern:no valid digits found for number -fn main() { - log(error, 0b_usize); -} diff --git a/src/test/compile-fail/issue-18107.rs b/src/test/compile-fail/issue-18107.rs index 91689988f58..d5fb22bdebd 100644 --- a/src/test/compile-fail/issue-18107.rs +++ b/src/test/compile-fail/issue-18107.rs @@ -8,9 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::marker::MarkerTrait; - -pub trait AbstractRenderer {} +pub trait AbstractRenderer : MarkerTrait {} fn _create_render(_: &()) -> AbstractRenderer diff --git a/src/test/compile-fail/issue-18611.rs b/src/test/compile-fail/issue-18611.rs index a662e9ca98e..e81a576fa63 100644 --- a/src/test/compile-fail/issue-18611.rs +++ b/src/test/compile-fail/issue-18611.rs @@ -8,11 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::marker::MarkerTrait; + fn add_state(op: <isize as HasState>::State) { //~^ ERROR the trait `HasState` is not implemented for the type `isize` } -trait HasState { +trait HasState : MarkerTrait { type State; } diff --git a/src/test/compile-fail/issue-18783.rs b/src/test/compile-fail/issue-18783.rs index 5ddf06add9d..13908bda9d8 100644 --- a/src/test/compile-fail/issue-18783.rs +++ b/src/test/compile-fail/issue-18783.rs @@ -26,6 +26,7 @@ fn ufcs() { Push::push(&c, box || y = 0); Push::push(&c, box || y = 0); +//~^ ERROR cannot borrow `y` as mutable more than once at a time } trait Push<'c> { diff --git a/src/test/compile-fail/issue-18819.rs b/src/test/compile-fail/issue-18819.rs index 3a9de741043..951d78410b8 100644 --- a/src/test/compile-fail/issue-18819.rs +++ b/src/test/compile-fail/issue-18819.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait Foo { +use std::marker::MarkerTrait; + +trait Foo : MarkerTrait { type Item; } diff --git a/src/test/compile-fail/issue-19660.rs b/src/test/compile-fail/issue-19660.rs index 14601e67a77..77aba7335bd 100644 --- a/src/test/compile-fail/issue-19660.rs +++ b/src/test/compile-fail/issue-19660.rs @@ -13,8 +13,12 @@ #![feature(lang_items, start, no_std)] #![no_std] +#[lang="phantom_fn"] +trait PhantomFn<A:?Sized,R:?Sized=()> { } +impl<A:?Sized, R:?Sized, U:?Sized> PhantomFn<A,R> for U { } + #[lang = "sized"] -trait Sized {} +trait Sized : PhantomFn<Self> {} #[start] fn main(_: int, _: *const *const u8) -> int { diff --git a/src/test/compile-fail/issue-2063.rs b/src/test/compile-fail/issue-2063.rs index 00607f85034..aed395d17ea 100644 --- a/src/test/compile-fail/issue-2063.rs +++ b/src/test/compile-fail/issue-2063.rs @@ -12,10 +12,11 @@ // cause compiler to loop. Note that no instances // of such a type could ever be constructed. +use std::marker::MarkerTrait; struct t(Box<t>); //~ ERROR this type cannot be instantiated -trait to_str_2 { +trait to_str_2 : MarkerTrait { fn my_to_string() -> String; } diff --git a/src/test/compile-fail/issue-20831-debruijn.rs b/src/test/compile-fail/issue-20831-debruijn.rs index aaf45f27398..5b623ac377b 100644 --- a/src/test/compile-fail/issue-20831-debruijn.rs +++ b/src/test/compile-fail/issue-20831-debruijn.rs @@ -13,10 +13,11 @@ // below. Note that changing to a named lifetime made the problem go // away. -use std::ops::{Shl, Shr}; use std::cell::RefCell; +use std::marker::MarkerTrait; +use std::ops::{Shl, Shr}; -pub trait Subscriber { +pub trait Subscriber : MarkerTrait { type Input; } diff --git a/src/test/compile-fail/issue-21160.rs b/src/test/compile-fail/issue-21160.rs index 45b7fbbd0b4..557bf518a3c 100644 --- a/src/test/compile-fail/issue-21160.rs +++ b/src/test/compile-fail/issue-21160.rs @@ -16,6 +16,6 @@ impl Bar { #[derive(Hash)] struct Foo(Bar); -//~^ error: the trait `core::hash::Hash<_>` is not implemented for the type `Bar` +//~^ error: the trait `core::hash::Hash` is not implemented for the type `Bar` fn main() {} diff --git a/src/test/compile-fail/issue-2611-4.rs b/src/test/compile-fail/issue-2611-4.rs index 31796e5e20c..24cc0099b89 100644 --- a/src/test/compile-fail/issue-2611-4.rs +++ b/src/test/compile-fail/issue-2611-4.rs @@ -12,7 +12,7 @@ // than the trait method it's implementing trait A { - fn b<C,D>(x: C) -> C; + fn b<C,D>(&self, x: C) -> C; } struct E { @@ -20,7 +20,7 @@ struct E { } impl A for E { - fn b<F: Sync, G>(_x: F) -> F { panic!() } + fn b<F: Sync, G>(&self, _x: F) -> F { panic!() } //~^ ERROR `F : core::marker::Sync` appears on the impl method } diff --git a/src/test/compile-fail/issue-3008-3.rs b/src/test/compile-fail/issue-3008-3.rs index a338a01690d..af6cee1f107 100644 --- a/src/test/compile-fail/issue-3008-3.rs +++ b/src/test/compile-fail/issue-3008-3.rs @@ -8,8 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::marker; + enum E1 { V1(E2<E1>), } -enum E2<T> { V2(E2<E1>), } +enum E2<T> { V2(E2<E1>, marker::PhantomData<T>), } //~^ ERROR illegal recursive enum type; wrap the inner value in a box to make it representable impl E1 { fn foo(&self) {} } diff --git a/src/test/compile-fail/issue-4972.rs b/src/test/compile-fail/issue-4972.rs index 9a398796d2a..f384dba7c9e 100644 --- a/src/test/compile-fail/issue-4972.rs +++ b/src/test/compile-fail/issue-4972.rs @@ -11,7 +11,9 @@ #![feature(box_patterns)] #![feature(box_syntax)] -trait MyTrait { } +trait MyTrait { + fn dummy(&self) {} +} pub enum TraitWrapper { A(Box<MyTrait+'static>), diff --git a/src/test/compile-fail/issue-5035-2.rs b/src/test/compile-fail/issue-5035-2.rs index 9e324cdd61e..d316b44794a 100644 --- a/src/test/compile-fail/issue-5035-2.rs +++ b/src/test/compile-fail/issue-5035-2.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait I {} +use std::marker::MarkerTrait; + +trait I : MarkerTrait {} type K = I+'static; fn foo(_x: K) {} //~ ERROR: the trait `core::marker::Sized` is not implemented diff --git a/src/test/compile-fail/issue-5543.rs b/src/test/compile-fail/issue-5543.rs index cf98f1572e5..4d721ad7666 100644 --- a/src/test/compile-fail/issue-5543.rs +++ b/src/test/compile-fail/issue-5543.rs @@ -10,7 +10,7 @@ #![feature(box_syntax)] -trait Foo {} +trait Foo { fn foo(&self) {} } impl Foo for u8 {} fn main() { diff --git a/src/test/compile-fail/issue-5544-a.rs b/src/test/compile-fail/issue-5544-a.rs deleted file mode 100644 index 95a4f36d171..00000000000 --- a/src/test/compile-fail/issue-5544-a.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2013 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. - -fn main() { - let __isize = 18446744073709551616; // 2^64 - //~^ ERROR int literal is too large -} diff --git a/src/test/compile-fail/issue-5544-b.rs b/src/test/compile-fail/issue-5544-b.rs deleted file mode 100644 index afff5984b46..00000000000 --- a/src/test/compile-fail/issue-5544-b.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2013 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. - -fn main() { - let __isize = 0xff_ffff_ffff_ffff_ffff__isize; - //~^ ERROR int literal is too large -} diff --git a/src/test/compile-fail/issue-5883.rs b/src/test/compile-fail/issue-5883.rs index 9ff957b6e6d..b0db9906195 100644 --- a/src/test/compile-fail/issue-5883.rs +++ b/src/test/compile-fail/issue-5883.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait A {} +use std::marker::MarkerTrait; + +trait A : MarkerTrait {} struct Struct { r: A+'static @@ -20,6 +22,6 @@ fn new_struct(r: A+'static) Struct { r: r } } -trait Curve {} +trait Curve : MarkerTrait {} enum E {X(Curve+'static)} fn main() {} diff --git a/src/test/compile-fail/issue-6458.rs b/src/test/compile-fail/issue-6458.rs index efa3100360b..0bf9a3c2d48 100644 --- a/src/test/compile-fail/issue-6458.rs +++ b/src/test/compile-fail/issue-6458.rs @@ -8,13 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -pub struct TypeWithState<State>; +use std::marker; + +pub struct TypeWithState<State>(marker::PhantomData<State>); pub struct MyState; pub fn foo<State>(_: TypeWithState<State>) {} pub fn bar() { - foo(TypeWithState); //~ ERROR type annotations required + foo(TypeWithState(marker::PhantomData)); //~ ERROR type annotations required } fn main() { diff --git a/src/test/compile-fail/issue-7575.rs b/src/test/compile-fail/issue-7575.rs index 9e6000c050a..b6643f43952 100644 --- a/src/test/compile-fail/issue-7575.rs +++ b/src/test/compile-fail/issue-7575.rs @@ -10,12 +10,14 @@ // Test the mechanism for warning about possible missing `self` declarations. +use std::marker::MarkerTrait; + trait CtxtFn { fn f8(self, usize) -> usize; fn f9(usize) -> usize; //~ NOTE candidate } -trait OtherTrait { +trait OtherTrait : MarkerTrait { fn f9(usize) -> usize; //~ NOTE candidate } @@ -24,7 +26,7 @@ trait OtherTrait { // declaration to match against, so we wind up prisizeing it as a // candidate. This seems not unreasonable -- perhaps the user meant to // implement it, after all. -trait UnusedTrait { +trait UnusedTrait : MarkerTrait { fn f9(usize) -> usize; //~ NOTE candidate } @@ -52,7 +54,7 @@ impl Myisize { } } -trait ManyImplTrait { +trait ManyImplTrait : MarkerTrait { fn is_str() -> bool { //~ NOTE candidate false } diff --git a/src/test/compile-fail/issue-8537.rs b/src/test/compile-fail/issue-8537.rs deleted file mode 100644 index 52cf420a9ff..00000000000 --- a/src/test/compile-fail/issue-8537.rs +++ /dev/null @@ -1,15 +0,0 @@ -// 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. - -pub extern - "invalid-ab_isize" //~ ERROR illegal ABI -fn foo() {} - -fn main() {} diff --git a/src/test/compile-fail/issue-8727.rs b/src/test/compile-fail/issue-8727.rs index d1a86d334cb..72da6dcaa6c 100644 --- a/src/test/compile-fail/issue-8727.rs +++ b/src/test/compile-fail/issue-8727.rs @@ -13,16 +13,12 @@ // Verify the compiler fails with an error on infinite function // recursions. -struct Data(Box<Option<Data>>); - -fn generic<T>( _ : Vec<(Data,T)> ) { - let rec : Vec<(Data,(bool,T))> = Vec::new(); - generic( rec ); +fn generic<T>() { + generic::<Option<T>>(); } fn main () { // Use generic<T> at least once to trigger instantiation. - let input : Vec<(Data,())> = Vec::new(); - generic(input); + generic::<i32>(); } diff --git a/src/test/compile-fail/keyword-as-as-identifier.rs b/src/test/compile-fail/keyword-as-as-identifier.rs deleted file mode 100644 index f307b12f66e..00000000000 --- a/src/test/compile-fail/keyword-as-as-identifier.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2013 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. - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py as' - -fn main() { - let as = "foo"; //~ error: ident -} diff --git a/src/test/compile-fail/keyword-break-as-identifier.rs b/src/test/compile-fail/keyword-break-as-identifier.rs deleted file mode 100644 index 1e2725eb2fe..00000000000 --- a/src/test/compile-fail/keyword-break-as-identifier.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2013 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. - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py break' - -fn main() { - let break = "foo"; //~ error: ident -} diff --git a/src/test/compile-fail/keyword-else-as-identifier.rs b/src/test/compile-fail/keyword-else-as-identifier.rs deleted file mode 100644 index 101fd938dcb..00000000000 --- a/src/test/compile-fail/keyword-else-as-identifier.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2013 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. - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py else' - -fn main() { - let else = "foo"; //~ error: ident -} diff --git a/src/test/compile-fail/keyword-enum-as-identifier.rs b/src/test/compile-fail/keyword-enum-as-identifier.rs deleted file mode 100644 index ed504cc7b7f..00000000000 --- a/src/test/compile-fail/keyword-enum-as-identifier.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2013 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. - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py enum' - -fn main() { - let enum = "foo"; //~ error: ident -} diff --git a/src/test/compile-fail/keyword-extern-as-identifier.rs b/src/test/compile-fail/keyword-extern-as-identifier.rs deleted file mode 100644 index 3260506b3e1..00000000000 --- a/src/test/compile-fail/keyword-extern-as-identifier.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2013 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. - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py extern' - -fn main() { - let extern = "foo"; //~ error: ident -} diff --git a/src/test/compile-fail/keyword-fn-as-identifier.rs b/src/test/compile-fail/keyword-fn-as-identifier.rs deleted file mode 100644 index 8c98da229c8..00000000000 --- a/src/test/compile-fail/keyword-fn-as-identifier.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2013 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. - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py fn' - -fn main() { - let fn = "foo"; //~ error: ident -} diff --git a/src/test/compile-fail/keyword-for-as-identifier.rs b/src/test/compile-fail/keyword-for-as-identifier.rs deleted file mode 100644 index 196a3390676..00000000000 --- a/src/test/compile-fail/keyword-for-as-identifier.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2013 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. - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py for' - -fn main() { - let for = "foo"; //~ error: ident -} diff --git a/src/test/compile-fail/keyword-if-as-identifier.rs b/src/test/compile-fail/keyword-if-as-identifier.rs deleted file mode 100644 index 05f82ec790c..00000000000 --- a/src/test/compile-fail/keyword-if-as-identifier.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2013 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. - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py if' - -fn main() { - let if = "foo"; //~ error: ident -} diff --git a/src/test/compile-fail/keyword-impl-as-identifier.rs b/src/test/compile-fail/keyword-impl-as-identifier.rs deleted file mode 100644 index 1dd21800345..00000000000 --- a/src/test/compile-fail/keyword-impl-as-identifier.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2013 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. - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py impl' - -fn main() { - let impl = "foo"; //~ error: ident -} diff --git a/src/test/compile-fail/keyword-let-as-identifier.rs b/src/test/compile-fail/keyword-let-as-identifier.rs deleted file mode 100644 index 0069a26a40b..00000000000 --- a/src/test/compile-fail/keyword-let-as-identifier.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2013 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. - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py let' - -fn main() { - let let = "foo"; //~ error: ident -} diff --git a/src/test/compile-fail/keyword-loop-as-identifier.rs b/src/test/compile-fail/keyword-loop-as-identifier.rs deleted file mode 100644 index 6e469e8c0b4..00000000000 --- a/src/test/compile-fail/keyword-loop-as-identifier.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2013 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. - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py loop' - -fn main() { - let loop = "foo"; //~ error: ident -} diff --git a/src/test/compile-fail/keyword-match-as-identifier.rs b/src/test/compile-fail/keyword-match-as-identifier.rs deleted file mode 100644 index 9155ebc71fa..00000000000 --- a/src/test/compile-fail/keyword-match-as-identifier.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2013 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. - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py match' - -fn main() { - let match = "foo"; //~ error: ident -} diff --git a/src/test/compile-fail/keyword-mod-as-identifier.rs b/src/test/compile-fail/keyword-mod-as-identifier.rs deleted file mode 100644 index 02f57e937dd..00000000000 --- a/src/test/compile-fail/keyword-mod-as-identifier.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2013 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. - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py mod' - -fn main() { - let mod = "foo"; //~ error: ident -} diff --git a/src/test/compile-fail/keyword-pub-as-identifier.rs b/src/test/compile-fail/keyword-pub-as-identifier.rs deleted file mode 100644 index aa679741c1c..00000000000 --- a/src/test/compile-fail/keyword-pub-as-identifier.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2013 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. - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py pub' - -fn main() { - let pub = "foo"; //~ error: ident -} diff --git a/src/test/compile-fail/keyword-return-as-identifier.rs b/src/test/compile-fail/keyword-return-as-identifier.rs deleted file mode 100644 index c5676445917..00000000000 --- a/src/test/compile-fail/keyword-return-as-identifier.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2013 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. - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py return' - -fn main() { - let return = "foo"; //~ error: ident -} diff --git a/src/test/compile-fail/keyword-self-as-identifier.rs b/src/test/compile-fail/keyword-self-as-identifier.rs deleted file mode 100644 index 8bb52142287..00000000000 --- a/src/test/compile-fail/keyword-self-as-identifier.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2013 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. - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py self' - -fn main() { - let self = "foo"; //~ error: ident -} diff --git a/src/test/compile-fail/keyword-static-as-identifier.rs b/src/test/compile-fail/keyword-static-as-identifier.rs deleted file mode 100644 index 7268c4f387e..00000000000 --- a/src/test/compile-fail/keyword-static-as-identifier.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2013 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. - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py static' - -fn main() { - let static = "foo"; //~ error: ident -} diff --git a/src/test/compile-fail/keyword-struct-as-identifier.rs b/src/test/compile-fail/keyword-struct-as-identifier.rs deleted file mode 100644 index bd42eac0ecb..00000000000 --- a/src/test/compile-fail/keyword-struct-as-identifier.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2013 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. - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py struct' - -fn main() { - let struct = "foo"; //~ error: ident -} diff --git a/src/test/compile-fail/keyword-super-as-identifier.rs b/src/test/compile-fail/keyword-super-as-identifier.rs deleted file mode 100644 index 0378c326a89..00000000000 --- a/src/test/compile-fail/keyword-super-as-identifier.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2013 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. - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py super' - -fn main() { - let super = "foo"; //~ error: ident -} diff --git a/src/test/compile-fail/keyword-super.rs b/src/test/compile-fail/keyword-super.rs deleted file mode 100644 index 0c94f76f1f6..00000000000 --- a/src/test/compile-fail/keyword-super.rs +++ /dev/null @@ -1,13 +0,0 @@ -// 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. - -fn main() { - let super: isize; //~ ERROR expected identifier, found keyword `super` -} diff --git a/src/test/compile-fail/keyword-trait-as-identifier.rs b/src/test/compile-fail/keyword-trait-as-identifier.rs deleted file mode 100644 index 95c0d174c33..00000000000 --- a/src/test/compile-fail/keyword-trait-as-identifier.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2013 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. - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py trait' - -fn main() { - let trait = "foo"; //~ error: ident -} diff --git a/src/test/compile-fail/keyword-type-as-identifier.rs b/src/test/compile-fail/keyword-type-as-identifier.rs deleted file mode 100644 index 0aaa2a63c7c..00000000000 --- a/src/test/compile-fail/keyword-type-as-identifier.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2013 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. - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py type' - -fn main() { - let type = "foo"; //~ error: ident -} diff --git a/src/test/compile-fail/keyword-unsafe-as-identifier.rs b/src/test/compile-fail/keyword-unsafe-as-identifier.rs deleted file mode 100644 index 1b631eb877d..00000000000 --- a/src/test/compile-fail/keyword-unsafe-as-identifier.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2013 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. - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py unsafe' - -fn main() { - let unsafe = "foo"; //~ error: ident -} diff --git a/src/test/compile-fail/keyword-use-as-identifier.rs b/src/test/compile-fail/keyword-use-as-identifier.rs deleted file mode 100644 index e82afd54442..00000000000 --- a/src/test/compile-fail/keyword-use-as-identifier.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2013 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. - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py use' - -fn main() { - let use = "foo"; //~ error: ident -} diff --git a/src/test/compile-fail/keyword-while-as-identifier.rs b/src/test/compile-fail/keyword-while-as-identifier.rs deleted file mode 100644 index 95cea65c610..00000000000 --- a/src/test/compile-fail/keyword-while-as-identifier.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2013 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. - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py while' - -fn main() { - let while = "foo"; //~ error: ident -} diff --git a/src/test/compile-fail/keyword.rs b/src/test/compile-fail/keyword.rs deleted file mode 100644 index 64eac47e69b..00000000000 --- a/src/test/compile-fail/keyword.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2012 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. - -pub mod break { - //~^ ERROR expected identifier, found keyword `break` -} diff --git a/src/test/compile-fail/keywords-followed-by-double-colon.rs b/src/test/compile-fail/keywords-followed-by-double-colon.rs deleted file mode 100644 index f69b041597e..00000000000 --- a/src/test/compile-fail/keywords-followed-by-double-colon.rs +++ /dev/null @@ -1,15 +0,0 @@ -// 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. - -fn main() { - struct::foo(); //~ ERROR expected identifier - mut::baz(); //~ ERROR expected identifier -} - diff --git a/src/test/compile-fail/kindck-copy.rs b/src/test/compile-fail/kindck-copy.rs index 56f83d93008..74e372e41eb 100644 --- a/src/test/compile-fail/kindck-copy.rs +++ b/src/test/compile-fail/kindck-copy.rs @@ -10,12 +10,12 @@ // Test which of the builtin types are considered POD. - +use std::marker::MarkerTrait; use std::rc::Rc; fn assert_copy<T:Copy>() { } -trait Dummy { } +trait Dummy : MarkerTrait { } #[derive(Copy)] struct MyStruct { diff --git a/src/test/compile-fail/kindck-impl-type-params-2.rs b/src/test/compile-fail/kindck-impl-type-params-2.rs index 2731be7308a..b575144f637 100644 --- a/src/test/compile-fail/kindck-impl-type-params-2.rs +++ b/src/test/compile-fail/kindck-impl-type-params-2.rs @@ -10,7 +10,9 @@ #![feature(box_syntax)] -trait Foo { +use std::marker::MarkerTrait; + +trait Foo : MarkerTrait { } impl<T:Copy> Foo for T { diff --git a/src/test/compile-fail/kindck-impl-type-params.rs b/src/test/compile-fail/kindck-impl-type-params.rs index d5276efa8be..dffc8fa2abd 100644 --- a/src/test/compile-fail/kindck-impl-type-params.rs +++ b/src/test/compile-fail/kindck-impl-type-params.rs @@ -13,40 +13,44 @@ #![feature(box_syntax)] -struct S<T>; +use std::marker; -trait Gettable<T> {} +struct S<T>(marker::PhantomData<T>); + +trait Gettable<T> { + fn get(&self) -> T { panic!() } +} impl<T: Send + Copy + 'static> Gettable<T> for S<T> {} fn f<T>(val: T) { - let t: S<T> = S; + let t: S<T> = S(marker::PhantomData); let a = &t as &Gettable<T>; //~^ ERROR the trait `core::marker::Send` is not implemented //~^^ ERROR the trait `core::marker::Copy` is not implemented } fn g<T>(val: T) { - let t: S<T> = S; + let t: S<T> = S(marker::PhantomData); let a: &Gettable<T> = &t; //~^ ERROR the trait `core::marker::Send` is not implemented //~^^ ERROR the trait `core::marker::Copy` is not implemented } fn foo<'a>() { - let t: S<&'a isize> = S; + let t: S<&'a isize> = S(marker::PhantomData); let a = &t as &Gettable<&'a isize>; - //~^ ERROR the type `&'a isize` does not fulfill the required lifetime + //~^ ERROR cannot infer } fn foo2<'a>() { - let t: Box<S<String>> = box S; + let t: Box<S<String>> = box S(marker::PhantomData); let a = t as Box<Gettable<String>>; //~^ ERROR the trait `core::marker::Copy` is not implemented } fn foo3<'a>() { - let t: Box<S<String>> = box S; + let t: Box<S<String>> = box S(marker::PhantomData); let a: Box<Gettable<String>> = t; //~^ ERROR the trait `core::marker::Copy` is not implemented } diff --git a/src/test/compile-fail/kindck-inherited-copy-bound.rs b/src/test/compile-fail/kindck-inherited-copy-bound.rs index e146cac21a3..0072b1228af 100644 --- a/src/test/compile-fail/kindck-inherited-copy-bound.rs +++ b/src/test/compile-fail/kindck-inherited-copy-bound.rs @@ -15,6 +15,7 @@ use std::any::Any; trait Foo : Copy { + fn foo(&self) {} } impl<T:Copy> Foo for T { diff --git a/src/test/compile-fail/kindck-send-object.rs b/src/test/compile-fail/kindck-send-object.rs index 570f7ad7fe3..0c68401bb2b 100644 --- a/src/test/compile-fail/kindck-send-object.rs +++ b/src/test/compile-fail/kindck-send-object.rs @@ -12,8 +12,10 @@ // in this file all test the "kind" violates detected during kindck. // See all `regions-bounded-by-send.rs` +use std::marker::MarkerTrait; + fn assert_send<T:Send>() { } -trait Dummy { } +trait Dummy : MarkerTrait { } trait Message : Send { } // careful with object types, who knows what they close over... diff --git a/src/test/compile-fail/kindck-send-object1.rs b/src/test/compile-fail/kindck-send-object1.rs index 48d5215b708..f86eac8b16b 100644 --- a/src/test/compile-fail/kindck-send-object1.rs +++ b/src/test/compile-fail/kindck-send-object1.rs @@ -12,8 +12,10 @@ // is broken into two parts because some errors occur in distinct // phases in the compiler. See kindck-send-object2.rs as well! +use std::marker::MarkerTrait; + fn assert_send<T:Send+'static>() { } -trait Dummy { } +trait Dummy : MarkerTrait { } // careful with object types, who knows what they close over... fn test51<'a>() { diff --git a/src/test/compile-fail/kindck-send-object2.rs b/src/test/compile-fail/kindck-send-object2.rs index d3d166e2a69..08516e67318 100644 --- a/src/test/compile-fail/kindck-send-object2.rs +++ b/src/test/compile-fail/kindck-send-object2.rs @@ -10,8 +10,10 @@ // Continue kindck-send-object1.rs. +use std::marker::MarkerTrait; + fn assert_send<T:Send>() { } -trait Dummy { } +trait Dummy : MarkerTrait { } fn test50() { assert_send::<&'static Dummy>(); //~ ERROR the trait `core::marker::Sync` is not implemented diff --git a/src/test/compile-fail/lex-bad-numeric-literals.rs b/src/test/compile-fail/lex-bad-numeric-literals.rs deleted file mode 100644 index 9a490be6a01..00000000000 --- a/src/test/compile-fail/lex-bad-numeric-literals.rs +++ /dev/null @@ -1,35 +0,0 @@ -// 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. - -fn main() { - 0o1.0; //~ ERROR: octal float literal is not supported - 0o2f32; //~ ERROR: octal float literal is not supported - 0o3.0f32; //~ ERROR: octal float literal is not supported - 0o4e4; //~ ERROR: octal float literal is not supported - 0o5.0e5; //~ ERROR: octal float literal is not supported - 0o6e6f32; //~ ERROR: octal float literal is not supported - 0o7.0e7f64; //~ ERROR: octal float literal is not supported - 0x8.0e+9; //~ ERROR: hexadecimal float literal is not supported - 0x9.0e-9; //~ ERROR: hexadecimal float literal is not supported - 0o; //~ ERROR: no valid digits - 1e+; //~ ERROR: expected at least one digit in exponent - 0x539.0; //~ ERROR: hexadecimal float literal is not supported - 99999999999999999999999999999999; //~ ERROR: int literal is too large - 99999999999999999999999999999999u32; //~ ERROR: int literal is too large - 0x; //~ ERROR: no valid digits - 0xu32; //~ ERROR: no valid digits - 0ou32; //~ ERROR: no valid digits - 0bu32; //~ ERROR: no valid digits - 0b; //~ ERROR: no valid digits - 0o123f64; //~ ERROR: octal float literal is not supported - 0o123.456; //~ ERROR: octal float literal is not supported - 0b101f64; //~ ERROR: binary float literal is not supported - 0b111.101; //~ ERROR: binary float literal is not supported -} diff --git a/src/test/compile-fail/lex-bare-cr-string-literal-doc-comment.rs b/src/test/compile-fail/lex-bare-cr-string-literal-doc-comment.rs deleted file mode 100644 index c1e5121d6dd..00000000000 --- a/src/test/compile-fail/lex-bare-cr-string-literal-doc-comment.rs +++ /dev/null @@ -1,30 +0,0 @@ -// 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. - -// ignore-tidy-cr - -/// doc comment with bare CR: ' ' -pub fn foo() {} -//~^^ ERROR: bare CR not allowed in doc-comment - -/** block doc comment with bare CR: ' ' */ -pub fn bar() {} -//~^^ ERROR: bare CR not allowed in block doc-comment - -fn main() { - // the following string literal has a bare CR in it - let _s = "foo bar"; //~ ERROR: bare CR not allowed in string - - // the following string literal has a bare CR in it - let _s = r"bar foo"; //~ ERROR: bare CR not allowed in raw string - - // the following string literal has a bare CR in it - let _s = "foo\ bar"; //~ ERROR: unknown character escape: \r -} diff --git a/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param-3.rs b/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param-3.rs index 04c5b223cb8..66d8927ee51 100644 --- a/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param-3.rs +++ b/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param-3.rs @@ -10,7 +10,9 @@ // ignore-tidy-linelength -struct Bar<'x, 'y, 'z> { bar: &'y i32, baz: i32 } +use std::marker::PhantomData; + +struct Bar<'x, 'y, 'z> { bar: &'y i32, baz: i32, marker: PhantomData<(&'x(),&'y(),&'z())> } fn bar1<'a>(x: &Bar) -> (&'a i32, &'a i32, &'a i32) { //~^ HELP: consider using an explicit lifetime parameter as shown: fn bar1<'b, 'c, 'a>(x: &'a Bar<'b, 'a, 'c>) -> (&'a i32, &'a i32, &'a i32) (x.bar, &x.baz, &x.baz) diff --git a/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param.rs b/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param.rs index c60e321219b..a85776a938b 100644 --- a/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param.rs +++ b/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param.rs @@ -10,7 +10,9 @@ // ignore-tidy-linelength -struct Foo<'x> { bar: isize } +use std::marker::PhantomData; + +struct Foo<'x> { bar: isize, marker: PhantomData<&'x ()> } fn foo1<'a>(x: &Foo) -> &'a isize { //~^ HELP: consider using an explicit lifetime parameter as shown: fn foo1<'a>(x: &'a Foo) -> &'a isize &x.bar //~ ERROR: cannot infer diff --git a/src/test/compile-fail/lifetime-no-keyword.rs b/src/test/compile-fail/lifetime-no-keyword.rs deleted file mode 100644 index 8ffbcd90df8..00000000000 --- a/src/test/compile-fail/lifetime-no-keyword.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2013 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. - -fn foo<'a>(a: &'a isize) { } -fn bar(a: &'static isize) { } -fn baz(a: &'let isize) { } //~ ERROR invalid lifetime name - -fn main() { } diff --git a/src/test/compile-fail/lifetime-obsoleted-self.rs b/src/test/compile-fail/lifetime-obsoleted-self.rs deleted file mode 100644 index 766922f2f88..00000000000 --- a/src/test/compile-fail/lifetime-obsoleted-self.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2013 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. - -fn baz(a: &'self isize) { } //~ ERROR invalid lifetime name: 'self is no longer a special lifetime - -fn main() { } diff --git a/src/test/compile-fail/lint-missing-doc.rs b/src/test/compile-fail/lint-missing-doc.rs index 3b96fd64fa2..73a58741bbb 100644 --- a/src/test/compile-fail/lint-missing-doc.rs +++ b/src/test/compile-fail/lint-missing-doc.rs @@ -47,20 +47,26 @@ fn foo3() {} /// dox pub trait A { /// dox - fn foo(); + fn foo(&self); /// dox - fn foo_with_impl() {} + fn foo_with_impl(&self) {} } + #[allow(missing_docs)] trait B { - fn foo(); - fn foo_with_impl() {} + fn foo(&self); + fn foo_with_impl(&self) {} } + pub trait C { //~ ERROR: missing documentation - fn foo(); //~ ERROR: missing documentation - fn foo_with_impl() {} //~ ERROR: missing documentation + fn foo(&self); //~ ERROR: missing documentation + fn foo_with_impl(&self) {} //~ ERROR: missing documentation +} + +#[allow(missing_docs)] +pub trait D { + fn dummy(&self) { } } -#[allow(missing_docs)] pub trait D {} impl Foo { pub fn foo() {} diff --git a/src/test/compile-fail/lint-non-camel-case-types.rs b/src/test/compile-fail/lint-non-camel-case-types.rs index 70d6b240985..9f58d5791cb 100644 --- a/src/test/compile-fail/lint-non-camel-case-types.rs +++ b/src/test/compile-fail/lint-non-camel-case-types.rs @@ -30,6 +30,7 @@ enum Foo5 { } trait foo6 { //~ ERROR trait `foo6` should have a camel case name such as `Foo6` + fn dummy(&self) { } } fn f<ty>(_: ty) {} //~ ERROR type parameter `ty` should have a camel case name such as `Ty` diff --git a/src/test/compile-fail/lint-stability.rs b/src/test/compile-fail/lint-stability.rs index f9cdfa4f7d6..88f2cbdea6d 100644 --- a/src/test/compile-fail/lint-stability.rs +++ b/src/test/compile-fail/lint-stability.rs @@ -341,7 +341,9 @@ mod this_crate { #[unstable(feature = "test_feature")] #[deprecated(since = "1.0.0")] - pub trait DeprecatedTrait {} + pub trait DeprecatedTrait { + fn dummy(&self) { } + } struct S; diff --git a/src/test/compile-fail/lint-visible-private-types.rs b/src/test/compile-fail/lint-visible-private-types.rs index 8cf375f80fb..918b4ee209c 100644 --- a/src/test/compile-fail/lint-visible-private-types.rs +++ b/src/test/compile-fail/lint-visible-private-types.rs @@ -12,8 +12,10 @@ #![allow(dead_code)] #![crate_type="lib"] -struct Private<T>; -pub struct Public<T>; +use std::marker; + +struct Private<T>(marker::PhantomData<T>); +pub struct Public<T>(marker::PhantomData<T>); impl Private<Public<isize>> { pub fn a(&self) -> Private<isize> { panic!() } @@ -103,7 +105,7 @@ impl PrivTrait for (Private<isize>,) { fn bar(&self) -> Private<isize> { panic!() } } -pub trait ParamTrait<T> { +pub trait ParamTrait<T> : marker::MarkerTrait { fn foo() -> T; } diff --git a/src/test/compile-fail/liveness-use-after-send.rs b/src/test/compile-fail/liveness-use-after-send.rs index a49339ecd7f..03d8d62e0b4 100644 --- a/src/test/compile-fail/liveness-use-after-send.rs +++ b/src/test/compile-fail/liveness-use-after-send.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::marker; + fn send<T:Send + std::fmt::Debug>(ch: _chan<T>, data: T) { println!("{:?}", ch); println!("{:?}", data); @@ -15,7 +17,7 @@ fn send<T:Send + std::fmt::Debug>(ch: _chan<T>, data: T) { } #[derive(Debug)] -struct _chan<T>(isize); +struct _chan<T>(isize, marker::PhantomData<T>); // Tests that "log(debug, message);" is flagged as using // message after the send deinitializes it diff --git a/src/test/compile-fail/macros-no-semicolon-items.rs b/src/test/compile-fail/macros-no-semicolon-items.rs deleted file mode 100644 index 314292085df..00000000000 --- a/src/test/compile-fail/macros-no-semicolon-items.rs +++ /dev/null @@ -1,14 +0,0 @@ -// 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. - -macro_rules! foo() //~ ERROR semicolon - -fn main() { -} diff --git a/src/test/compile-fail/map-types.rs b/src/test/compile-fail/map-types.rs index ba2205f5868..6e8719eeace 100644 --- a/src/test/compile-fail/map-types.rs +++ b/src/test/compile-fail/map-types.rs @@ -14,7 +14,10 @@ extern crate collections; use std::collections::HashMap; -trait Map<K, V> {} +trait Map<K, V> +{ + fn get(&self, k: K) -> V { panic!() } +} impl<K, V> Map<K, V> for HashMap<K, V> {} diff --git a/src/test/compile-fail/method-ambig-one-trait-coerce.rs b/src/test/compile-fail/method-ambig-one-trait-coerce.rs deleted file mode 100644 index cb5da4bb547..00000000000 --- a/src/test/compile-fail/method-ambig-one-trait-coerce.rs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2012 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 when we pick a trait based on coercion, versus subtyping, -// we consider all possible coercions equivalent and don't try to pick -// a best one. - -trait Object { } - -trait foo { - fn foo(self) -> isize; -} - -impl foo for Box<Object+'static> { - fn foo(self) -> isize {1} -} - -impl foo for Box<Object+Send> { - fn foo(self) -> isize {2} -} - -fn test1(x: Box<Object+Send+Sync>) { - // FIXME(#18737) -- we ought to consider this to be ambiguous, - // since we could coerce to either impl. However, what actually - // happens is that we consider both impls applicable because of - // incorrect subtyping relation. We then decide to call this a - // call to the `foo` trait, leading to the following error - // message. - - x.foo(); //~ ERROR `foo` is not implemented -} - -fn test2(x: Box<Object+Send>) { - // Not ambiguous because it is a precise match: - x.foo(); -} - -fn test3(x: Box<Object+'static>) { - // Not ambiguous because it is a precise match: - x.foo(); -} - -fn main() { } diff --git a/src/test/compile-fail/attr-before-stmt.rs b/src/test/compile-fail/mod_file_disambig.rs index ec837cd6de3..48bd00a3ee0 100644 --- a/src/test/compile-fail/attr-before-stmt.rs +++ b/src/test/compile-fail/mod_file_disambig.rs @@ -8,12 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:expected item - -fn f() { - #[foo = "bar"] - let x = 10; -} +mod mod_file_disambig_aux; //~ ERROR file for module `mod_file_disambig_aux` found at both fn main() { + assert_eq!(mod_file_aux::bar(), 10); } diff --git a/src/test/compile-fail/struct-variant-no-pub.rs b/src/test/compile-fail/mod_file_not_owning.rs index e62b39ad5aa..adbcedd91f2 100644 --- a/src/test/compile-fail/struct-variant-no-pub.rs +++ b/src/test/compile-fail/mod_file_not_owning.rs @@ -8,10 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -enum Foo { - Bar { - pub a: isize //~ ERROR: `pub` is not allowed here - } -} +// error-pattern: cannot declare a new module at this location + +mod mod_file_not_owning_aux1; fn main() {} diff --git a/src/test/compile-fail/no-binary-float-literal.rs b/src/test/compile-fail/no-binary-float-literal.rs deleted file mode 100644 index 2e207f90d36..00000000000 --- a/src/test/compile-fail/no-binary-float-literal.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2013 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. - -// error-pattern:binary float literal is not supported - -fn main() { - 0b101010f64; - 0b101.010; - 0b101p4f64; -} diff --git a/src/test/compile-fail/no-hex-float-literal.rs b/src/test/compile-fail/no-hex-float-literal.rs deleted file mode 100644 index 4abb6093b24..00000000000 --- a/src/test/compile-fail/no-hex-float-literal.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2013 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. - -// error-pattern:hexadecimal float literal is not supported - -fn main() { - 0xABC.Df; - 0x567.89; - 0xDEAD.BEEFp-2f; -} diff --git a/src/test/compile-fail/non-str-meta.rs b/src/test/compile-fail/non-str-meta.rs deleted file mode 100644 index 752f72f0b08..00000000000 --- a/src/test/compile-fail/non-str-meta.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 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. - -// Issue #623 - non-string meta items are not serialized correctly; -// for now just forbid them - -#[foo = 1] //~ ERROR: non-string literals are not allowed in meta-items -fn main() { } diff --git a/src/test/compile-fail/object-does-not-impl-trait.rs b/src/test/compile-fail/object-does-not-impl-trait.rs index cfaf149a49c..607ab13d122 100644 --- a/src/test/compile-fail/object-does-not-impl-trait.rs +++ b/src/test/compile-fail/object-does-not-impl-trait.rs @@ -11,8 +11,9 @@ // Test that an object type `Box<Foo>` is not considered to implement the // trait `Foo`. Issue #5087. +use std::marker::MarkerTrait; -trait Foo {} +trait Foo : MarkerTrait {} fn take_foo<F:Foo>(f: F) {} fn take_object(f: Box<Foo>) { take_foo(f); } //~^ ERROR the trait `Foo` is not implemented diff --git a/src/test/compile-fail/object-lifetime-default-mybox.rs b/src/test/compile-fail/object-lifetime-default-mybox.rs index c107c8d131d..23ddea4499a 100644 --- a/src/test/compile-fail/object-lifetime-default-mybox.rs +++ b/src/test/compile-fail/object-lifetime-default-mybox.rs @@ -37,7 +37,6 @@ fn load1<'a,'b>(a: &'a MyBox<SomeTrait>, a //~^ ERROR cannot infer //~| ERROR mismatched types - //~| ERROR mismatched types } fn main() { diff --git a/src/test/compile-fail/object-safety-issue-22040.rs b/src/test/compile-fail/object-safety-issue-22040.rs new file mode 100644 index 00000000000..edf32131b68 --- /dev/null +++ b/src/test/compile-fail/object-safety-issue-22040.rs @@ -0,0 +1,50 @@ +// Copyright 2015 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. + +// Regression test for #22040. + +use std::fmt::Debug; + +trait Expr: Debug + PartialEq { + fn print_element_count(&self); +} + +//#[derive(PartialEq)] +#[derive(Debug)] +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()); + let result = self.elements.len() == other.elements.len(); + + println!("Got compare {}", result); + return result; + } +} + +impl <'x> SExpr<'x> { + fn new() -> SExpr<'x> { return SExpr{elements: Vec::new(),}; } +} + +impl <'x> Expr for SExpr<'x> { + fn print_element_count(&self) { + println!("element count: {}", self.elements.len()); + } +} + +fn main() { + let a: Box<Expr> = Box::new(SExpr::new()); //~ ERROR trait `Expr` is not object-safe + let b: Box<Expr> = Box::new(SExpr::new()); //~ ERROR trait `Expr` is not object-safe + + assert_eq!(a , b); +} diff --git a/src/test/compile-fail/object-safety-no-static.rs b/src/test/compile-fail/object-safety-no-static.rs index 6a010d49692..aae829ec7b5 100644 --- a/src/test/compile-fail/object-safety-no-static.rs +++ b/src/test/compile-fail/object-safety-no-static.rs @@ -11,7 +11,7 @@ // Check that we correctly prevent users from making trait objects // from traits with static methods. -trait Foo { +trait Foo : ::std::marker::MarkerTrait { fn foo(); } diff --git a/src/test/compile-fail/where-clauses-no-bounds-or-predicates.rs b/src/test/compile-fail/object-safety-phantom-fn.rs index b96c7c2de6b..1c95ee43d27 100644 --- a/src/test/compile-fail/where-clauses-no-bounds-or-predicates.rs +++ b/src/test/compile-fail/object-safety-phantom-fn.rs @@ -8,16 +8,27 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn equal1<T>(_: &T, _: &T) -> bool where { -//~^ ERROR a `where` clause must have at least one predicate in it - true +// Check that `Self` appearing in a phantom fn does not make a trait not object safe. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +use std::marker::PhantomFn; + +trait Baz : PhantomFn<Self> { } -fn equal2<T>(_: &T, _: &T) -> bool where T: { -//~^ ERROR each predicate in a `where` clause must have at least one bound - true +trait Bar<T> : PhantomFn<(Self, T)> { } -fn main() { +fn make_bar<T:Bar<u32>>(t: &T) -> &Bar<u32> { + t } +fn make_baz<T:Baz>(t: &T) -> &Baz { + t +} + +#[rustc_error] +fn main() { //~ ERROR compilation successful +} diff --git a/src/test/compile-fail/issue-14182.rs b/src/test/compile-fail/object-safety-supertrait-mentions-Self.rs index 364951a4fea..d3f9dc73020 100644 --- a/src/test/compile-fail/issue-14182.rs +++ b/src/test/compile-fail/object-safety-supertrait-mentions-Self.rs @@ -8,20 +8,25 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-test FIXME(japari) remove test +// Check that we correctly prevent users from making trait objects +// form traits that make use of `Self` in an argument or return position. -struct Foo { - f: for <'b> |&'b isize|: - 'b -> &'b isize //~ ERROR use of undeclared lifetime name `'b` +trait Bar<T> { + fn bar(&self, x: &T); } -fn main() { - let mut x: Vec< for <'a> || - :'a //~ ERROR use of undeclared lifetime name `'a` - > = Vec::new(); - x.push(|| {}); +trait Baz : Bar<Self> { +} + +fn make_bar<T:Bar<u32>>(t: &T) -> &Bar<u32> { + t +} - let foo = Foo { - f: |x| x - }; +fn make_baz<T:Baz>(t: &T) -> &Baz { + t + //~^ ERROR `Baz` is not object-safe + //~| NOTE the trait cannot use `Self` as a type parameter in the supertrait listing +} + +fn main() { } diff --git a/src/test/compile-fail/obsolete-proc.rs b/src/test/compile-fail/obsolete-proc.rs deleted file mode 100644 index 5208cdb6ad2..00000000000 --- a/src/test/compile-fail/obsolete-proc.rs +++ /dev/null @@ -1,17 +0,0 @@ -// 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 generate obsolete syntax errors around usages of `proc`. - -fn foo(p: proc()) { } //~ ERROR obsolete syntax: the `proc` type - -fn bar() { proc() 1; } //~ ERROR obsolete syntax: `proc` expression - -fn main() { } diff --git a/src/test/compile-fail/on-unimplemented-bad-anno.rs b/src/test/compile-fail/on-unimplemented-bad-anno.rs index dda534cc489..7538b1c85e5 100644 --- a/src/test/compile-fail/on-unimplemented-bad-anno.rs +++ b/src/test/compile-fail/on-unimplemented-bad-anno.rs @@ -13,8 +13,12 @@ #![allow(unused)] +use std::marker; + #[rustc_on_unimplemented = "test error `{Self}` with `{Bar}` `{Baz}` `{Quux}`"] -trait Foo<Bar, Baz, Quux>{} +trait Foo<Bar, Baz, Quux> + : marker::PhantomFn<(Self,Bar,Baz,Quux)> +{} #[rustc_on_unimplemented="a collection of type `{Self}` cannot be built from an iterator over elements of type `{A}`"] trait MyFromIterator<A> { @@ -23,15 +27,21 @@ trait MyFromIterator<A> { } #[rustc_on_unimplemented] //~ ERROR this attribute must have a value -trait BadAnnotation1 {} +trait BadAnnotation1 + : marker::MarkerTrait +{} #[rustc_on_unimplemented = "Unimplemented trait error on `{Self}` with params `<{A},{B},{C}>`"] //~^ ERROR there is no type parameter C on trait BadAnnotation2 -trait BadAnnotation2<A,B> {} +trait BadAnnotation2<A,B> + : marker::PhantomFn<(Self,A,B)> +{} #[rustc_on_unimplemented = "Unimplemented trait error on `{Self}` with params `<{A},{B},{}>`"] //~^ only named substitution parameters are allowed -trait BadAnnotation3<A,B> {} +trait BadAnnotation3<A,B> + : marker::PhantomFn<(Self,A,B)> +{} pub fn main() { } diff --git a/src/test/compile-fail/on-unimplemented.rs b/src/test/compile-fail/on-unimplemented.rs index 7b406afcf1f..2447d086422 100644 --- a/src/test/compile-fail/on-unimplemented.rs +++ b/src/test/compile-fail/on-unimplemented.rs @@ -11,8 +11,12 @@ #![feature(on_unimplemented)] +use std::marker; + #[rustc_on_unimplemented = "test error `{Self}` with `{Bar}` `{Baz}` `{Quux}`"] -trait Foo<Bar, Baz, Quux>{} +trait Foo<Bar, Baz, Quux> + : marker::PhantomFn<(Self,Bar,Baz,Quux)> +{} fn foobar<U: Clone, T: Foo<u8, U, u32>>() -> T { diff --git a/src/test/compile-fail/orphan-check-diagnostics.rs b/src/test/compile-fail/orphan-check-diagnostics.rs index ff5c101b917..8201565c331 100644 --- a/src/test/compile-fail/orphan-check-diagnostics.rs +++ b/src/test/compile-fail/orphan-check-diagnostics.rs @@ -15,7 +15,7 @@ extern crate orphan_check_diagnostics; use orphan_check_diagnostics::RemoteTrait; -trait LocalTrait {} +trait LocalTrait { fn dummy(&self) { } } impl<T> RemoteTrait for T where T: LocalTrait {} //~^ ERROR type parameter `T` must be used as the type parameter for some local type diff --git a/src/test/compile-fail/priv-in-bad-locations.rs b/src/test/compile-fail/priv-in-bad-locations.rs index db649ed0cc6..43d112b8aa0 100644 --- a/src/test/compile-fail/priv-in-bad-locations.rs +++ b/src/test/compile-fail/priv-in-bad-locations.rs @@ -14,7 +14,7 @@ pub extern { } trait A { - fn foo() {} + fn foo(&self) {} } struct B; @@ -22,7 +22,7 @@ struct B; pub impl B {} //~ ERROR: unnecessary visibility pub impl A for B { //~ ERROR: unnecessary visibility - pub fn foo() {} //~ ERROR: unnecessary visibility + pub fn foo(&self) {} //~ ERROR: unnecessary visibility } pub fn main() {} diff --git a/src/test/compile-fail/privacy-ns2.rs b/src/test/compile-fail/privacy-ns2.rs index 7fe0574ab7d..67bb566ea68 100644 --- a/src/test/compile-fail/privacy-ns2.rs +++ b/src/test/compile-fail/privacy-ns2.rs @@ -17,7 +17,9 @@ // public type, private value pub mod foo1 { - pub trait Bar { + use std::marker::MarkerTrait; + + pub trait Bar : MarkerTrait { } pub struct Baz; @@ -39,7 +41,7 @@ fn test_list1() { // private type, public value pub mod foo2 { - trait Bar { + trait Bar : ::std::marker::MarkerTrait { } pub struct Baz; @@ -60,7 +62,7 @@ fn test_list2() { // neither public pub mod foo3 { - trait Bar { + trait Bar : ::std::marker::MarkerTrait { } pub struct Baz; diff --git a/src/test/compile-fail/privacy1.rs b/src/test/compile-fail/privacy1.rs index 7ebbcc2809a..1ae79adbad7 100644 --- a/src/test/compile-fail/privacy1.rs +++ b/src/test/compile-fail/privacy1.rs @@ -11,11 +11,15 @@ #![feature(lang_items, start, no_std)] #![no_std] // makes debugging this test *a lot* easier (during resolve) +#[lang="phantom_fn"] +pub trait PhantomFn<A:?Sized,R:?Sized=()> { } +impl<A:?Sized, R:?Sized, U:?Sized> PhantomFn<A,R> for U { } + #[lang="sized"] -pub trait Sized {} +pub trait Sized : PhantomFn<Self> {} #[lang="copy"] -pub trait Copy {} +pub trait Copy : PhantomFn<Self> {} mod bar { // shouldn't bring in too much diff --git a/src/test/compile-fail/privacy4.rs b/src/test/compile-fail/privacy4.rs index bcb46663aa8..adce93af079 100644 --- a/src/test/compile-fail/privacy4.rs +++ b/src/test/compile-fail/privacy4.rs @@ -11,8 +11,12 @@ #![feature(lang_items, start, no_std)] #![no_std] // makes debugging this test *a lot* easier (during resolve) -#[lang = "sized"] pub trait Sized {} -#[lang="copy"] pub trait Copy {} +#[lang="phantom_fn"] +pub trait PhantomFn<A:?Sized,R:?Sized=()> { } +impl<A:?Sized, R:?Sized, U:?Sized> PhantomFn<A,R> for U { } + +#[lang = "sized"] pub trait Sized : PhantomFn<Self> {} +#[lang="copy"] pub trait Copy : PhantomFn<Self> {} // Test to make sure that private items imported through globs remain private // when they're used. diff --git a/src/test/compile-fail/qquote-1.rs b/src/test/compile-fail/qquote-1.rs deleted file mode 100644 index deae9a83866..00000000000 --- a/src/test/compile-fail/qquote-1.rs +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2012-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. - -// ignore-test Can't use syntax crate here - -#![feature(quote)] - -extern crate syntax; - -use io::*; - -use syntax::diagnostic; -use syntax::ast; -use syntax::codemap; -use syntax::parse; -use syntax::print::*; - - -trait fake_ext_ctxt { - fn cfg() -> ast::CrateConfig; - fn parse_sess() -> parse::parse_sess; - fn call_site() -> span; - fn ident_of(st: &str) -> ast::ident; -} - -type fake_session = parse::parse_sess; - -impl fake_ext_ctxt for fake_session { - fn cfg() -> ast::CrateConfig { Vec::new() } - fn parse_sess() -> parse::parse_sess { self } - fn call_site() -> span { - codemap::span { - lo: codemap::BytePos(0), - hi: codemap::BytePos(0), - expn_id: NO_EXPANSION - } - } - fn ident_of(st: &str) -> ast::ident { - self.interner.intern(st) - } -} - -fn mk_ctxt() -> fake_ext_ctxt { - parse::new_parse_sess(None) as fake_ext_ctxt -} - - - -fn main() { - let cx = mk_ctxt(); - - let abc = quote_expr!(cx, 23); - check_pp(abc, pprust::print_expr, "23"); - - let expr3 = quote_expr!(cx, 2 - $abcd + 7); //~ ERROR unresolved name: abcd - check_pp(expr3, pprust::print_expr, "2 - 23 + 7"); -} - -fn check_pp<T>(expr: T, f: |pprust::ps, T|, expect: str) { - panic!(); -} diff --git a/src/test/compile-fail/qquote-2.rs b/src/test/compile-fail/qquote-2.rs deleted file mode 100644 index 978287a681e..00000000000 --- a/src/test/compile-fail/qquote-2.rs +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2012-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. - -// ignore-test Can't use syntax crate here - -#![feature(quote)] - -extern crate syntax; - -use syntax::diagnostic; -use syntax::ast; -use syntax::codemap; -use syntax::parse::parser; -use syntax::print::*; - -trait fake_ext_ctxt { - fn cfg() -> ast::CrateConfig; - fn parse_sess() -> parse::parse_sess; - fn call_site() -> span; - fn ident_of(st: &str) -> ast::ident; -} - -type fake_session = parse::parse_sess; - -impl fake_ext_ctxt for fake_session { - fn cfg() -> ast::CrateConfig { Vec::new() } - fn parse_sess() -> parse::parse_sess { self } - fn call_site() -> span { - codemap::span { - lo: codemap::BytePos(0), - hi: codemap::BytePos(0), - expn_id: codemap::NO_EXPANSION - } - } - fn ident_of(st: &str) -> ast::ident { - self.interner.intern(st) - } -} - -fn mk_ctxt() -> fake_ext_ctxt { - parse::new_parse_sess(None) as fake_ext_ctxt -} - - -fn main() { - let cx = mk_ctxt(); - - let stmt = quote_stmt!(cx, let x isize = 20;); //~ ERROR expected end-of-string - check_pp(*stmt, pprust::print_stmt, ""); -} - -fn check_pp<T>(expr: T, f: |pprust::ps, T|, expect: str) { - panic!(); -} diff --git a/src/test/compile-fail/region-object-lifetime-in-coercion.rs b/src/test/compile-fail/region-object-lifetime-in-coercion.rs index 20cc624ab19..2da414befd8 100644 --- a/src/test/compile-fail/region-object-lifetime-in-coercion.rs +++ b/src/test/compile-fail/region-object-lifetime-in-coercion.rs @@ -13,7 +13,7 @@ #![feature(box_syntax)] -trait Foo {} +trait Foo : ::std::marker::MarkerTrait {} impl<'a> Foo for &'a [u8] {} fn a(v: &[u8]) -> Box<Foo + 'static> { diff --git a/src/test/compile-fail/regions-assoc-type-in-supertrait-outlives-container.rs b/src/test/compile-fail/regions-assoc-type-in-supertrait-outlives-container.rs index fa26c9c54c8..6aa0cc003ce 100644 --- a/src/test/compile-fail/regions-assoc-type-in-supertrait-outlives-container.rs +++ b/src/test/compile-fail/regions-assoc-type-in-supertrait-outlives-container.rs @@ -15,15 +15,12 @@ #![allow(dead_code)] -use std::mem::transmute; -use std::ops::Deref; +use std::marker::PhantomFn; /////////////////////////////////////////////////////////////////////////// -pub trait TheTrait { +pub trait TheTrait: PhantomFn<Self, Self> { type TheAssocType; - - fn dummy(&self) { } } pub trait TheSubTrait : TheTrait { diff --git a/src/test/compile-fail/regions-assoc-type-outlives-container-hrtb.rs b/src/test/compile-fail/regions-assoc-type-outlives-container-hrtb.rs index 7d955065ff4..9736910d7b5 100644 --- a/src/test/compile-fail/regions-assoc-type-outlives-container-hrtb.rs +++ b/src/test/compile-fail/regions-assoc-type-outlives-container-hrtb.rs @@ -14,12 +14,12 @@ #![allow(dead_code)] #![feature(rustc_attrs)] +use std::marker::PhantomFn; + /////////////////////////////////////////////////////////////////////////// -pub trait TheTrait<'b> { +pub trait TheTrait<'b> : PhantomFn<&'b Self,Self> { type TheAssocType; - - fn dummy(&'b self) { } } pub struct TheType<'b> { diff --git a/src/test/compile-fail/regions-assoc-type-outlives-container-wc.rs b/src/test/compile-fail/regions-assoc-type-outlives-container-wc.rs index 6ee65fbdf91..da7546ce21c 100644 --- a/src/test/compile-fail/regions-assoc-type-outlives-container-wc.rs +++ b/src/test/compile-fail/regions-assoc-type-outlives-container-wc.rs @@ -15,15 +15,12 @@ #![allow(dead_code)] -use std::mem::transmute; -use std::ops::Deref; +use std::marker::PhantomFn; /////////////////////////////////////////////////////////////////////////// -pub trait TheTrait { +pub trait TheTrait: PhantomFn<Self, Self> { type TheAssocType; - - fn dummy(&self) { } } pub struct TheType<'b> { diff --git a/src/test/compile-fail/regions-assoc-type-outlives-container.rs b/src/test/compile-fail/regions-assoc-type-outlives-container.rs index 49a0726fa3b..e1e72e6f56e 100644 --- a/src/test/compile-fail/regions-assoc-type-outlives-container.rs +++ b/src/test/compile-fail/regions-assoc-type-outlives-container.rs @@ -13,16 +13,14 @@ // outlive the location in which the type appears. Issue #22246. #![allow(dead_code)] +#![feature(rustc_attrs)] -use std::mem::transmute; -use std::ops::Deref; +use std::marker::PhantomFn; /////////////////////////////////////////////////////////////////////////// -pub trait TheTrait { +pub trait TheTrait: PhantomFn<Self, Self> { type TheAssocType; - - fn dummy(&self) { } } pub struct TheType<'b> { diff --git a/src/test/compile-fail/regions-assoc-type-region-bound-in-trait-not-met.rs b/src/test/compile-fail/regions-assoc-type-region-bound-in-trait-not-met.rs index f833361e3b5..f921eccef1f 100644 --- a/src/test/compile-fail/regions-assoc-type-region-bound-in-trait-not-met.rs +++ b/src/test/compile-fail/regions-assoc-type-region-bound-in-trait-not-met.rs @@ -11,7 +11,10 @@ // Test that the compiler checks that arbitrary region bounds declared // in the trait must be satisfied on the impl. Issue #20890. -trait Foo<'a> { type Value: 'a; } +trait Foo<'a> { + type Value: 'a; + fn dummy(&'a self) { } +} impl<'a> Foo<'a> for &'a i16 { // OK. diff --git a/src/test/compile-fail/regions-assoc-type-static-bound-in-trait-not-met.rs b/src/test/compile-fail/regions-assoc-type-static-bound-in-trait-not-met.rs index 0871d8b01f6..1cf83b8ac58 100644 --- a/src/test/compile-fail/regions-assoc-type-static-bound-in-trait-not-met.rs +++ b/src/test/compile-fail/regions-assoc-type-static-bound-in-trait-not-met.rs @@ -11,7 +11,10 @@ // Test that the compiler checks that the 'static bound declared in // the trait must be satisfied on the impl. Issue #20890. -trait Foo { type Value: 'static; } +trait Foo { + type Value: 'static; + fn dummy(&self) { } +} impl<'a> Foo for &'a i32 { //~^ ERROR cannot infer diff --git a/src/test/compile-fail/regions-bound-missing-bound-in-impl.rs b/src/test/compile-fail/regions-bound-missing-bound-in-impl.rs index a3c38dff6b0..278ccd3c119 100644 --- a/src/test/compile-fail/regions-bound-missing-bound-in-impl.rs +++ b/src/test/compile-fail/regions-bound-missing-bound-in-impl.rs @@ -21,10 +21,9 @@ pub trait Foo<'a, 't> { fn has_bound<'b:'a>(self, b: Inv<'b>); fn wrong_bound1<'b,'c,'d:'a+'b>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>); fn okay_bound<'b,'c,'d:'a+'b+'c>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>); - fn another_bound<'x: 'a>(self, x: Inv<'x>); + fn another_bound<'x: 'a>(self, x: Inv<'x>, y: Inv<'t>); } - impl<'a, 't> Foo<'a, 't> for &'a isize { fn no_bound<'b:'a>(self, b: Inv<'b>) { //~^ ERROR lifetime parameters or bounds on method `no_bound` do not match @@ -51,7 +50,7 @@ impl<'a, 't> Foo<'a, 't> for &'a isize { fn okay_bound<'b,'c,'e:'b+'c>(self, b: Inv<'b>, c: Inv<'c>, e: Inv<'e>) { } - fn another_bound<'x: 't>(self, x: Inv<'x>) {} + fn another_bound<'x: 't>(self, x: Inv<'x>, y: Inv<'t>) {} } fn main() { } diff --git a/src/test/compile-fail/regions-bounded-method-type-parameters-trait-bound.rs b/src/test/compile-fail/regions-bounded-method-type-parameters-trait-bound.rs index 74c2c6e584b..f13d8a60894 100644 --- a/src/test/compile-fail/regions-bounded-method-type-parameters-trait-bound.rs +++ b/src/test/compile-fail/regions-bounded-method-type-parameters-trait-bound.rs @@ -8,16 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(lang_items, no_std)] -#![no_std] - // Check that explicit region bounds are allowed on the various // nominal types (but not on other types) and that they are type // checked. -#[lang="sized"] -trait Sized { } - struct Inv<'a> { // invariant w/r/t 'a x: &'a mut &'a isize } diff --git a/src/test/compile-fail/regions-close-associated-type-into-object.rs b/src/test/compile-fail/regions-close-associated-type-into-object.rs index 8a03f36972d..979c1e997d0 100644 --- a/src/test/compile-fail/regions-close-associated-type-into-object.rs +++ b/src/test/compile-fail/regions-close-associated-type-into-object.rs @@ -10,7 +10,9 @@ #![feature(box_syntax)] -trait X {} +use std::marker::MarkerTrait; + +trait X : MarkerTrait {} trait Iter { type Item: X; diff --git a/src/test/compile-fail/regions-close-object-into-object-1.rs b/src/test/compile-fail/regions-close-object-into-object-1.rs index 7a0e3cf4611..7bbce7dad53 100644 --- a/src/test/compile-fail/regions-close-object-into-object-1.rs +++ b/src/test/compile-fail/regions-close-object-into-object-1.rs @@ -11,13 +11,16 @@ #![feature(box_syntax)] #![allow(warnings)] -trait A<T> {} +use std::marker::PhantomFn; + +trait A<T> : PhantomFn<(Self,T)> { } struct B<'a, T>(&'a (A<T>+'a)); -trait X {} +trait X : ::std::marker::MarkerTrait {} + impl<'a, T> X for B<'a, T> {} -fn f<'a, T, U>(v: Box<A<T>+'static>) -> Box<X+'static> { +fn f<'a, T:'static, U>(v: Box<A<T>+'static>) -> Box<X+'static> { box B(&*v) as Box<X> //~ ERROR `*v` does not live long enough } diff --git a/src/test/compile-fail/regions-close-object-into-object-2.rs b/src/test/compile-fail/regions-close-object-into-object-2.rs index 7861fb95fef..6de49020a6f 100644 --- a/src/test/compile-fail/regions-close-object-into-object-2.rs +++ b/src/test/compile-fail/regions-close-object-into-object-2.rs @@ -10,10 +10,12 @@ #![feature(box_syntax)] -trait A<T> {} +use std::marker::PhantomFn; + +trait A<T> : PhantomFn<(Self,T)> { } struct B<'a, T>(&'a (A<T>+'a)); -trait X {} +trait X : PhantomFn<Self> {} impl<'a, T> X for B<'a, T> {} fn g<'a, T: 'static>(v: Box<A<T>+'a>) -> Box<X+'static> { diff --git a/src/test/compile-fail/regions-close-object-into-object-3.rs b/src/test/compile-fail/regions-close-object-into-object-3.rs index 31354de2a27..e22d0c7d0a4 100644 --- a/src/test/compile-fail/regions-close-object-into-object-3.rs +++ b/src/test/compile-fail/regions-close-object-into-object-3.rs @@ -11,10 +11,12 @@ #![feature(box_syntax)] #![allow(warnings)] -trait A<T> {} +use std::marker::PhantomFn; + +trait A<T> : PhantomFn<(Self,T)> {} struct B<'a, T>(&'a (A<T>+'a)); -trait X {} +trait X : PhantomFn<Self> {} impl<'a, T> X for B<'a, T> {} fn h<'a, T, U>(v: Box<A<U>+'static>) -> Box<X+'static> { diff --git a/src/test/compile-fail/regions-close-object-into-object-4.rs b/src/test/compile-fail/regions-close-object-into-object-4.rs index c60975f97e1..147a575d38c 100644 --- a/src/test/compile-fail/regions-close-object-into-object-4.rs +++ b/src/test/compile-fail/regions-close-object-into-object-4.rs @@ -10,10 +10,12 @@ #![feature(box_syntax)] -trait A<T> {} +use std::marker::PhantomFn; + +trait A<T> : PhantomFn<(Self,T)> {} struct B<'a, T>(&'a (A<T>+'a)); -trait X {} +trait X : PhantomFn<Self> {} impl<'a, T> X for B<'a, T> {} fn i<'a, T, U>(v: Box<A<U>+'a>) -> Box<X+'static> { diff --git a/src/test/compile-fail/issue-17383.rs b/src/test/compile-fail/regions-close-object-into-object-5.rs index c71e0ecd494..bdc52eca2cb 100644 --- a/src/test/compile-fail/issue-17383.rs +++ b/src/test/compile-fail/regions-close-object-into-object-5.rs @@ -8,11 +8,23 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -enum X { - A = - b'a' //~ ERROR discriminator values can only be used with a c-like enum - , - B(isize) +#![feature(box_syntax)] +#![allow(warnings)] + +trait A<T> +{ + fn get(&self) -> T { panic!() } +} + +struct B<'a, T>(&'a (A<T>+'a)); + +trait X { fn foo(&self) {} } + +impl<'a, T> X for B<'a, T> {} + +fn f<'a, T, U>(v: Box<A<T>+'static>) -> Box<X+'static> { + box B(&*v) as Box<X> //~ ERROR the parameter type `T` may not live long enough } fn main() {} + diff --git a/src/test/compile-fail/regions-close-over-borrowed-ref-in-obj.rs b/src/test/compile-fail/regions-close-over-borrowed-ref-in-obj.rs index 25b8137d29c..2341d2397c9 100644 --- a/src/test/compile-fail/regions-close-over-borrowed-ref-in-obj.rs +++ b/src/test/compile-fail/regions-close-over-borrowed-ref-in-obj.rs @@ -10,7 +10,9 @@ #![feature(box_syntax)] -trait Foo { } +use std::marker::MarkerTrait; + +trait Foo : MarkerTrait { } impl<'a> Foo for &'a isize { } diff --git a/src/test/compile-fail/regions-close-param-into-object.rs b/src/test/compile-fail/regions-close-param-into-object.rs index 74b36958c92..655ac6f66c9 100644 --- a/src/test/compile-fail/regions-close-param-into-object.rs +++ b/src/test/compile-fail/regions-close-param-into-object.rs @@ -10,7 +10,7 @@ #![feature(box_syntax)] -trait X {} +trait X { fn foo(&self) {} } fn p1<T>(v: T) -> Box<X+'static> where T : X diff --git a/src/test/compile-fail/regions-fn-bound.rs b/src/test/compile-fail/regions-fn-bound.rs deleted file mode 100644 index c2b52b79f6c..00000000000 --- a/src/test/compile-fail/regions-fn-bound.rs +++ /dev/null @@ -1,46 +0,0 @@ -// 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. - -// ignore-test -// ignored because the first error does not show up. - -// Copyright 2012 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. - -fn of<T>() -> |T| { panic!(); } -fn subtype<T>(x: |T|) { panic!(); } - -fn test_fn<'x, 'y, 'z, T>(_x: &'x T, _y: &'y T, _z: &'z T) { - // Here, x, y, and z are free. Other letters - // are bound. Note that the arrangement - // subtype::<T1>(of::<T2>()) will typecheck - // iff T1 <: T2. - - // should be the default: - subtype::< ||:'static>(of::<||>()); - subtype::<||>(of::< ||:'static>()); - - // - subtype::< <'x> ||>(of::<||>()); //~ ERROR mismatched types - subtype::< <'x> ||>(of::< <'y> ||>()); //~ ERROR mismatched types - - subtype::< <'x> ||>(of::< ||:'static>()); //~ ERROR mismatched types - subtype::< ||:'static>(of::< <'x> ||>()); - -} - -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 6c5e90a54de..b7ef19d1e3b 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 @@ -20,7 +20,7 @@ use std::marker; // Contravariant<'foo> <: Contravariant<'static> because // 'foo <= 'static struct Contravariant<'a> { - marker: marker::ContravariantLifetime<'a> + marker: marker::PhantomData<&'a()> } fn use_<'short,'long>(c: Contravariant<'short>, 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 d8e31fa1374..0d3d9dacbd6 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 @@ -17,7 +17,7 @@ use std::marker; struct Covariant<'a> { - marker: marker::CovariantLifetime<'a> + marker: marker::PhantomData<fn(&'a ())> } fn use_<'short,'long>(c: Covariant<'long>, diff --git a/src/test/compile-fail/regions-infer-invariance-due-to-decl.rs b/src/test/compile-fail/regions-infer-invariance-due-to-decl.rs index e88c96de9e4..8c191fbd5bb 100644 --- a/src/test/compile-fail/regions-infer-invariance-due-to-decl.rs +++ b/src/test/compile-fail/regions-infer-invariance-due-to-decl.rs @@ -11,7 +11,7 @@ use std::marker; struct invariant<'a> { - marker: marker::InvariantLifetime<'a> + marker: marker::PhantomData<*mut &'a()> } fn to_same_lifetime<'r>(b_isize: invariant<'r>) { diff --git a/src/test/compile-fail/required-lang-item.rs b/src/test/compile-fail/required-lang-item.rs index 7d252604883..1b749faf1b8 100644 --- a/src/test/compile-fail/required-lang-item.rs +++ b/src/test/compile-fail/required-lang-item.rs @@ -11,7 +11,11 @@ #![feature(lang_items, no_std)] #![no_std] -#[lang="sized"] pub trait Sized {} +#[lang="phantom_fn"] +pub trait PhantomFn<T:?Sized> { } +impl<T:?Sized, U:?Sized> PhantomFn<T> for U { } + +#[lang="sized"] pub trait Sized : PhantomFn<Self> {} // error-pattern:requires `start` lang_item diff --git a/src/test/compile-fail/shadowed-type-parameter.rs b/src/test/compile-fail/shadowed-type-parameter.rs index 1a3d7821159..1f72db1e894 100644 --- a/src/test/compile-fail/shadowed-type-parameter.rs +++ b/src/test/compile-fail/shadowed-type-parameter.rs @@ -12,19 +12,21 @@ #![feature(box_syntax)] -struct Foo<T>; +struct Foo<T>(T); impl<T> Foo<T> { fn shadow_in_method<T>(&self) {} //~^ ERROR type parameter `T` shadows another type parameter fn not_shadow_in_item<U>(&self) { - struct Bar<T, U>; // not a shadow, separate item + struct Bar<T, U>(T,U); // not a shadow, separate item fn foo<T, U>() {} // same } } trait Bar<T> { + fn dummy(&self) -> T; + fn shadow_in_required<T>(&self); //~^ ERROR type parameter `T` shadows another type parameter diff --git a/src/test/compile-fail/slice-1.rs b/src/test/compile-fail/slice-1.rs index 23ad5b09950..3b992e3bcc3 100644 --- a/src/test/compile-fail/slice-1.rs +++ b/src/test/compile-fail/slice-1.rs @@ -9,14 +9,12 @@ // except according to those terms. // Test slicing &expr[] is deprecated and gives a helpful error message. -// -// ignore-test struct Foo; fn main() { let x = Foo; - &x[]; //~ WARNING deprecated slicing syntax: `[]` - //~^ NOTE use `&expr[..]` to construct a slice of the whole of expr - //~^^ ERROR cannot index a value of type `Foo` + &x[]; + //~^ WARN obsolete syntax + //~| ERROR cannot index } diff --git a/src/test/compile-fail/slightly-nice-generic-literal-messages.rs b/src/test/compile-fail/slightly-nice-generic-literal-messages.rs index 1203d622348..3c1c3796a24 100644 --- a/src/test/compile-fail/slightly-nice-generic-literal-messages.rs +++ b/src/test/compile-fail/slightly-nice-generic-literal-messages.rs @@ -8,10 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct Foo<T,U>(T); +use std::marker; + +struct Foo<T,U>(T, marker::PhantomData<U>); fn main() { - match Foo(1.1) { + match Foo(1.1, marker::PhantomData) { 1 => {} //~^ ERROR mismatched types //~| expected `Foo<_, _>` diff --git a/src/test/compile-fail/staticness-mismatch.rs b/src/test/compile-fail/staticness-mismatch.rs index bf4e46cace3..2dfc9b79ee2 100644 --- a/src/test/compile-fail/staticness-mismatch.rs +++ b/src/test/compile-fail/staticness-mismatch.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - trait foo { + fn dummy(&self) { } fn bar(); } diff --git a/src/test/compile-fail/struct-no-fields-2.rs b/src/test/compile-fail/struct-no-fields-2.rs deleted file mode 100644 index 4f973f81b16..00000000000 --- a/src/test/compile-fail/struct-no-fields-2.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2013 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. - -struct Foo; - -fn f2() { - let _end_stmt = Foo { }; - //~^ ERROR: structure literal must either have at least one field -} - -fn main() {} diff --git a/src/test/compile-fail/struct-no-fields-3.rs b/src/test/compile-fail/struct-no-fields-3.rs deleted file mode 100644 index e594683feed..00000000000 --- a/src/test/compile-fail/struct-no-fields-3.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2013 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. - -struct Foo; - -fn g3() { - let _mid_tuple = (Foo { }, 2); - //~^ ERROR: structure literal must either have at least one field -} - -fn main() {} diff --git a/src/test/compile-fail/struct-no-fields-4.rs b/src/test/compile-fail/struct-no-fields-4.rs deleted file mode 100644 index 60a0a85d0ab..00000000000 --- a/src/test/compile-fail/struct-no-fields-4.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2013 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. - -struct Foo; - -fn h4() { - let _end_of_tuple = (3, Foo { }); - //~^ ERROR: structure literal must either have at least one field -} - -fn main() {} diff --git a/src/test/compile-fail/struct-no-fields-5.rs b/src/test/compile-fail/struct-no-fields-5.rs deleted file mode 100644 index 940fa9c7f27..00000000000 --- a/src/test/compile-fail/struct-no-fields-5.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2013 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. - -struct Foo; - -fn i5() { - let _end_of_block = { Foo { } }; - //~^ ERROR: structure literal must either have at least one field -} - -fn main() {} diff --git a/src/test/compile-fail/struct-variant-no-fields.rs b/src/test/compile-fail/struct-variant-no-fields.rs deleted file mode 100644 index 41dbbeefc0a..00000000000 --- a/src/test/compile-fail/struct-variant-no-fields.rs +++ /dev/null @@ -1,13 +0,0 @@ -// 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. - -enum Foo { - Bar {} //~ ERROR unit-like struct variant should be written without braces, as `Bar,` -} diff --git a/src/test/compile-fail/syntax-trait-polarity.rs b/src/test/compile-fail/syntax-trait-polarity.rs deleted file mode 100644 index 1ab79f5c80e..00000000000 --- a/src/test/compile-fail/syntax-trait-polarity.rs +++ /dev/null @@ -1,33 +0,0 @@ -// 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. - -#![feature(optin_builtin_traits)] - -use std::marker::Send; - -struct TestType; - -impl !TestType {} -//~^ ERROR inherent implementation can't be negated - -trait TestTrait {} - -unsafe impl !Send for TestType {} -impl !TestTrait for TestType {} - -struct TestType2<T>; - -impl<T> !TestType2<T> {} -//~^ ERROR inherent implementation can't be negated - -unsafe impl<T> !Send for TestType2<T> {} -impl<T> !TestTrait for TestType2<T> {} - -fn main() {} diff --git a/src/test/compile-fail/tag-variant-disr-non-nullary.rs b/src/test/compile-fail/tag-variant-disr-non-nullary.rs deleted file mode 100644 index 207bbe9a446..00000000000 --- a/src/test/compile-fail/tag-variant-disr-non-nullary.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2012 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. - -//error-pattern: discriminator values can only be used with a c-like enum - -enum color { - red = 0xff0000, - green = 0x00ff00, - blue = 0x0000ff, - black = 0x000000, - white = 0xffffff, - other (str), -} diff --git a/src/test/compile-fail/trailing-carriage-return-in-string.rs b/src/test/compile-fail/trailing-carriage-return-in-string.rs deleted file mode 100644 index 81098333261..00000000000 --- a/src/test/compile-fail/trailing-carriage-return-in-string.rs +++ /dev/null @@ -1,23 +0,0 @@ -// 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. - -// ignore-tidy-cr -// Issue #11669 - -fn main() { - // \r\n - let ok = "This is \ - a test"; - // \r only - let bad = "This is \ a test"; - //~^ ERROR unknown character escape: \r - //~^^ HELP this is an isolated carriage return - -} diff --git a/src/test/compile-fail/trait-as-struct-constructor.rs b/src/test/compile-fail/trait-as-struct-constructor.rs index a1fcab002e1..fff14414094 100644 --- a/src/test/compile-fail/trait-as-struct-constructor.rs +++ b/src/test/compile-fail/trait-as-struct-constructor.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait TraitNotAStruct { } +trait TraitNotAStruct : ::std::marker::MarkerTrait { } fn main() { TraitNotAStruct{ value: 0 }; diff --git a/src/test/compile-fail/trait-bounds-cant-coerce.rs b/src/test/compile-fail/trait-bounds-cant-coerce.rs index 79174552ae0..3129dceffbb 100644 --- a/src/test/compile-fail/trait-bounds-cant-coerce.rs +++ b/src/test/compile-fail/trait-bounds-cant-coerce.rs @@ -10,6 +10,7 @@ trait Foo { + fn dummy(&self) { } } fn a(_x: Box<Foo+Send>) { diff --git a/src/test/compile-fail/trait-bounds-impl-comparison-1.rs b/src/test/compile-fail/trait-bounds-impl-comparison-1.rs index 477bd4f5be9..34e06cc9365 100644 --- a/src/test/compile-fail/trait-bounds-impl-comparison-1.rs +++ b/src/test/compile-fail/trait-bounds-impl-comparison-1.rs @@ -11,7 +11,10 @@ // Make sure rustc checks the type parameter bounds in implementations of traits, // see #2687 -trait A {} +use std::marker; + +trait A : marker::PhantomFn<Self> { +} trait B: A {} @@ -62,15 +65,16 @@ impl Foo for isize { //~^ ERROR the requirement `T : C` appears on the impl } - -trait Getter<T> { } +trait Getter<T> { + fn get(&self) -> T { loop { } } +} trait Trait { - fn method<G:Getter<isize>>(); + fn method<G:Getter<isize>>(&self); } impl Trait for usize { - fn method<G: Getter<usize>>() {} + fn method<G: Getter<usize>>(&self) {} //~^ G : Getter<usize>` appears on the impl method but not on the corresponding trait method } diff --git a/src/test/compile-fail/trait-bounds-impl-comparison-2.rs b/src/test/compile-fail/trait-bounds-impl-comparison-2.rs index 8ad19116e7b..284c4fac953 100644 --- a/src/test/compile-fail/trait-bounds-impl-comparison-2.rs +++ b/src/test/compile-fail/trait-bounds-impl-comparison-2.rs @@ -14,7 +14,9 @@ trait Iterator<A> { fn next(&mut self) -> Option<A>; } -trait IteratorUtil<A> { +trait IteratorUtil<A> + : ::std::marker::PhantomFn<(),A> +{ fn zip<B, U: Iterator<U>>(self, other: U) -> ZipIterator<Self, U>; } diff --git a/src/test/compile-fail/trait-bounds-not-on-bare-trait.rs b/src/test/compile-fail/trait-bounds-not-on-bare-trait.rs index 434d803d718..448b186f6a5 100644 --- a/src/test/compile-fail/trait-bounds-not-on-bare-trait.rs +++ b/src/test/compile-fail/trait-bounds-not-on-bare-trait.rs @@ -9,6 +9,7 @@ // except according to those terms. trait Foo { + fn dummy(&self) { } } // This should emit the less confusing error, not the more confusing one. diff --git a/src/test/compile-fail/trait-bounds-on-structs-and-enums-locals.rs b/src/test/compile-fail/trait-bounds-on-structs-and-enums-locals.rs index 118dfeb37c2..df44e847c50 100644 --- a/src/test/compile-fail/trait-bounds-on-structs-and-enums-locals.rs +++ b/src/test/compile-fail/trait-bounds-on-structs-and-enums-locals.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait Trait {} +trait Trait { + fn dummy(&self) { } +} struct Foo<T:Trait> { x: T, diff --git a/src/test/compile-fail/trait-bounds-on-structs-and-enums-static.rs b/src/test/compile-fail/trait-bounds-on-structs-and-enums-static.rs index d5369817e9a..18871d0d386 100644 --- a/src/test/compile-fail/trait-bounds-on-structs-and-enums-static.rs +++ b/src/test/compile-fail/trait-bounds-on-structs-and-enums-static.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait Trait {} +trait Trait { + fn dummy(&self) { } +} struct Foo<T:Trait> { x: T, diff --git a/src/test/compile-fail/trait-bounds-on-structs-and-enums.rs b/src/test/compile-fail/trait-bounds-on-structs-and-enums.rs index 490ee0e8ad6..8dfdb2f205d 100644 --- a/src/test/compile-fail/trait-bounds-on-structs-and-enums.rs +++ b/src/test/compile-fail/trait-bounds-on-structs-and-enums.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait Trait {} +use std::marker::MarkerTrait; + +trait Trait : MarkerTrait {} struct Foo<T:Trait> { x: T, @@ -51,15 +53,15 @@ enum MoreBadness<V> { EvenMoreBadness(Bar<V>), } -trait PolyTrait<T> { - fn whatever() {} +trait PolyTrait<T> +{ + fn whatever(&self, t: T) {} } struct Struct; impl PolyTrait<Foo<usize>> for Struct { //~^ ERROR not implemented - fn whatever() {} } fn main() { diff --git a/src/test/compile-fail/trait-bounds-sugar.rs b/src/test/compile-fail/trait-bounds-sugar.rs index 3d264e681a3..e4058a0943a 100644 --- a/src/test/compile-fail/trait-bounds-sugar.rs +++ b/src/test/compile-fail/trait-bounds-sugar.rs @@ -10,8 +10,9 @@ // Tests for "default" bounds inferred for traits with no bounds list. +use std::marker::MarkerTrait; -trait Foo {} +trait Foo : MarkerTrait {} fn a(_x: Box<Foo+Send>) { } diff --git a/src/test/compile-fail/trait-impl-1.rs b/src/test/compile-fail/trait-impl-1.rs index dadcbd5bce7..2f4793b4d88 100644 --- a/src/test/compile-fail/trait-impl-1.rs +++ b/src/test/compile-fail/trait-impl-1.rs @@ -12,7 +12,9 @@ // trait impl is only applied to a trait object, not concrete types which implement // the trait. -trait T {} +use std::marker::MarkerTrait; + +trait T : MarkerTrait {} impl<'a> T+'a { fn foo(&self) {} diff --git a/src/test/compile-fail/trait-object-safety.rs b/src/test/compile-fail/trait-object-safety.rs index 761bcd4968a..d45d13556e1 100644 --- a/src/test/compile-fail/trait-object-safety.rs +++ b/src/test/compile-fail/trait-object-safety.rs @@ -12,6 +12,7 @@ trait Tr { fn foo(); + fn bar(&self) { } } struct St; diff --git a/src/test/compile-fail/trait-static-method-generic-inference.rs b/src/test/compile-fail/trait-static-method-generic-inference.rs index 651f663fc99..0e357d9d4d5 100644 --- a/src/test/compile-fail/trait-static-method-generic-inference.rs +++ b/src/test/compile-fail/trait-static-method-generic-inference.rs @@ -16,6 +16,7 @@ mod base { pub trait HasNew<T> { fn new() -> T; + fn dummy(&self) { } } pub struct Foo { diff --git a/src/test/compile-fail/type-parameter-defaults-referencing-Self-ppaux.rs b/src/test/compile-fail/type-parameter-defaults-referencing-Self-ppaux.rs new file mode 100644 index 00000000000..8ff514e04e3 --- /dev/null +++ b/src/test/compile-fail/type-parameter-defaults-referencing-Self-ppaux.rs @@ -0,0 +1,26 @@ +// Copyright 2015 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 a default that references `Self` which is then used in an +// object type. Issue #18956. In this case, the value is supplied by +// the user, but pretty-printing the type during the error message +// caused an ICE. + +trait MyAdd<Rhs=Self> { fn add(&self, other: &Rhs) -> Self; } + +impl MyAdd for i32 { + fn add(&self, other: &i32) -> i32 { *self + *other } +} + +fn main() { + let x = 5; + let y = x as MyAdd<i32>; + //~^ ERROR as `MyAdd<i32>` +} diff --git a/src/test/compile-fail/obsolete-for-sized.rs b/src/test/compile-fail/type-parameter-defaults-referencing-Self.rs index 1b86d08a50d..9982d485024 100644 --- a/src/test/compile-fail/obsolete-for-sized.rs +++ b/src/test/compile-fail/type-parameter-defaults-referencing-Self.rs @@ -8,10 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Test that we generate obsolete syntax errors around usages of `for Sized?` +// Test a default that references `Self` which is then used in an object type. +// Issue #18956. -trait Foo for Sized? {} //~ ERROR obsolete syntax: for Sized? +#![feature(default_type_params)] -trait Bar for ?Sized {} //~ ERROR obsolete syntax: for Sized? +trait Foo<T=Self> { + fn method(&self); +} + +fn foo(x: &Foo) { } +//~^ ERROR the type parameter `T` must be explicitly specified fn main() { } diff --git a/src/test/compile-fail/type-parameters-in-field-exprs.rs b/src/test/compile-fail/type-parameters-in-field-exprs.rs deleted file mode 100644 index 54ddb3e19fa..00000000000 --- a/src/test/compile-fail/type-parameters-in-field-exprs.rs +++ /dev/null @@ -1,24 +0,0 @@ -// 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. - -struct Foo { - x: isize, - y: isize, -} - -fn main() { - let f = Foo { - x: 1, - y: 2, - }; - f.x::<isize>; - //~^ ERROR field expressions may not have type parameters -} - diff --git a/src/test/compile-fail/typeck-negative-impls-builtin.rs b/src/test/compile-fail/typeck-negative-impls-builtin.rs index 9da79b11cf0..557fb2f4f88 100644 --- a/src/test/compile-fail/typeck-negative-impls-builtin.rs +++ b/src/test/compile-fail/typeck-negative-impls-builtin.rs @@ -12,7 +12,9 @@ struct TestType; -trait TestTrait {} +trait TestTrait { + fn dummy(&self) { } +} impl !TestTrait for TestType {} //~^ ERROR negative impls are currently allowed just for `Send` and `Sync` diff --git a/src/test/compile-fail/typeck_type_placeholder_mismatch.rs b/src/test/compile-fail/typeck_type_placeholder_mismatch.rs index a34be63ba6b..1daea8f915b 100644 --- a/src/test/compile-fail/typeck_type_placeholder_mismatch.rs +++ b/src/test/compile-fail/typeck_type_placeholder_mismatch.rs @@ -11,14 +11,16 @@ // This test checks that genuine type errors with partial // type hints are understandable. -struct Foo<T>; -struct Bar<U>; +use std::marker::PhantomData; + +struct Foo<T>(PhantomData<T>); +struct Bar<U>(PhantomData<U>); pub fn main() { } fn test1() { - let x: Foo<_> = Bar::<usize>; + let x: Foo<_> = Bar::<usize>(PhantomData); //~^ ERROR mismatched types //~| expected `Foo<_>` //~| found `Bar<usize>` @@ -28,7 +30,7 @@ fn test1() { } fn test2() { - let x: Foo<_> = Bar::<usize>; + let x: Foo<_> = Bar::<usize>(PhantomData); //~^ ERROR mismatched types //~| expected `Foo<_>` //~| found `Bar<usize>` diff --git a/src/test/compile-fail/ufcs-qpath-missing-params.rs b/src/test/compile-fail/ufcs-qpath-missing-params.rs index 5fa66eb98e1..f4e18265fd9 100644 --- a/src/test/compile-fail/ufcs-qpath-missing-params.rs +++ b/src/test/compile-fail/ufcs-qpath-missing-params.rs @@ -12,6 +12,5 @@ use std::borrow::IntoCow; fn main() { <String as IntoCow>::into_cow("foo".to_string()); - //~^ ERROR wrong number of type arguments: expected 2, found 0 + //~^ ERROR wrong number of type arguments: expected 1, found 0 } - diff --git a/src/test/compile-fail/unboxed-closure-feature-gate.rs b/src/test/compile-fail/unboxed-closure-feature-gate.rs index 3536244f011..74a6f869f63 100644 --- a/src/test/compile-fail/unboxed-closure-feature-gate.rs +++ b/src/test/compile-fail/unboxed-closure-feature-gate.rs @@ -11,8 +11,12 @@ // Check that parenthetical notation is feature-gated except with the // `Fn` traits. +use std::marker; + trait Foo<A> { type Output; + + fn dummy(&self, a: A) { } } fn main() { diff --git a/src/test/compile-fail/unboxed-closure-sugar-default.rs b/src/test/compile-fail/unboxed-closure-sugar-default.rs index 870377bc1ad..831db98941c 100644 --- a/src/test/compile-fail/unboxed-closure-sugar-default.rs +++ b/src/test/compile-fail/unboxed-closure-sugar-default.rs @@ -19,7 +19,7 @@ trait Foo<T,V=T> { fn dummy(&self, t: T, v: V); } -trait Eq<X: ?Sized> { } +trait Eq<X: ?Sized> { fn same_types(&self, x: &X) -> bool { true } } impl<X: ?Sized> Eq<X> for X { } fn eq<A: ?Sized,B: ?Sized>() where A : Eq<B> { } diff --git a/src/test/compile-fail/unboxed-closure-sugar-equiv.rs b/src/test/compile-fail/unboxed-closure-sugar-equiv.rs index dc5576aee65..6d315c1b7a9 100644 --- a/src/test/compile-fail/unboxed-closure-sugar-equiv.rs +++ b/src/test/compile-fail/unboxed-closure-sugar-equiv.rs @@ -16,12 +16,14 @@ #![feature(unboxed_closures)] #![allow(dead_code)] +use std::marker::PhantomFn; + trait Foo<T> { type Output; fn dummy(&self, t: T, u: Self::Output); } -trait Eq<X: ?Sized> { } +trait Eq<X: ?Sized> : PhantomFn<(Self,X)> { } impl<X: ?Sized> Eq<X> for X { } fn eq<A: ?Sized,B: ?Sized +Eq<A>>() { } diff --git a/src/test/compile-fail/unboxed-closure-sugar-lifetime-elision.rs b/src/test/compile-fail/unboxed-closure-sugar-lifetime-elision.rs index d2f781bba11..bd3530e6e30 100644 --- a/src/test/compile-fail/unboxed-closure-sugar-lifetime-elision.rs +++ b/src/test/compile-fail/unboxed-closure-sugar-lifetime-elision.rs @@ -16,12 +16,14 @@ #![feature(unboxed_closures)] #![allow(dead_code)] +use std::marker; + trait Foo<T> { type Output; fn dummy(&self, t: T); } -trait Eq<X: ?Sized> { } +trait Eq<X: ?Sized> : marker::PhantomFn<(Self, X)> { } impl<X: ?Sized> Eq<X> for X { } fn eq<A: ?Sized,B: ?Sized +Eq<A>>() { } diff --git a/src/test/compile-fail/unboxed-closure-sugar-region.rs b/src/test/compile-fail/unboxed-closure-sugar-region.rs index 75688e44e80..057b496bd43 100644 --- a/src/test/compile-fail/unboxed-closure-sugar-region.rs +++ b/src/test/compile-fail/unboxed-closure-sugar-region.rs @@ -22,7 +22,7 @@ trait Foo<'a,T> { fn dummy(&'a self) -> &'a (T,Self::Output); } -trait Eq<X: ?Sized> { } +trait Eq<X: ?Sized> { fn is_of_eq_type(&self, x: &X) -> bool { true } } impl<X: ?Sized> Eq<X> for X { } fn eq<A: ?Sized,B: ?Sized +Eq<A>>() { } diff --git a/src/test/compile-fail/unboxed-closures-recursive-fn-using-fn-mut.rs b/src/test/compile-fail/unboxed-closures-recursive-fn-using-fn-mut.rs index 215b2c6798e..713b64b1349 100644 --- a/src/test/compile-fail/unboxed-closures-recursive-fn-using-fn-mut.rs +++ b/src/test/compile-fail/unboxed-closures-recursive-fn-using-fn-mut.rs @@ -10,7 +10,7 @@ #![feature(core,unboxed_closures)] -use std::marker::CovariantType; +use std::marker::PhantomData; // A erroneous variant of `run-pass/unboxed_closures-infer-recursive-fn.rs` // where we attempt to perform mutation in the recursive function. This fails to compile @@ -18,12 +18,12 @@ use std::marker::CovariantType; struct YCombinator<F,A,R> { func: F, - marker: CovariantType<(A,R)>, + marker: PhantomData<(A,R)>, } impl<F,A,R> YCombinator<F,A,R> { fn new(f: F) -> YCombinator<F,A,R> { - YCombinator { func: f, marker: CovariantType } + YCombinator { func: f, marker: PhantomData } } } diff --git a/src/test/compile-fail/unnecessary-private.rs b/src/test/compile-fail/unnecessary-private.rs index e3707292f24..964db6e9a45 100644 --- a/src/test/compile-fail/unnecessary-private.rs +++ b/src/test/compile-fail/unnecessary-private.rs @@ -13,10 +13,10 @@ fn main() { pub struct A; //~ ERROR: visibility has no effect pub enum B {} //~ ERROR: visibility has no effect pub trait C { //~ ERROR: visibility has no effect - pub fn foo() {} //~ ERROR: visibility has no effect + pub fn foo(&self) {} //~ ERROR: visibility has no effect } impl A { - pub fn foo() {} //~ ERROR: visibility has no effect + pub fn foo(&self) {} //~ ERROR: visibility has no effect } struct D { diff --git a/src/test/compile-fail/unsized-inherent-impl-self-type.rs b/src/test/compile-fail/unsized-inherent-impl-self-type.rs index 8740346a217..a03c76b12dd 100644 --- a/src/test/compile-fail/unsized-inherent-impl-self-type.rs +++ b/src/test/compile-fail/unsized-inherent-impl-self-type.rs @@ -12,7 +12,7 @@ // impl - struct -struct S5<Y>; +struct S5<Y>(Y); impl<X: ?Sized> S5<X> { //~ ERROR not implemented } diff --git a/src/test/compile-fail/unsized-trait-impl-self-type.rs b/src/test/compile-fail/unsized-trait-impl-self-type.rs index 3dd55b0ba7d..08df1d9b7b8 100644 --- a/src/test/compile-fail/unsized-trait-impl-self-type.rs +++ b/src/test/compile-fail/unsized-trait-impl-self-type.rs @@ -12,9 +12,10 @@ // impl - struct trait T3<Z: ?Sized> { + fn foo(&self, z: &Z); } -struct S5<Y>; +struct S5<Y>(Y); impl<X: ?Sized> T3<X> for S5<X> { //~ ERROR not implemented } diff --git a/src/test/compile-fail/unsized-trait-impl-trait-arg.rs b/src/test/compile-fail/unsized-trait-impl-trait-arg.rs index ac8043d6852..4723dfeaeb9 100644 --- a/src/test/compile-fail/unsized-trait-impl-trait-arg.rs +++ b/src/test/compile-fail/unsized-trait-impl-trait-arg.rs @@ -12,8 +12,9 @@ // impl - unbounded trait T2<Z> { + fn foo(&self, z: Z); } -struct S4<Y: ?Sized>; +struct S4<Y: ?Sized>(Box<Y>); impl<X: ?Sized> T2<X> for S4<X> { //~^ ERROR `core::marker::Sized` is not implemented for the type `X` } diff --git a/src/test/compile-fail/unsized2.rs b/src/test/compile-fail/unsized2.rs deleted file mode 100644 index b2eb2064aeb..00000000000 --- a/src/test/compile-fail/unsized2.rs +++ /dev/null @@ -1,20 +0,0 @@ -// 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 syntax checks for `type` keyword. - -fn f<X>() {} - -pub fn main() { - f<type>(); - //~^ ERROR expected identifier, found keyword `type` - //~^^ ERROR: chained comparison - //~^^^ HELP: use `::< -} diff --git a/src/test/compile-fail/unsized3.rs b/src/test/compile-fail/unsized3.rs index 4fc76c99c60..de1cbab82b2 100644 --- a/src/test/compile-fail/unsized3.rs +++ b/src/test/compile-fail/unsized3.rs @@ -10,6 +10,7 @@ // Test sized-ness checking in substitution within fn bodies.. +use std::marker; // Unbounded. fn f1<X: ?Sized>(x: &X) { @@ -20,7 +21,9 @@ fn f2<X>(x: &X) { } // Bounded. -trait T {} +trait T { + fn foo(&self) { } +} fn f3<X: ?Sized + T>(x: &X) { f4::<X>(x); //~^ ERROR the trait `core::marker::Sized` is not implemented diff --git a/src/test/compile-fail/unsized6.rs b/src/test/compile-fail/unsized6.rs index 217d1f44d84..f31a6ffdc0d 100644 --- a/src/test/compile-fail/unsized6.rs +++ b/src/test/compile-fail/unsized6.rs @@ -10,8 +10,9 @@ // Test `?Sized` local variables. +use std::marker; -trait T {} +trait T : marker::MarkerTrait { } fn f1<X: ?Sized>(x: &X) { let _: X; // <-- this is OK, no bindings created, no initializer. diff --git a/src/test/compile-fail/unsized7.rs b/src/test/compile-fail/unsized7.rs index 6fc547c0b8e..6ea3d0720ee 100644 --- a/src/test/compile-fail/unsized7.rs +++ b/src/test/compile-fail/unsized7.rs @@ -10,13 +10,17 @@ // Test sized-ness checking in substitution in impls. -trait T {} +use std::marker::MarkerTrait; + +trait T : MarkerTrait {} // I would like these to fail eventually. // impl - bounded trait T1<Z: T> { + fn dummy(&self) -> Z; } -struct S3<Y: ?Sized>; + +struct S3<Y: ?Sized>(Box<Y>); impl<X: ?Sized + T> T1<X> for S3<X> { //~^ ERROR `core::marker::Sized` is not implemented for the type `X` } diff --git a/src/test/compile-fail/unused-attr.rs b/src/test/compile-fail/unused-attr.rs index 2d4bc0c857a..af242b96a84 100644 --- a/src/test/compile-fail/unused-attr.rs +++ b/src/test/compile-fail/unused-attr.rs @@ -52,9 +52,9 @@ struct Foo { #[foo] //~ ERROR unused attribute trait Baz { #[foo] //~ ERROR unused attribute - fn blah(); + fn blah(&self); #[foo] //~ ERROR unused attribute - fn blah2() {} + fn blah2(&self) {} } fn main() {} diff --git a/src/test/compile-fail/useless-priv.rs b/src/test/compile-fail/useless-priv.rs index d8531f4543d..b1120e54434 100644 --- a/src/test/compile-fail/useless-priv.rs +++ b/src/test/compile-fail/useless-priv.rs @@ -12,12 +12,14 @@ struct A { pub i: isize } pub enum C { pub Variant } //~ ERROR: unnecessary `pub` pub trait E { - pub fn foo() {} //~ ERROR: unnecessary visibility + pub fn foo(&self) {} //~ ERROR: unnecessary visibility +} +trait F { + pub fn foo(&self) {} //~ ERROR: unnecessary visibility } -trait F { pub fn foo() {} } //~ ERROR: unnecessary visibility impl E for A { - pub fn foo() {} //~ ERROR: unnecessary visibility + pub fn foo(&self) {} //~ ERROR: unnecessary visibility } fn main() {} diff --git a/src/test/compile-fail/useless-priv2.rs b/src/test/compile-fail/useless-priv2.rs index 7125a66b294..a404d09248f 100644 --- a/src/test/compile-fail/useless-priv2.rs +++ b/src/test/compile-fail/useless-priv2.rs @@ -9,8 +9,10 @@ // except according to those terms. pub trait E { - pub fn foo(); //~ ERROR: unnecessary visibility + pub fn foo(&self); //~ ERROR: unnecessary visibility +} +trait F { + pub fn foo(&self); //~ ERROR: unnecessary visibility } -trait F { pub fn foo(); } //~ ERROR: unnecessary visibility fn main() {} diff --git a/src/test/compile-fail/variance-contravariant-arg-object.rs b/src/test/compile-fail/variance-contravariant-arg-object.rs new file mode 100644 index 00000000000..3330e1d0d51 --- /dev/null +++ b/src/test/compile-fail/variance-contravariant-arg-object.rs @@ -0,0 +1,31 @@ +// Copyright 2015 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. + +#![allow(dead_code)] + +trait Get<T> : 'static { + fn get(&self, t: T); +} + +fn get_min_from_max<'min, 'max>(v: Box<Get<&'max i32>>) + -> Box<Get<&'min i32>> + where 'max : 'min +{ + v //~ ERROR mismatched types +} + +fn get_max_from_min<'min, 'max, G>(v: Box<Get<&'min i32>>) + -> Box<Get<&'max i32>> + where 'max : 'min +{ + v +} + +fn main() { } diff --git a/src/test/compile-fail/variance-contravariant-arg-trait-match.rs b/src/test/compile-fail/variance-contravariant-arg-trait-match.rs new file mode 100644 index 00000000000..caaad4014ad --- /dev/null +++ b/src/test/compile-fail/variance-contravariant-arg-trait-match.rs @@ -0,0 +1,31 @@ +// Copyright 2015 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. + +#![allow(dead_code)] + +trait Get<T> { + fn get(&self, t: T); +} + +fn get_min_from_max<'min, 'max, G>() + where 'max : 'min, G : Get<&'max i32> +{ + impls_get::<G,&'min i32>() //~ ERROR mismatched types +} + +fn get_max_from_min<'min, 'max, G>() + where 'max : 'min, G : Get<&'min i32> +{ + impls_get::<G,&'max i32>() +} + +fn impls_get<G,T>() where G : Get<T> { } + +fn main() { } diff --git a/src/test/compile-fail/no-unsafe-self.rs b/src/test/compile-fail/variance-contravariant-self-trait-match.rs index 0bf73bbdfe3..013511ed517 100644 --- a/src/test/compile-fail/no-unsafe-self.rs +++ b/src/test/compile-fail/variance-contravariant-self-trait-match.rs @@ -1,4 +1,4 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -8,15 +8,24 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait A { - fn foo(*mut self); //~ ERROR cannot pass self by unsafe pointer - fn bar(*self); //~ ERROR cannot pass self by unsafe pointer +#![allow(dead_code)] + +trait Get { + fn get(&self); +} + +fn get_min_from_max<'min, 'max, G>() + where 'max : 'min, G : 'max, &'max G : Get +{ + impls_get::<&'min G>(); //~ ERROR mismatched types } -struct X; -impl A for X { - fn foo(*mut self) { } //~ ERROR cannot pass self by unsafe pointer - fn bar(*self) { } //~ ERROR cannot pass self by unsafe pointer +fn get_max_from_min<'min, 'max, G>() + where 'max : 'min, G : 'max, &'min G : Get +{ + impls_get::<&'max G>(); } +fn impls_get<G>() where G : Get { } + fn main() { } diff --git a/src/test/compile-fail/variance-covariant-arg-object.rs b/src/test/compile-fail/variance-covariant-arg-object.rs new file mode 100644 index 00000000000..828c987c082 --- /dev/null +++ b/src/test/compile-fail/variance-covariant-arg-object.rs @@ -0,0 +1,31 @@ +// Copyright 2015 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. + +#![allow(dead_code)] + +trait Get<T> : 'static { + fn get(&self) -> T; +} + +fn get_min_from_max<'min, 'max>(v: Box<Get<&'max i32>>) + -> Box<Get<&'min i32>> + where 'max : 'min +{ + v +} + +fn get_max_from_min<'min, 'max, G>(v: Box<Get<&'min i32>>) + -> Box<Get<&'max i32>> + where 'max : 'min +{ + v //~ ERROR mismatched types +} + +fn main() { } diff --git a/src/test/compile-fail/variance-covariant-arg-trait-match.rs b/src/test/compile-fail/variance-covariant-arg-trait-match.rs new file mode 100644 index 00000000000..17761b9c0b1 --- /dev/null +++ b/src/test/compile-fail/variance-covariant-arg-trait-match.rs @@ -0,0 +1,31 @@ +// Copyright 2015 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. + +#![allow(dead_code)] + +trait Get<T> { + fn get(&self) -> T; +} + +fn get_min_from_max<'min, 'max, G>() + where 'max : 'min, G : Get<&'max i32> +{ + impls_get::<G,&'min i32>() +} + +fn get_max_from_min<'min, 'max, G>() + where 'max : 'min, G : Get<&'min i32> +{ + impls_get::<G,&'max i32>() //~ ERROR mismatched types +} + +fn impls_get<G,T>() where G : Get<T> { } + +fn main() { } diff --git a/src/test/compile-fail/variance-covariant-self-trait-match.rs b/src/test/compile-fail/variance-covariant-self-trait-match.rs new file mode 100644 index 00000000000..4e94a3eeb46 --- /dev/null +++ b/src/test/compile-fail/variance-covariant-self-trait-match.rs @@ -0,0 +1,31 @@ +// Copyright 2015 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. + +#![allow(dead_code)] + +trait Get { + fn get() -> Self; +} + +fn get_min_from_max<'min, 'max, G>() + where 'max : 'min, G : 'max, &'max G : Get +{ + impls_get::<&'min G>(); +} + +fn get_max_from_min<'min, 'max, G>() + where 'max : 'min, G : 'max, &'min G : Get +{ + impls_get::<&'max G>(); //~ ERROR mismatched types +} + +fn impls_get<G>() where G : Get { } + +fn main() { } diff --git a/src/test/compile-fail/variance-deprecated-markers.rs b/src/test/compile-fail/variance-deprecated-markers.rs new file mode 100644 index 00000000000..8f9d24cb132 --- /dev/null +++ b/src/test/compile-fail/variance-deprecated-markers.rs @@ -0,0 +1,35 @@ +// Copyright 2015 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 the deprecated markers still have their old effect. + +#![feature(rustc_attrs)] + +use std::marker; + +#[rustc_variance] +struct A<T>(marker::CovariantType<T>); //~ ERROR types=[[+];[];[]] + +#[rustc_variance] +struct B<T>(marker::ContravariantType<T>); //~ ERROR types=[[-];[];[]] + +#[rustc_variance] +struct C<T>(marker::InvariantType<T>); //~ ERROR types=[[o];[];[]] + +#[rustc_variance] +struct D<'a>(marker::CovariantLifetime<'a>); //~ ERROR regions=[[+];[];[]] + +#[rustc_variance] +struct E<'a>(marker::ContravariantLifetime<'a>); //~ ERROR regions=[[-];[];[]] + +#[rustc_variance] +struct F<'a>(marker::InvariantLifetime<'a>); //~ ERROR regions=[[o];[];[]] + +fn main() { } diff --git a/src/test/compile-fail/variance-invariant-arg-object.rs b/src/test/compile-fail/variance-invariant-arg-object.rs new file mode 100644 index 00000000000..9edb510b826 --- /dev/null +++ b/src/test/compile-fail/variance-invariant-arg-object.rs @@ -0,0 +1,31 @@ +// Copyright 2015 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. + +#![allow(dead_code)] + +trait Get<T> : 'static { + fn get(&self, t: T) -> T; +} + +fn get_min_from_max<'min, 'max>(v: Box<Get<&'max i32>>) + -> Box<Get<&'min i32>> + where 'max : 'min +{ + v //~ ERROR mismatched types +} + +fn get_max_from_min<'min, 'max, G>(v: Box<Get<&'min i32>>) + -> Box<Get<&'max i32>> + where 'max : 'min +{ + v //~ ERROR mismatched types +} + +fn main() { } diff --git a/src/test/compile-fail/variance-invariant-arg-trait-match.rs b/src/test/compile-fail/variance-invariant-arg-trait-match.rs new file mode 100644 index 00000000000..45fed0b083d --- /dev/null +++ b/src/test/compile-fail/variance-invariant-arg-trait-match.rs @@ -0,0 +1,31 @@ +// Copyright 2015 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. + +#![allow(dead_code)] + +trait Get<T> { + fn get(&self, t: T) -> T; +} + +fn get_min_from_max<'min, 'max, G>() + where 'max : 'min, G : Get<&'max i32> +{ + impls_get::<G,&'min i32>() //~ ERROR mismatched types +} + +fn get_max_from_min<'min, 'max, G>() + where 'max : 'min, G : Get<&'min i32> +{ + impls_get::<G,&'max i32>() //~ ERROR mismatched types +} + +fn impls_get<G,T>() where G : Get<T> { } + +fn main() { } diff --git a/src/test/compile-fail/variance-invariant-self-trait-match.rs b/src/test/compile-fail/variance-invariant-self-trait-match.rs new file mode 100644 index 00000000000..b46cd302ae5 --- /dev/null +++ b/src/test/compile-fail/variance-invariant-self-trait-match.rs @@ -0,0 +1,31 @@ +// Copyright 2015 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. + +#![allow(dead_code)] + +trait Get { + fn get(&self) -> Self; +} + +fn get_min_from_max<'min, 'max, G>() + where 'max : 'min, &'max G : Get +{ + impls_get::<&'min G>(); //~ ERROR mismatched types +} + +fn get_max_from_min<'min, 'max, G>() + where 'max : 'min, &'min G : Get +{ + impls_get::<&'max G>(); //~ ERROR mismatched types +} + +fn impls_get<G>() where G : Get { } + +fn main() { } diff --git a/src/test/compile-fail/variance-issue-20533.rs b/src/test/compile-fail/variance-issue-20533.rs new file mode 100644 index 00000000000..0254f56bd1a --- /dev/null +++ b/src/test/compile-fail/variance-issue-20533.rs @@ -0,0 +1,54 @@ +// Copyright 2015 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. + +// Regression test for issue #20533. At some point, only 1 out of the +// 3 errors below were being reported. + +use std::marker::PhantomData; + +fn foo<'a, T>(_x: &'a T) -> PhantomData<&'a ()> { + PhantomData +} + +struct Wrap<T>(T); + +fn bar<'a, T>(_x: &'a T) -> Wrap<PhantomData<&'a ()>> { + Wrap(PhantomData) +} + +struct Baked<'a>(PhantomData<&'a ()>); + +fn baz<'a, T>(_x: &'a T) -> Baked<'a> { + Baked(PhantomData) +} + +struct AffineU32(u32); + +fn main() { + { + let a = AffineU32(1_u32); + let x = foo(&a); + drop(a); //~ ERROR cannot move out of `a` + drop(x); + } + { + let a = AffineU32(1_u32); + let x = bar(&a); + drop(a); //~ ERROR cannot move out of `a` + drop(x); + } + { + let a = AffineU32(1_u32); + let x = baz(&a); + drop(a); //~ ERROR cannot move out of `a` + drop(x); + } +} + diff --git a/src/test/compile-fail/variance-regions-direct.rs b/src/test/compile-fail/variance-regions-direct.rs index d70305d1106..da4d6c75227 100644 --- a/src/test/compile-fail/variance-regions-direct.rs +++ b/src/test/compile-fail/variance-regions-direct.rs @@ -60,6 +60,7 @@ struct Test6<'a, 'b> { //~ ERROR regions=[[-, o];[];[]] #[rustc_variance] struct Test7<'a> { //~ ERROR regions=[[*];[];[]] + //~^ ERROR parameter `'a` is never used x: isize } diff --git a/src/test/compile-fail/variance-regions-indirect.rs b/src/test/compile-fail/variance-regions-indirect.rs index 4bb329d6304..9beb90d0b24 100644 --- a/src/test/compile-fail/variance-regions-indirect.rs +++ b/src/test/compile-fail/variance-regions-indirect.rs @@ -16,6 +16,7 @@ #[rustc_variance] enum Base<'a, 'b, 'c:'b, 'd> { //~ ERROR regions=[[+, -, o, *];[];[]] + //~^ ERROR parameter `'d` is never used Test8A(extern "Rust" fn(&'a isize)), Test8B(&'b [isize]), Test8C(&'b mut &'c str), @@ -23,16 +24,19 @@ enum Base<'a, 'b, 'c:'b, 'd> { //~ ERROR regions=[[+, -, o, *];[];[]] #[rustc_variance] struct Derived1<'w, 'x:'y, 'y, 'z> { //~ ERROR regions=[[*, o, -, +];[];[]] + //~^ ERROR parameter `'w` is never used f: Base<'z, 'y, 'x, 'w> } #[rustc_variance] // Combine - and + to yield o struct Derived2<'a, 'b:'a, 'c> { //~ ERROR regions=[[o, o, *];[];[]] + //~^ ERROR parameter `'c` is never used f: Base<'a, 'a, 'b, 'c> } #[rustc_variance] // Combine + and o to yield o (just pay attention to 'a here) struct Derived3<'a:'b, 'b, 'c> { //~ ERROR regions=[[o, -, *];[];[]] + //~^ ERROR parameter `'c` is never used f: Base<'a, 'b, 'a, 'c> } diff --git a/src/test/compile-fail/trailing-plus-in-bounds.rs b/src/test/compile-fail/variance-regions-unused-direct.rs index e8f9ed4d2cf..396e7765206 100644 --- a/src/test/compile-fail/trailing-plus-in-bounds.rs +++ b/src/test/compile-fail/variance-regions-unused-direct.rs @@ -8,11 +8,18 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::fmt::Show; +// Test that disallow lifetime parameters that are unused. -fn main() { - let x: Box<Show+> = box 3 as Box<Show+>; - //~^ ERROR at least one type parameter bound must be specified - //~^^ ERROR at least one type parameter bound must be specified +use std::marker; + +struct Bivariant<'a>; //~ ERROR parameter `'a` is never used + +struct Struct<'a, 'd> { //~ ERROR parameter `'d` is never used + field: &'a [i32] +} + +trait Trait<'a, 'd> { //~ ERROR parameter `'d` is never used + fn method(&'a self); } +fn main() {} diff --git a/src/test/compile-fail/attr-dangling-in-fn.rs b/src/test/compile-fail/variance-regions-unused-indirect.rs index 384622fb168..2d234ed7b57 100644 --- a/src/test/compile-fail/attr-dangling-in-fn.rs +++ b/src/test/compile-fail/variance-regions-unused-indirect.rs @@ -8,11 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:expected item +// Test that disallow lifetime parameters that are unused. -fn f() { - #[foo = "bar"] +enum Foo<'a> { //~ ERROR parameter `'a` is never used + Foo1(Bar<'a>) } -fn main() { +enum Bar<'a> { //~ ERROR parameter `'a` is never used + Bar1(Foo<'a>) } + +fn main() {} diff --git a/src/test/compile-fail/variance-trait-bounds.rs b/src/test/compile-fail/variance-trait-bounds.rs new file mode 100644 index 00000000000..88b50058b65 --- /dev/null +++ b/src/test/compile-fail/variance-trait-bounds.rs @@ -0,0 +1,65 @@ +// 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. + +#![deny(bivariance)] +#![allow(dead_code)] +#![feature(rustc_attrs)] + +// Check that bounds on type parameters (other than `Self`) do not +// influence variance. + +#[rustc_variance] +trait Getter<T> { //~ ERROR types=[[+];[-];[]] + fn get(&self) -> T; +} + +#[rustc_variance] +trait Setter<T> { //~ ERROR types=[[-];[-];[]] + fn get(&self, T); +} + +#[rustc_variance] +struct TestStruct<U,T:Setter<U>> { //~ ERROR types=[[+, +];[];[]] + t: T, u: U +} + +#[rustc_variance] +enum TestEnum<U,T:Setter<U>> {//~ ERROR types=[[*, +];[];[]] + //~^ ERROR parameter `U` is never used + Foo(T) +} + +#[rustc_variance] +trait TestTrait<U,T:Setter<U>> { //~ ERROR types=[[-, +];[-];[]] + fn getter(&self, u: U) -> T; +} + +#[rustc_variance] +trait TestTrait2<U> : Getter<U> { //~ ERROR types=[[+];[-];[]] +} + +#[rustc_variance] +trait TestTrait3<U> { //~ ERROR types=[[-];[-];[]] + fn getter<T:Getter<U>>(&self); +} + +#[rustc_variance] +struct TestContraStruct<U,T:Setter<U>> { //~ ERROR types=[[*, +];[];[]] + //~^ ERROR parameter `U` is never used + t: T +} + +#[rustc_variance] +struct TestBox<U,T:Getter<U>+Setter<U>> { //~ ERROR types=[[*, +];[];[]] + //~^ ERROR parameter `U` is never used + t: T +} + +pub fn main() { } diff --git a/src/test/compile-fail/variance-trait-object-bound.rs b/src/test/compile-fail/variance-trait-object-bound.rs index 965b9430a5e..f0ca1edd563 100644 --- a/src/test/compile-fail/variance-trait-object-bound.rs +++ b/src/test/compile-fail/variance-trait-object-bound.rs @@ -18,7 +18,7 @@ use std::mem; -trait T { fn foo(); } +trait T { fn foo(&self); } #[rustc_variance] struct TOption<'a> { //~ ERROR regions=[[-];[];[]] diff --git a/src/test/compile-fail/variance-types-bounds.rs b/src/test/compile-fail/variance-types-bounds.rs new file mode 100644 index 00000000000..d53e4cd7610 --- /dev/null +++ b/src/test/compile-fail/variance-types-bounds.rs @@ -0,0 +1,76 @@ +// Copyright 2012 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 correctly infer variance for type parameters in +// various types and traits. + +#![feature(rustc_attrs)] + +#[rustc_variance] +struct TestImm<A, B> { //~ ERROR types=[[+, +];[];[]] + x: A, + y: B, +} + +#[rustc_variance] +struct TestMut<A, B:'static> { //~ ERROR types=[[+, o];[];[]] + x: A, + y: &'static mut B, +} + +#[rustc_variance] +struct TestIndirect<A:'static, B:'static> { //~ ERROR types=[[+, o];[];[]] + m: TestMut<A, B> +} + +#[rustc_variance] +struct TestIndirect2<A:'static, B:'static> { //~ ERROR types=[[o, o];[];[]] + n: TestMut<A, B>, + m: TestMut<B, A> +} + +#[rustc_variance] +trait Getter<A> { //~ ERROR types=[[+];[-];[]] + fn get(&self) -> A; +} + +#[rustc_variance] +trait Setter<A> { //~ ERROR types=[[-];[o];[]] + fn set(&mut self, a: A); +} + +#[rustc_variance] +trait GetterSetter<A> { //~ ERROR types=[[o];[o];[]] + fn get(&self) -> A; + fn set(&mut self, a: A); +} + +#[rustc_variance] +trait GetterInTypeBound<A> { //~ ERROR types=[[-];[-];[]] + // Here, the use of `A` in the method bound *does* affect + // variance. Think of it as if the method requested a dictionary + // for `T:Getter<A>`. Since this dictionary is an input, it is + // contravariant, and the Getter is covariant w/r/t A, yielding an + // overall contravariant result. + fn do_it<T:Getter<A>>(&self); +} + +#[rustc_variance] +trait SetterInTypeBound<A> { //~ ERROR types=[[+];[-];[]] + fn do_it<T:Setter<A>>(&self); +} + +#[rustc_variance] +struct TestObject<A, R> { //~ ERROR types=[[-, +];[];[]] + n: Box<Setter<A>+Send>, + m: Box<Getter<R>+Send>, +} + +fn main() {} diff --git a/src/test/compile-fail/variance-types.rs b/src/test/compile-fail/variance-types.rs new file mode 100644 index 00000000000..e407ebe345a --- /dev/null +++ b/src/test/compile-fail/variance-types.rs @@ -0,0 +1,52 @@ +// 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. + +#![deny(bivariance)] +#![allow(dead_code)] +#![feature(rustc_attrs)] + +use std::cell::Cell; + +// Check that a type parameter which is only used in a trait bound is +// not considered bivariant. + +#[rustc_variance] +struct InvariantMut<'a,A:'a,B:'a> { //~ ERROR types=[[o, o];[];[]], regions=[[-];[];[]] + t: &'a mut (A,B) +} + +#[rustc_variance] +struct InvariantCell<A> { //~ ERROR types=[[o];[];[]] + t: Cell<A> +} + +#[rustc_variance] +struct InvariantIndirect<A> { //~ ERROR types=[[o];[];[]] + t: InvariantCell<A> +} + +#[rustc_variance] +struct Covariant<A> { //~ ERROR types=[[+];[];[]] + t: A, u: fn() -> A +} + +#[rustc_variance] +struct Contravariant<A> { //~ ERROR types=[[-];[];[]] + t: fn(A) +} + +#[rustc_variance] +enum Enum<A,B,C> { //~ ERROR types=[[+, -, o];[];[]] + Foo(Covariant<A>), + Bar(Contravariant<B>), + Zed(Covariant<C>,Contravariant<C>) +} + +pub fn main() { } diff --git a/src/test/compile-fail/attr-dangling-in-mod.rs b/src/test/compile-fail/variance-unused-region-param.rs index 59a922ebee1..5f504226370 100644 --- a/src/test/compile-fail/attr-dangling-in-mod.rs +++ b/src/test/compile-fail/variance-unused-region-param.rs @@ -8,9 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:expected item +// Test that we report an error for unused type parameters in types. -fn main() { -} +struct SomeStruct<'a> { x: u32 } //~ ERROR parameter `'a` is never used +enum SomeEnum<'a> { Nothing } //~ ERROR parameter `'a` is never used +trait SomeTrait<'a> { fn foo(&self); } //~ ERROR parameter `'a` is never used -#[foo = "bar"] +fn main() {} diff --git a/src/test/compile-fail/variance-unused-type-param.rs b/src/test/compile-fail/variance-unused-type-param.rs new file mode 100644 index 00000000000..2e867ec3c93 --- /dev/null +++ b/src/test/compile-fail/variance-unused-type-param.rs @@ -0,0 +1,36 @@ +// Copyright 2012 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. + +#![allow(dead_code)] + +// Test that we report an error for unused type parameters in types and traits, +// and that we offer a helpful suggestion. + +struct SomeStruct<A> { x: u32 } +//~^ ERROR parameter `A` is never used +//~| HELP PhantomData + +enum SomeEnum<A> { Nothing } +//~^ ERROR parameter `A` is never used +//~| HELP PhantomData + +trait SomeTrait<A> { fn foo(&self); } +//~^ ERROR parameter `A` is never used +//~| HELP PhantomFn + +// Here T might *appear* used, but in fact it isn't. +enum ListCell<T> { +//~^ ERROR parameter `T` is never used +//~| HELP PhantomData + Cons(Box<ListCell<T>>), + Nil +} + +fn main() {} diff --git a/src/test/compile-fail/trait-bounds-not-on-impl.rs b/src/test/compile-fail/variance-use-contravariant-struct-1.rs index a034352c4a6..d2fd2978750 100644 --- a/src/test/compile-fail/trait-bounds-not-on-impl.rs +++ b/src/test/compile-fail/variance-use-contravariant-struct-1.rs @@ -1,4 +1,4 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -8,12 +8,19 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait Foo { -} +// Test various uses of structs with distint variances to make sure +// they permit lifetimes to be approximated as expected. + +#![feature(rustc_attrs)] -struct Bar; +struct SomeStruct<T>(fn(T)); -impl Foo + Owned for Bar { //~ ERROR not a trait +fn foo<'min,'max>(v: SomeStruct<&'max ()>) + -> SomeStruct<&'min ()> + where 'max : 'min +{ + v //~ ERROR mismatched types } +#[rustc_error] fn main() { } diff --git a/src/test/compile-fail/variance-use-contravariant-struct-2.rs b/src/test/compile-fail/variance-use-contravariant-struct-2.rs new file mode 100644 index 00000000000..b38fd0e9ffc --- /dev/null +++ b/src/test/compile-fail/variance-use-contravariant-struct-2.rs @@ -0,0 +1,27 @@ +// Copyright 2015 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 various uses of structs with distint variances to make sure +// they permit lifetimes to be approximated as expected. + +#![allow(dead_code)] +#![feature(rustc_attrs)] + +struct SomeStruct<T>(fn(T)); + +fn bar<'min,'max>(v: SomeStruct<&'min ()>) + -> SomeStruct<&'max ()> + where 'max : 'min +{ + v +} + +#[rustc_error] +fn main() { } //~ ERROR compilation successful diff --git a/src/test/compile-fail/require-parens-for-chained-comparison.rs b/src/test/compile-fail/variance-use-covariant-struct-1.rs index f2705f58331..2631cfc05e8 100644 --- a/src/test/compile-fail/require-parens-for-chained-comparison.rs +++ b/src/test/compile-fail/variance-use-covariant-struct-1.rs @@ -8,16 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn f<T>() {} +// Test that a covariant struct does not permit the lifetime of a +// reference to be enlarged. -fn main() { - false == false == false; - //~^ ERROR: chained comparison operators require parentheses +struct SomeStruct<T>(T); - false == 0 < 2; - //~^ ERROR: chained comparison operators require parentheses - - f<X>(); - //~^ ERROR: chained comparison operators require parentheses - //~^^ HELP: use `::<...>` instead of `<...>` +fn foo<'min,'max>(v: SomeStruct<&'min ()>) + -> SomeStruct<&'max ()> + where 'max : 'min +{ + v //~ ERROR mismatched types } + +fn main() { } diff --git a/src/test/compile-fail/virtual-structs.rs b/src/test/compile-fail/variance-use-covariant-struct-2.rs index 3b3c7d5a30f..d8e1a5f5f1c 100644 --- a/src/test/compile-fail/virtual-structs.rs +++ b/src/test/compile-fail/variance-use-covariant-struct-2.rs @@ -1,4 +1,4 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -8,13 +8,19 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Test diagnostics for the removed struct inheritance feature. -#![feature(struct_inherit)] +// Test that a covariant struct permits the lifetime of a reference to +// be shortened. -virtual struct SuperStruct { //~ ERROR `virtual` structs have been removed from the language - f1: isize, -} +#![allow(dead_code)] +#![feature(rustc_attrs)] + +struct SomeStruct<T>(T); -struct Struct : SuperStruct; //~ ERROR `virtual` structs have been removed from the language +fn foo<'min,'max>(v: SomeStruct<&'max ()>) + -> SomeStruct<&'min ()> + where 'max : 'min +{ + v +} -pub fn main() {} +#[rustc_error] fn main() { } //~ ERROR compilation successful diff --git a/src/test/compile-fail/variance-use-invariant-struct-1.rs b/src/test/compile-fail/variance-use-invariant-struct-1.rs new file mode 100644 index 00000000000..c89436b2094 --- /dev/null +++ b/src/test/compile-fail/variance-use-invariant-struct-1.rs @@ -0,0 +1,33 @@ +// Copyright 2015 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 various uses of structs with distint variances to make sure +// they permit lifetimes to be approximated as expected. + +#![feature(rustc_attrs)] + +struct SomeStruct<T>(*mut T); + +fn foo<'min,'max>(v: SomeStruct<&'max ()>) + -> SomeStruct<&'min ()> + where 'max : 'min +{ + v //~ ERROR mismatched types +} + +fn bar<'min,'max>(v: SomeStruct<&'min ()>) + -> SomeStruct<&'max ()> + where 'max : 'min +{ + v //~ ERROR mismatched types +} + +#[rustc_error] +fn main() { } diff --git a/src/test/compile-fail/visible-private-types-generics.rs b/src/test/compile-fail/visible-private-types-generics.rs index 7ff18f8e088..1f2205b5c71 100644 --- a/src/test/compile-fail/visible-private-types-generics.rs +++ b/src/test/compile-fail/visible-private-types-generics.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait Foo {} +trait Foo { + fn dummy(&self) { } +} pub fn f< T diff --git a/src/test/compile-fail/visible-private-types-supertrait.rs b/src/test/compile-fail/visible-private-types-supertrait.rs index dc6d446154a..9d9eae4a075 100644 --- a/src/test/compile-fail/visible-private-types-supertrait.rs +++ b/src/test/compile-fail/visible-private-types-supertrait.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait Foo {} +trait Foo { + fn dummy(&self) { } +} pub trait Bar : Foo {} //~ ERROR private trait in exported type diff --git a/src/test/compile-fail/where-clause-method-substituion.rs b/src/test/compile-fail/where-clause-method-substituion.rs index a5108f005dc..bf614e6eb51 100644 --- a/src/test/compile-fail/where-clause-method-substituion.rs +++ b/src/test/compile-fail/where-clause-method-substituion.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait Foo<T> {} +trait Foo<T> { + fn dummy(&self, t: T) { } +} trait Bar<A> { fn method<B>(&self) where A: Foo<B>; diff --git a/src/test/compile-fail/where-clauses-not-parameter.rs b/src/test/compile-fail/where-clauses-not-parameter.rs index 313ae273c07..7968cc37090 100644 --- a/src/test/compile-fail/where-clauses-not-parameter.rs +++ b/src/test/compile-fail/where-clauses-not-parameter.rs @@ -21,7 +21,7 @@ fn test2() -> bool where Option<isize> : Eq {} #[derive(PartialEq)] //~^ ERROR cannot bound type `isize`, where clause bounds -enum Foo<T> where isize : Eq { MkFoo } +enum Foo<T> where isize : Eq { MkFoo(T) } //~^ ERROR cannot bound type `isize`, where clause bounds fn test3<T: Eq>() -> bool where Option<Foo<T>> : Eq {} @@ -31,7 +31,7 @@ fn test4() -> bool where Option<Foo<isize>> : Eq {} trait Baz<T> where isize : Eq { //~^ ERROR cannot bound type `isize`, where clause bounds may only - fn baz() where String : Eq; //~ ERROR cannot bound type `collections::string::String` + fn baz(&self, t: T) where String : Eq; //~ ERROR cannot bound type `collections::string::String` //~^ ERROR cannot bound type `isize`, where clause } |
