diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2015-01-28 23:03:36 +0530 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2015-01-28 23:31:03 +0530 |
| commit | c709ed2faf4ea28df1395a924453b5298b87fa57 (patch) | |
| tree | 9567cea197e37b96607f471b18dd1c77908c8965 /src/test | |
| parent | 249c29fe2746d251dc8aab63cd8730df9ff8434c (diff) | |
| parent | a45e117733b866302fa99390553d1c548508dcca (diff) | |
| download | rust-c709ed2faf4ea28df1395a924453b5298b87fa57.tar.gz rust-c709ed2faf4ea28df1395a924453b5298b87fa57.zip | |
Merge remote-tracking branch 'origin/master' into rollup
Conflicts: src/libcollections/slice.rs src/libcore/nonzero.rs src/libcore/ops.rs
Diffstat (limited to 'src/test')
105 files changed, 931 insertions, 508 deletions
diff --git a/src/test/auxiliary/inherited_stability.rs b/src/test/auxiliary/inherited_stability.rs index 7a01ce3de0b..77eb82f8022 100644 --- a/src/test/auxiliary/inherited_stability.rs +++ b/src/test/auxiliary/inherited_stability.rs @@ -9,52 +9,47 @@ // except according to those terms. #![crate_name="inherited_stability"] #![crate_type = "lib"] -#![unstable] +#![unstable(feature = "test_feature")] +#![feature(staged_api)] #![staged_api] -pub fn experimental() {} +pub fn unstable() {} -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] pub fn stable() {} -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] pub mod stable_mod { - pub fn experimental() {} + pub fn unstable() {} - #[stable] + #[stable(feature = "rust1", since = "1.0.0")] pub fn stable() {} } -#[unstable] +#[unstable(feature = "test_feature")] pub mod unstable_mod { - #[unstable] - pub fn experimental() {} + #[stable(feature = "test_feature", since = "1.0.0")] + #[deprecated(since = "1.0.0")] + pub fn deprecated() {} pub fn unstable() {} } -pub mod experimental_mod { - pub fn experimental() {} - - #[stable] - pub fn stable() {} -} - -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] pub trait Stable { - fn experimental(&self); + fn unstable(&self); - #[stable] + #[stable(feature = "rust1", since = "1.0.0")] fn stable(&self); } impl Stable for uint { - fn experimental(&self) {} + fn unstable(&self) {} fn stable(&self) {} } -pub enum Experimental { - ExperimentalVariant, - #[stable] +pub enum Unstable { + UnstableVariant, + #[stable(feature = "rust1", since = "1.0.0")] StableVariant } diff --git a/src/test/auxiliary/lint_output_format.rs b/src/test/auxiliary/lint_output_format.rs index adbb90fe6c8..1977e2aad28 100755 --- a/src/test/auxiliary/lint_output_format.rs +++ b/src/test/auxiliary/lint_output_format.rs @@ -10,19 +10,22 @@ #![crate_name="lint_output_format"] #![crate_type = "lib"] +#![feature(staged_api)] #![staged_api] +#![unstable(feature = "test_feature")] -#[deprecated] +#[stable(feature = "test_feature", since = "1.0.0")] +#[deprecated(since = "1.0.0")] pub fn foo() -> uint { 20 } -#[unstable] +#[unstable(feature = "test_feature")] pub fn bar() -> uint { 40 } -#[unstable] +#[unstable(feature = "test_feature")] pub fn baz() -> uint { 30 } diff --git a/src/test/auxiliary/lint_stability.rs b/src/test/auxiliary/lint_stability.rs index 73724713b21..3679557d06b 100644 --- a/src/test/auxiliary/lint_stability.rs +++ b/src/test/auxiliary/lint_stability.rs @@ -9,64 +9,63 @@ // except according to those terms. #![crate_name="lint_stability"] #![crate_type = "lib"] +#![feature(staged_api)] #![staged_api] -#[deprecated] +#[stable(feature = "test_feature", since = "1.0.0")] +#[deprecated(since = "1.0.0")] pub fn deprecated() {} -#[deprecated="text"] +#[stable(feature = "test_feature", since = "1.0.0")] +#[deprecated(since = "1.0.0", reason = "text")] pub fn deprecated_text() {} -#[unstable] -pub fn experimental() {} -#[unstable="text"] -pub fn experimental_text() {} +#[unstable(feature = "test_feature")] +#[deprecated(since = "1.0.0")] +pub fn deprecated_unstable() {} +#[unstable(feature = "test_feature")] +#[deprecated(since = "1.0.0", reason = "text")] +pub fn deprecated_unstable_text() {} -#[unstable] +#[unstable(feature = "test_feature")] pub fn unstable() {} -#[unstable="text"] +#[unstable(feature = "test_feature", reason = "text")] pub fn unstable_text() {} pub fn unmarked() {} -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] pub fn stable() {} -#[stable="text"] +#[stable(feature = "rust1", since = "1.0.0", reason = "text")] pub fn stable_text() {} -#[locked] -pub fn locked() {} -#[locked="text"] -pub fn locked_text() {} - -#[frozen] -pub fn frozen() {} -#[frozen="text"] -pub fn frozen_text() {} - -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] pub struct MethodTester; impl MethodTester { - #[deprecated] + #[stable(feature = "test_feature", since = "1.0.0")] + #[deprecated(since = "1.0.0")] pub fn method_deprecated(&self) {} - #[deprecated="text"] + #[stable(feature = "test_feature", since = "1.0.0")] + #[deprecated(since = "1.0.0", reason = "text")] pub fn method_deprecated_text(&self) {} - #[unstable] - pub fn method_experimental(&self) {} - #[unstable="text"] - pub fn method_experimental_text(&self) {} + #[unstable(feature = "test_feature")] + #[deprecated(since = "1.0.0")] + pub fn method_deprecated_unstable(&self) {} + #[unstable(feature = "test_feature")] + #[deprecated(since = "1.0.0", reason = "text")] + pub fn method_deprecated_unstable_text(&self) {} - #[unstable] + #[unstable(feature = "test_feature")] pub fn method_unstable(&self) {} - #[unstable="text"] + #[unstable(feature = "test_feature", reason = "text")] pub fn method_unstable_text(&self) {} pub fn method_unmarked(&self) {} - #[stable] + #[stable(feature = "rust1", since = "1.0.0")] pub fn method_stable(&self) {} - #[stable="text"] + #[stable(feature = "rust1", since = "1.0.0", reason = "text")] pub fn method_stable_text(&self) {} #[locked] @@ -81,26 +80,30 @@ impl MethodTester { } pub trait Trait { - #[deprecated] + #[stable(feature = "test_feature", since = "1.0.0")] + #[deprecated(since = "1.0.0")] fn trait_deprecated(&self) {} - #[deprecated="text"] + #[stable(feature = "test_feature", since = "1.0.0")] + #[deprecated(since = "1.0.0", reason = "text")] fn trait_deprecated_text(&self) {} - #[unstable] - fn trait_experimental(&self) {} - #[unstable="text"] - fn trait_experimental_text(&self) {} + #[unstable(feature = "test_feature")] + #[deprecated(since = "1.0.0")] + fn trait_deprecated_unstable(&self) {} + #[unstable(feature = "test_feature")] + #[deprecated(since = "1.0.0", reason = "text")] + fn trait_deprecated_unstable_text(&self) {} - #[unstable] + #[unstable(feature = "test_feature")] fn trait_unstable(&self) {} - #[unstable="text"] + #[unstable(feature = "test_feature", reason = "text")] fn trait_unstable_text(&self) {} fn trait_unmarked(&self) {} - #[stable] + #[stable(feature = "rust1", since = "1.0.0")] fn trait_stable(&self) {} - #[stable="text"] + #[stable(feature = "rust1", since = "1.0.0", reason = "text")] fn trait_stable_text(&self) {} #[locked] @@ -116,67 +119,59 @@ pub trait Trait { impl Trait for MethodTester {} -#[unstable] -pub trait ExperimentalTrait {} +#[unstable(feature = "test_feature")] +pub trait UnstableTrait {} -#[deprecated] +#[stable(feature = "test_feature", since = "1.0.0")] +#[deprecated(since = "1.0.0")] pub struct DeprecatedStruct { pub i: int } -#[unstable] -pub struct ExperimentalStruct { pub i: int } -#[unstable] +#[unstable(feature = "test_feature")] +#[deprecated(since = "1.0.0")] +pub struct DeprecatedUnstableStruct { pub i: int } +#[unstable(feature = "test_feature")] pub struct UnstableStruct { pub i: int } pub struct UnmarkedStruct { pub i: int } -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] pub struct StableStruct { pub i: int } -#[frozen] -pub struct FrozenStruct { pub i: int } -#[locked] -pub struct LockedStruct { pub i: int } -#[deprecated] +#[stable(feature = "test_feature", since = "1.0.0")] +#[deprecated(since = "1.0.0")] pub struct DeprecatedUnitStruct; -#[unstable] -pub struct ExperimentalUnitStruct; -#[unstable] +#[unstable(feature = "test_feature")] +#[deprecated(since = "1.0.0")] +pub struct DeprecatedUnstableUnitStruct; +#[unstable(feature = "test_feature")] pub struct UnstableUnitStruct; pub struct UnmarkedUnitStruct; -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] pub struct StableUnitStruct; -#[frozen] -pub struct FrozenUnitStruct; -#[locked] -pub struct LockedUnitStruct; pub enum Enum { - #[deprecated] + #[stable(feature = "test_feature", since = "1.0.0")] + #[deprecated(since = "1.0.0")] DeprecatedVariant, - #[unstable] - ExperimentalVariant, - #[unstable] + #[unstable(feature = "test_feature")] + #[deprecated(since = "1.0.0")] + DeprecatedUnstableVariant, + #[unstable(feature = "test_feature")] UnstableVariant, UnmarkedVariant, - #[stable] + #[stable(feature = "rust1", since = "1.0.0")] StableVariant, - #[frozen] - FrozenVariant, - #[locked] - LockedVariant, } -#[deprecated] +#[stable(feature = "test_feature", since = "1.0.0")] +#[deprecated(since = "1.0.0")] pub struct DeprecatedTupleStruct(pub int); -#[unstable] -pub struct ExperimentalTupleStruct(pub int); -#[unstable] +#[unstable(feature = "test_feature")] +#[deprecated(since = "1.0.0")] +pub struct DeprecatedUnstableTupleStruct(pub int); +#[unstable(feature = "test_feature")] pub struct UnstableTupleStruct(pub int); pub struct UnmarkedTupleStruct(pub int); -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] pub struct StableTupleStruct(pub int); -#[frozen] -pub struct FrozenTupleStruct(pub int); -#[locked] -pub struct LockedTupleStruct(pub int); #[macro_export] macro_rules! macro_test { diff --git a/src/test/auxiliary/stability_cfg1.rs b/src/test/auxiliary/stability_cfg1.rs index de806c65beb..3a92cf59611 100644 --- a/src/test/auxiliary/stability_cfg1.rs +++ b/src/test/auxiliary/stability_cfg1.rs @@ -9,5 +9,6 @@ // except according to those terms. #![cfg_attr(foo, experimental)] -#![cfg_attr(not(foo), stable)] +#![cfg_attr(not(foo), stable(feature = "test_feature", since = "1.0.0"))] +#![feature(staged_api)] #![staged_api] diff --git a/src/test/auxiliary/stability_cfg2.rs b/src/test/auxiliary/stability_cfg2.rs index 842f35b08ae..d9ed76e5c58 100644 --- a/src/test/auxiliary/stability_cfg2.rs +++ b/src/test/auxiliary/stability_cfg2.rs @@ -10,6 +10,7 @@ // compile-flags:--cfg foo -#![cfg_attr(foo, unstable)] -#![cfg_attr(not(foo), stable)] +#![cfg_attr(foo, unstable(feature = "test_feature"))] +#![cfg_attr(not(foo), stable(feature = "test_feature", since = "1.0.0"))] +#![feature(staged_api)] #![staged_api] diff --git a/src/test/bench/shootout-mandelbrot.rs b/src/test/bench/shootout-mandelbrot.rs index d261f3f3cf2..0bd69b73214 100644 --- a/src/test/bench/shootout-mandelbrot.rs +++ b/src/test/bench/shootout-mandelbrot.rs @@ -39,7 +39,6 @@ // OF THE POSSIBILITY OF SUCH DAMAGE. #![feature(simd)] -#![allow(unstable)] // ignore-pretty very bad with line comments diff --git a/src/test/compile-fail/associated-type-projection-from-supertrait.rs b/src/test/compile-fail/associated-type-projection-from-supertrait.rs index abaf79fb4cb..b388b6a28e3 100644 --- a/src/test/compile-fail/associated-type-projection-from-supertrait.rs +++ b/src/test/compile-fail/associated-type-projection-from-supertrait.rs @@ -40,8 +40,8 @@ impl Car for ModelU { } fn dent<C:Car>(c: C, color: C::Color) { c.chip_paint(color) } fn a() { dent(ModelT, Black); } -fn b() { dent(ModelT, Blue); } //~ ERROR type mismatch -fn c() { dent(ModelU, Black); } //~ ERROR type mismatch +fn b() { dent(ModelT, Blue); } //~ ERROR mismatched types +fn c() { dent(ModelU, Black); } //~ ERROR mismatched types fn d() { dent(ModelU, Blue); } /////////////////////////////////////////////////////////////////////////// diff --git a/src/test/compile-fail/associated-types-path-2.rs b/src/test/compile-fail/associated-types-path-2.rs index 5cb9aca8beb..55ba65d6102 100644 --- a/src/test/compile-fail/associated-types-path-2.rs +++ b/src/test/compile-fail/associated-types-path-2.rs @@ -25,7 +25,7 @@ pub fn f2<T: Foo>(a: T) -> T::A { pub fn f1_int_int() { f1(2is, 4is); - //~^ ERROR type mismatch resolving + //~^ ERROR mismatched types //~| expected usize //~| found isize } @@ -51,8 +51,6 @@ pub fn f2_int() { //~^ ERROR mismatched types //~| expected `isize` //~| found `usize` - //~| expected isize - //~| found usize } pub fn main() { } diff --git a/src/test/compile-fail/borrowck-overloaded-call.rs b/src/test/compile-fail/borrowck-overloaded-call.rs index 7d35a27c0ae..04d73cc36f0 100644 --- a/src/test/compile-fail/borrowck-overloaded-call.rs +++ b/src/test/compile-fail/borrowck-overloaded-call.rs @@ -17,7 +17,9 @@ struct SFn { y: isize, } -impl Fn<(isize,),isize> for SFn { +impl Fn<(isize,)> for SFn { + type Output = isize; + extern "rust-call" fn call(&self, (z,): (isize,)) -> isize { self.x * self.y * z } @@ -28,7 +30,9 @@ struct SFnMut { y: isize, } -impl FnMut<(isize,),isize> for SFnMut { +impl FnMut<(isize,)> for SFnMut { + type Output = isize; + extern "rust-call" fn call_mut(&mut self, (z,): (isize,)) -> isize { self.x * self.y * z } @@ -38,7 +42,9 @@ struct SFnOnce { x: String, } -impl FnOnce<(String,),usize> for SFnOnce { +impl FnOnce<(String,)> for SFnOnce { + type Output = usize; + extern "rust-call" fn call_once(self, (z,): (String,)) -> usize { self.x.len() + z.len() } diff --git a/src/test/compile-fail/enable-unstable-lib-feature.rs b/src/test/compile-fail/enable-unstable-lib-feature.rs new file mode 100644 index 00000000000..c65b2366bf1 --- /dev/null +++ b/src/test/compile-fail/enable-unstable-lib-feature.rs @@ -0,0 +1,23 @@ +// 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 enabling an unstable feature disables warnings + +// aux-build:stability_cfg2.rs + +#![feature(test_feature)] +#![deny(non_snake_case)] // To trigger a hard error + +// Shouldn't generate a warning about unstable features +extern crate stability_cfg2; + +pub fn BOGUS() { } //~ ERROR + +pub fn main() { } diff --git a/src/test/compile-fail/extern-wrong-value-type.rs b/src/test/compile-fail/extern-wrong-value-type.rs index d7586af291e..db3373ea027 100644 --- a/src/test/compile-fail/extern-wrong-value-type.rs +++ b/src/test/compile-fail/extern-wrong-value-type.rs @@ -16,5 +16,7 @@ fn is_fn<F>(_: F) where F: Fn() {} fn main() { // extern functions are extern "C" fn let _x: extern "C" fn() = f; // OK - is_fn(f); //~ ERROR the trait `core::ops::Fn()` is not implemented for the type `extern "C" fn() + is_fn(f); + //~^ ERROR the trait `core::ops::Fn<()>` is not implemented for the type `extern "C" fn() + //~| ERROR the trait `core::ops::Fn<()>` is not implemented for the type `extern "C" fn() } diff --git a/src/test/compile-fail/fail-no-dead-code-core.rs b/src/test/compile-fail/fail-no-dead-code-core.rs index ee86c6ca1f0..9923db3c566 100644 --- a/src/test/compile-fail/fail-no-dead-code-core.rs +++ b/src/test/compile-fail/fail-no-dead-code-core.rs @@ -10,7 +10,7 @@ #![deny(dead_code)] #![allow(unreachable_code)] -#![allow(unstable)] +#![feature(core)] #[macro_use] extern crate core; diff --git a/src/test/compile-fail/feature-gate-unboxed-closures-manual-impls.rs b/src/test/compile-fail/feature-gate-unboxed-closures-manual-impls.rs index cdb207f705f..e5e5ddadafc 100644 --- a/src/test/compile-fail/feature-gate-unboxed-closures-manual-impls.rs +++ b/src/test/compile-fail/feature-gate-unboxed-closures-manual-impls.rs @@ -8,18 +8,38 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// Test that manual impls of the `Fn` traits are not possible without +// a feature gate. In fact, the specialized check for these cases +// never triggers (yet), because they encounter other problems around +// angle bracket vs parentheses notation. + #![allow(dead_code)] struct Foo; -impl Fn() for Foo { //~ ERROR manual implementations of `Fn` are experimental +impl Fn<()> for Foo { + //~^ ERROR angle-bracket notation is not stable when used with the `Fn` family of traits + type Output = (); + + extern "rust-call" fn call(&self, args: ()) -> () {} +} +struct Foo1; +impl Fn() for Foo1 { + //~^ ERROR associated type bindings are not allowed here + extern "rust-call" fn call(&self, args: ()) -> () {} } struct Bar; -impl FnMut() for Bar { //~ ERROR manual implementations of `FnMut` are experimental +impl FnMut<()> for Bar { + //~^ ERROR angle-bracket notation is not stable when used with the `Fn` family of traits + type Output = (); + extern "rust-call" fn call_mut(&self, args: ()) -> () {} } struct Baz; -impl FnOnce() for Baz { //~ ERROR manual implementations of `FnOnce` are experimental +impl FnOnce<()> for Baz { + //~^ ERROR angle-bracket notation is not stable when used with the `Fn` family of traits + type Output = (); + extern "rust-call" fn call_once(&self, args: ()) -> () {} } diff --git a/src/test/compile-fail/fn-trait-formatting.rs b/src/test/compile-fail/fn-trait-formatting.rs index f19e27640cb..460e05c8438 100644 --- a/src/test/compile-fail/fn-trait-formatting.rs +++ b/src/test/compile-fail/fn-trait-formatting.rs @@ -34,5 +34,7 @@ fn main() { //~| expected () //~| found box - needs_fn(1is); //~ ERROR `core::ops::Fn(isize) -> isize` + needs_fn(1is); + //~^ ERROR `core::ops::Fn<(isize,)>` + //~| ERROR `core::ops::Fn<(isize,)>` } diff --git a/src/test/compile-fail/issue-15094.rs b/src/test/compile-fail/issue-15094.rs index 2c03a9e0733..977586483b0 100644 --- a/src/test/compile-fail/issue-15094.rs +++ b/src/test/compile-fail/issue-15094.rs @@ -16,7 +16,9 @@ struct Debuger<T> { x: T } -impl<T: fmt::Debug> ops::Fn<(), ()> for Debuger<T> { +impl<T: fmt::Debug> ops::Fn<(),> for Debuger<T> { + type Output = (); + fn call(&self, _args: ()) { //~^ ERROR `call` has an incompatible type for trait: expected "rust-call" fn, found "Rust" fn println!("{:?}", self.x); diff --git a/src/test/compile-fail/issue-17337.rs b/src/test/compile-fail/issue-17337.rs index 24425e5eeec..ff640793afe 100644 --- a/src/test/compile-fail/issue-17337.rs +++ b/src/test/compile-fail/issue-17337.rs @@ -8,13 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(staged_api)] #![staged_api] #![deny(deprecated)] struct Foo; impl Foo { - #[deprecated] + #[unstable(feature = "test_feature")] + #[deprecated(since = "1.0.0")] fn foo(self) {} } diff --git a/src/test/compile-fail/issue-17545.rs b/src/test/compile-fail/issue-17545.rs index 0501a3013cc..84800218efc 100644 --- a/src/test/compile-fail/issue-17545.rs +++ b/src/test/compile-fail/issue-17545.rs @@ -10,7 +10,7 @@ #![feature(unboxed_closures)] -pub fn foo<'a, F: Fn<(&'a (),), ()>>(bar: F) { +pub fn foo<'a, F: Fn(&'a ())>(bar: F) { bar.call(( &(), //~ ERROR borrowed value does not live long enough )); diff --git a/src/test/compile-fail/issue-17999.rs b/src/test/compile-fail/issue-17999.rs index eaefe55e066..a8804a6df06 100644 --- a/src/test/compile-fail/issue-17999.rs +++ b/src/test/compile-fail/issue-17999.rs @@ -9,7 +9,7 @@ // except according to those terms. #![deny(unused_variables)] -#![allow(unstable)] +#![feature(core)] fn main() { for _ in range(1is, 101) { diff --git a/src/test/compile-fail/issue-18400.rs b/src/test/compile-fail/issue-18400.rs index a6662e78f3e..f3b2b3d5667 100644 --- a/src/test/compile-fail/issue-18400.rs +++ b/src/test/compile-fail/issue-18400.rs @@ -32,5 +32,8 @@ fn main() { let bits: &[_] = &[0, 1]; 0.contains(bits); -//~^ ERROR the trait `Set<_>` is not implemented for the type `_` + //~^ ERROR overflow + //~| ERROR overflow + //~| ERROR overflow + //~| ERROR mismatched types } diff --git a/src/test/compile-fail/issue-20711-2.rs b/src/test/compile-fail/issue-20711-2.rs index f5f5c4fe8d7..9f0e81a662f 100644 --- a/src/test/compile-fail/issue-20711-2.rs +++ b/src/test/compile-fail/issue-20711-2.rs @@ -13,7 +13,7 @@ struct Foo; impl Foo { fn foo() {} - #[stable] + #[stable(feature = "rust1", since = "1.0.0")] } //~ ERROR expected `fn`, found `}` fn main() {} diff --git a/src/test/compile-fail/issue-20711.rs b/src/test/compile-fail/issue-20711.rs index b065355394c..5f0f0fc05a9 100644 --- a/src/test/compile-fail/issue-20711.rs +++ b/src/test/compile-fail/issue-20711.rs @@ -11,7 +11,7 @@ struct Foo; impl Foo { - #[stable] + #[stable(feature = "rust1", since = "1.0.0")] } //~ ERROR expected `fn`, found `}` fn main() {} diff --git a/src/test/compile-fail/issue-21160.rs b/src/test/compile-fail/issue-21160.rs index 0ee38166935..45b7fbbd0b4 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<__S>` 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-21356.rs b/src/test/compile-fail/issue-21356.rs index 979534ab30c..fefd432e229 100644 --- a/src/test/compile-fail/issue-21356.rs +++ b/src/test/compile-fail/issue-21356.rs @@ -9,6 +9,6 @@ // except according to those terms. macro_rules! test { ($wrong:t_ty ..) => () } - //~^ ERROR: unrecognized builtin nonterminal `t_ty` + //~^ ERROR: invalid fragment specifier `t_ty` fn main() {} diff --git a/src/test/compile-fail/lint-ctypes.rs b/src/test/compile-fail/lint-ctypes.rs index 5706453a220..3f25e9c7b76 100644 --- a/src/test/compile-fail/lint-ctypes.rs +++ b/src/test/compile-fail/lint-ctypes.rs @@ -9,7 +9,7 @@ // except according to those terms. #![deny(improper_ctypes)] -#![allow(unstable)] +#![feature(libc)] extern crate libc; diff --git a/src/test/compile-fail/lint-dead-code-1.rs b/src/test/compile-fail/lint-dead-code-1.rs index ceba33360d9..dc591943731 100644 --- a/src/test/compile-fail/lint-dead-code-1.rs +++ b/src/test/compile-fail/lint-dead-code-1.rs @@ -13,8 +13,8 @@ #![allow(non_camel_case_types)] #![allow(non_upper_case_globals)] #![allow(missing_copy_implementations)] -#![allow(unstable)] #![deny(dead_code)] +#![feature(core)] #![crate_type="lib"] diff --git a/src/test/compile-fail/lint-dead-code-3.rs b/src/test/compile-fail/lint-dead-code-3.rs index 89ab78968d0..be135978d2d 100644 --- a/src/test/compile-fail/lint-dead-code-3.rs +++ b/src/test/compile-fail/lint-dead-code-3.rs @@ -10,8 +10,8 @@ #![allow(unused_variables)] #![allow(non_camel_case_types)] -#![allow(unstable)] #![deny(dead_code)] +#![feature(libc)] #![crate_type="lib"] diff --git a/src/test/compile-fail/lint-dead-code-4.rs b/src/test/compile-fail/lint-dead-code-4.rs index 3221be220d9..22570bad616 100644 --- a/src/test/compile-fail/lint-dead-code-4.rs +++ b/src/test/compile-fail/lint-dead-code-4.rs @@ -10,8 +10,10 @@ #![allow(unused_variables)] #![allow(non_camel_case_types)] -#![allow(unstable)] #![deny(dead_code)] +#![feature(libc)] +#![feature(core)] +#![feature(collections)] extern crate libc; diff --git a/src/test/compile-fail/lint-exceeding-bitshifts.rs b/src/test/compile-fail/lint-exceeding-bitshifts.rs index 4c880eda099..98853a2e9a1 100644 --- a/src/test/compile-fail/lint-exceeding-bitshifts.rs +++ b/src/test/compile-fail/lint-exceeding-bitshifts.rs @@ -10,8 +10,8 @@ #![deny(exceeding_bitshifts)] #![allow(unused_variables)] -#![allow(unstable)] #![allow(dead_code)] +#![feature(core)] fn main() { let n = 1u8 << 7; diff --git a/src/test/compile-fail/lint-forbid-attr.rs b/src/test/compile-fail/lint-forbid-attr.rs index d1fcf62115b..fcc8fb6f933 100644 --- a/src/test/compile-fail/lint-forbid-attr.rs +++ b/src/test/compile-fail/lint-forbid-attr.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![forbid(unstable)] +#![forbid(deprecated)] -#[allow(unstable)] //~ ERROR allow(unstable) overruled by outer forbid(unstable) +#[allow(deprecated)] //~ ERROR allow(deprecated) overruled by outer forbid(deprecated) fn main() { } diff --git a/src/test/compile-fail/lint-forbid-cmdline.rs b/src/test/compile-fail/lint-forbid-cmdline.rs index e3be0d06a35..be927297be7 100644 --- a/src/test/compile-fail/lint-forbid-cmdline.rs +++ b/src/test/compile-fail/lint-forbid-cmdline.rs @@ -8,9 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// compile-flags: -F unstable +// compile-flags: -F deprecated +#![feature(staged_api)] #![staged_api] -#[allow(unstable)] //~ ERROR allow(unstable) overruled by outer forbid(unstable) +#[allow(deprecated)] //~ ERROR allow(deprecated) overruled by outer forbid(deprecated) fn main() { } diff --git a/src/test/compile-fail/lint-output-format.rs b/src/test/compile-fail/lint-output-format.rs index 10217481bf3..ec4e3c774db 100644 --- a/src/test/compile-fail/lint-output-format.rs +++ b/src/test/compile-fail/lint-output-format.rs @@ -8,13 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// compile-flags:-F unstable +// compile-flags: -F unused_features // aux-build:lint_output_format.rs -extern crate lint_output_format; //~ ERROR: use of unmarked item +#![feature(foo)] //~ ERROR unused or unknown feature + +extern crate lint_output_format; //~ WARNING: use of unstable library feature use lint_output_format::{foo, bar}; fn main() { let _x = foo(); //~ WARNING #[warn(deprecated)] on by default - let _y = bar(); //~ ERROR [-F unstable] + let _y = bar(); //~ WARNING: use of unstable library feature } diff --git a/src/test/compile-fail/lint-stability.rs b/src/test/compile-fail/lint-stability.rs index eab5e98d68f..5b093a8556c 100644 --- a/src/test/compile-fail/lint-stability.rs +++ b/src/test/compile-fail/lint-stability.rs @@ -12,19 +12,19 @@ // aux-build:inherited_stability.rs // aux-build:stability_cfg1.rs // aux-build:stability_cfg2.rs +// ignore-tidy-linelength -#![deny(unstable)] #![deny(deprecated)] -#![deny(unstable)] #![allow(dead_code)] +#![feature(staged_api)] #![staged_api] #[macro_use] -extern crate lint_stability; //~ ERROR: use of unmarked item +extern crate lint_stability; //~ ERROR: use of unmarked library feature mod cross_crate { extern crate stability_cfg1; - extern crate stability_cfg2; //~ ERROR: use of unstable item + extern crate stability_cfg2; //~ WARNING: use of unstable library feature use lint_stability::*; @@ -39,25 +39,31 @@ mod cross_crate { foo.method_deprecated_text(); //~ ERROR use of deprecated item: text foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text - experimental(); //~ ERROR use of unstable item - foo.method_experimental(); //~ ERROR use of unstable item - foo.trait_experimental(); //~ ERROR use of unstable item + deprecated_unstable(); //~ ERROR use of deprecated item + //~^ WARNING use of unstable library feature + foo.method_deprecated_unstable(); //~ ERROR use of deprecated item + //~^ WARNING use of unstable library feature + foo.trait_deprecated_unstable(); //~ ERROR use of deprecated item + //~^ WARNING use of unstable library feature - experimental_text(); //~ ERROR use of unstable item: text - foo.method_experimental_text(); //~ ERROR use of unstable item: text - foo.trait_experimental_text(); //~ ERROR use of unstable item: text + deprecated_unstable_text(); //~ ERROR use of deprecated item: text + //~^ WARNING use of unstable library feature + foo.method_deprecated_unstable_text(); //~ ERROR use of deprecated item: text + //~^ WARNING use of unstable library feature + foo.trait_deprecated_unstable_text(); //~ ERROR use of deprecated item: text + //~^ WARNING use of unstable library feature - unstable(); //~ ERROR use of unstable item - foo.method_unstable(); //~ ERROR use of unstable item - foo.trait_unstable(); //~ ERROR use of unstable item + unstable(); //~ WARNING use of unstable library feature + foo.method_unstable(); //~ WARNING use of unstable library feature + foo.trait_unstable(); //~ WARNING use of unstable library feature - unstable_text(); //~ ERROR use of unstable item: text - foo.method_unstable_text(); //~ ERROR use of unstable item: text - foo.trait_unstable_text(); //~ ERROR use of unstable item: text + unstable_text(); //~ WARNING use of unstable library feature 'test_feature': text + foo.method_unstable_text(); //~ WARNING use of unstable library feature 'test_feature': text + foo.trait_unstable_text(); //~ WARNING use of unstable library feature 'test_feature': text - unmarked(); //~ ERROR use of unmarked item - foo.method_unmarked(); //~ ERROR use of unmarked item - foo.trait_unmarked(); //~ ERROR use of unmarked item + unmarked(); //~ ERROR use of unmarked library feature + foo.method_unmarked(); //~ ERROR use of unmarked library feature + foo.trait_unmarked(); //~ ERROR use of unmarked library feature stable(); foo.method_stable(); @@ -67,53 +73,33 @@ mod cross_crate { foo.method_stable_text(); foo.trait_stable_text(); - frozen(); - foo.method_frozen(); - foo.trait_frozen(); - - frozen_text(); - foo.method_frozen_text(); - foo.trait_frozen_text(); - - locked(); - foo.method_locked(); - foo.trait_locked(); - - locked_text(); - foo.method_locked_text(); - foo.trait_locked_text(); - let _ = DeprecatedStruct { i: 0 }; //~ ERROR use of deprecated item - let _ = ExperimentalStruct { i: 0 }; //~ ERROR use of unstable item - let _ = UnstableStruct { i: 0 }; //~ ERROR use of unstable item - let _ = UnmarkedStruct { i: 0 }; //~ ERROR use of unmarked item + let _ = DeprecatedUnstableStruct { i: 0 }; //~ ERROR use of deprecated item + //~^ WARNING use of unstable library feature + let _ = UnstableStruct { i: 0 }; //~ WARNING use of unstable library feature + let _ = UnmarkedStruct { i: 0 }; //~ ERROR use of unmarked library feature let _ = StableStruct { i: 0 }; - let _ = FrozenStruct { i: 0 }; - let _ = LockedStruct { i: 0 }; let _ = DeprecatedUnitStruct; //~ ERROR use of deprecated item - let _ = ExperimentalUnitStruct; //~ ERROR use of unstable item - let _ = UnstableUnitStruct; //~ ERROR use of unstable item - let _ = UnmarkedUnitStruct; //~ ERROR use of unmarked item + let _ = DeprecatedUnstableUnitStruct; //~ ERROR use of deprecated item + //~^ WARNING use of unstable library feature + let _ = UnstableUnitStruct; //~ WARNING use of unstable library feature + let _ = UnmarkedUnitStruct; //~ ERROR use of unmarked library feature let _ = StableUnitStruct; - let _ = FrozenUnitStruct; - let _ = LockedUnitStruct; let _ = Enum::DeprecatedVariant; //~ ERROR use of deprecated item - let _ = Enum::ExperimentalVariant; //~ ERROR use of unstable item - let _ = Enum::UnstableVariant; //~ ERROR use of unstable item - let _ = Enum::UnmarkedVariant; //~ ERROR use of unmarked item + let _ = Enum::DeprecatedUnstableVariant; //~ ERROR use of deprecated item + //~^ WARNING use of unstable library feature + let _ = Enum::UnstableVariant; //~ WARNING use of unstable library feature + let _ = Enum::UnmarkedVariant; //~ ERROR use of unmarked library feature let _ = Enum::StableVariant; - let _ = Enum::FrozenVariant; - let _ = Enum::LockedVariant; let _ = DeprecatedTupleStruct (1); //~ ERROR use of deprecated item - let _ = ExperimentalTupleStruct (1); //~ ERROR use of unstable item - let _ = UnstableTupleStruct (1); //~ ERROR use of unstable item - let _ = UnmarkedTupleStruct (1); //~ ERROR use of unmarked item + let _ = DeprecatedUnstableTupleStruct (1); //~ ERROR use of deprecated item + //~^ WARNING use of unstable library feature + let _ = UnstableTupleStruct (1); //~ WARNING use of unstable library feature + let _ = UnmarkedTupleStruct (1); //~ ERROR use of unmarked library feature let _ = StableTupleStruct (1); - let _ = FrozenTupleStruct (1); - let _ = LockedTupleStruct (1); // At the moment, the lint checker only checks stability in // in the arguments of macros. @@ -122,6 +108,8 @@ mod cross_crate { // on macros themselves are not yet linted. macro_test!(); macro_test_arg!(deprecated_text()); //~ ERROR use of deprecated item: text + macro_test_arg!(deprecated_unstable_text()); //~ ERROR use of deprecated item: text + //~^ WARNING use of unstable library feature macro_test_arg!(macro_test_arg!(deprecated_text())); //~ ERROR use of deprecated item: text macro_test_arg_nested!(deprecated_text); } @@ -129,222 +117,164 @@ mod cross_crate { fn test_method_param<F: Trait>(foo: F) { foo.trait_deprecated(); //~ ERROR use of deprecated item foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text - foo.trait_experimental(); //~ ERROR use of unstable item - foo.trait_experimental_text(); //~ ERROR use of unstable item: text - foo.trait_unstable(); //~ ERROR use of unstable item - foo.trait_unstable_text(); //~ ERROR use of unstable item: text - foo.trait_unmarked(); //~ ERROR use of unmarked item + foo.trait_deprecated_unstable(); //~ ERROR use of deprecated item + //~^ WARNING use of unstable library feature + foo.trait_deprecated_unstable_text(); //~ ERROR use of deprecated item: text + //~^ WARNING use of unstable library feature + foo.trait_unstable(); //~ WARNING use of unstable library feature + foo.trait_unstable_text(); //~ WARNING use of unstable library feature 'test_feature': text + foo.trait_unmarked(); //~ ERROR use of unmarked library feature foo.trait_stable(); } fn test_method_object(foo: &Trait) { foo.trait_deprecated(); //~ ERROR use of deprecated item foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text - foo.trait_experimental(); //~ ERROR use of unstable item - foo.trait_experimental_text(); //~ ERROR use of unstable item: text - foo.trait_unstable(); //~ ERROR use of unstable item - foo.trait_unstable_text(); //~ ERROR use of unstable item: text - foo.trait_unmarked(); //~ ERROR use of unmarked item + foo.trait_deprecated_unstable(); //~ ERROR use of deprecated item + //~^ WARNING use of unstable library feature + foo.trait_deprecated_unstable_text(); //~ ERROR use of deprecated item: text + //~^ WARNING use of unstable library feature + foo.trait_unstable(); //~ WARNING use of unstable library feature + foo.trait_unstable_text(); //~ WARNING use of unstable library feature 'test_feature': text + foo.trait_unmarked(); //~ ERROR use of unmarked library feature foo.trait_stable(); } struct S; - impl ExperimentalTrait for S { } //~ ERROR use of unstable item + impl UnstableTrait for S { } //~ WARNING use of unstable library feature - trait LocalTrait : ExperimentalTrait { } //~ ERROR use of unstable item + trait LocalTrait : UnstableTrait { } //~ WARNING use of unstable library feature } mod inheritance { - extern crate inherited_stability; //~ ERROR: use of unstable item + extern crate inherited_stability; //~ WARNING: use of unstable library feature use self::inherited_stability::*; fn test_inheritance() { - experimental(); //~ ERROR use of unstable item + unstable(); //~ WARNING use of unstable library feature stable(); - stable_mod::experimental(); //~ ERROR use of unstable item + stable_mod::unstable(); //~ WARNING use of unstable library feature stable_mod::stable(); - unstable_mod::experimental(); //~ ERROR use of unstable item - unstable_mod::unstable(); //~ ERROR use of unstable item - - experimental_mod::experimental(); //~ ERROR use of unstable item - experimental_mod::stable(); + unstable_mod::deprecated(); //~ ERROR use of deprecated item + unstable_mod::unstable(); //~ WARNING use of unstable library feature - let _ = Experimental::ExperimentalVariant; //~ ERROR use of unstable item - let _ = Experimental::StableVariant; + let _ = Unstable::UnstableVariant; //~ WARNING use of unstable library feature + let _ = Unstable::StableVariant; let x: usize = 0; - x.experimental(); //~ ERROR use of unstable item + x.unstable(); //~ WARNING use of unstable library feature x.stable(); } } mod this_crate { - #[deprecated] + #[unstable(feature = "test_feature")] + #[deprecated(since = "1.0.0")] pub fn deprecated() {} - #[deprecated="text"] + #[unstable(feature = "test_feature")] + #[deprecated(since = "1.0.0", reason = "text")] pub fn deprecated_text() {} - #[unstable] - pub fn experimental() {} - #[unstable="text"] - pub fn experimental_text() {} - - #[unstable] + #[unstable(feature = "test_feature")] pub fn unstable() {} - #[unstable="text"] + #[unstable(feature = "test_feature", reason = "text")] pub fn unstable_text() {} pub fn unmarked() {} - #[stable] + #[stable(feature = "rust1", since = "1.0.0")] pub fn stable() {} - #[stable="text"] + #[stable(feature = "rust1", since = "1.0.0", reason = "text")] pub fn stable_text() {} - #[locked] - pub fn locked() {} - #[locked="text"] - pub fn locked_text() {} - - #[frozen] - pub fn frozen() {} - #[frozen="text"] - pub fn frozen_text() {} - - #[stable] + #[stable(feature = "rust1", since = "1.0.0")] pub struct MethodTester; impl MethodTester { - #[deprecated] + #[unstable(feature = "test_feature")] + #[deprecated(since = "1.0.0")] pub fn method_deprecated(&self) {} - #[deprecated="text"] + #[unstable(feature = "test_feature")] + #[deprecated(since = "1.0.0", reason = "text")] pub fn method_deprecated_text(&self) {} - #[unstable] - pub fn method_experimental(&self) {} - #[unstable="text"] - pub fn method_experimental_text(&self) {} - - #[unstable] + #[unstable(feature = "test_feature")] pub fn method_unstable(&self) {} - #[unstable="text"] + #[unstable(feature = "test_feature", reason = "text")] pub fn method_unstable_text(&self) {} pub fn method_unmarked(&self) {} - #[stable] + #[stable(feature = "rust1", since = "1.0.0")] pub fn method_stable(&self) {} - #[stable="text"] + #[stable(feature = "rust1", since = "1.0.0", reason = "text")] pub fn method_stable_text(&self) {} - - #[locked] - pub fn method_locked(&self) {} - #[locked="text"] - pub fn method_locked_text(&self) {} - - #[frozen] - pub fn method_frozen(&self) {} - #[frozen="text"] - pub fn method_frozen_text(&self) {} } pub trait Trait { - #[deprecated] + #[unstable(feature = "test_feature")] + #[deprecated(since = "1.0.0")] fn trait_deprecated(&self) {} - #[deprecated="text"] + #[unstable(feature = "test_feature")] + #[deprecated(since = "1.0.0", reason = "text")] fn trait_deprecated_text(&self) {} - #[unstable] - fn trait_experimental(&self) {} - #[unstable="text"] - fn trait_experimental_text(&self) {} - - #[unstable] + #[unstable(feature = "test_feature")] fn trait_unstable(&self) {} - #[unstable="text"] + #[unstable(feature = "test_feature", reason = "text")] fn trait_unstable_text(&self) {} fn trait_unmarked(&self) {} - #[stable] + #[stable(feature = "rust1", since = "1.0.0")] fn trait_stable(&self) {} - #[stable="text"] + #[stable(feature = "rust1", since = "1.0.0", reason = "text")] fn trait_stable_text(&self) {} - - #[locked] - fn trait_locked(&self) {} - #[locked="text"] - fn trait_locked_text(&self) {} - - #[frozen] - fn trait_frozen(&self) {} - #[frozen="text"] - fn trait_frozen_text(&self) {} } impl Trait for MethodTester {} - #[deprecated] + #[unstable(feature = "test_feature")] + #[deprecated(since = "1.0.0")] pub struct DeprecatedStruct { i: isize } - #[unstable] - pub struct ExperimentalStruct { i: isize } - #[unstable] + #[unstable(feature = "test_feature")] pub struct UnstableStruct { i: isize } pub struct UnmarkedStruct { i: isize } - #[stable] + #[stable(feature = "rust1", since = "1.0.0")] pub struct StableStruct { i: isize } - #[frozen] - pub struct FrozenStruct { i: isize } - #[locked] - pub struct LockedStruct { i: isize } - #[deprecated] + #[unstable(feature = "test_feature")] + #[deprecated(since = "1.0.0")] pub struct DeprecatedUnitStruct; - #[unstable] - pub struct ExperimentalUnitStruct; - #[unstable] + #[unstable(feature = "test_feature")] pub struct UnstableUnitStruct; pub struct UnmarkedUnitStruct; - #[stable] + #[stable(feature = "rust1", since = "1.0.0")] pub struct StableUnitStruct; - #[frozen] - pub struct FrozenUnitStruct; - #[locked] - pub struct LockedUnitStruct; pub enum Enum { - #[deprecated] + #[unstable(feature = "test_feature")] + #[deprecated(since = "1.0.0")] DeprecatedVariant, - #[unstable] - ExperimentalVariant, - #[unstable] + #[unstable(feature = "test_feature")] UnstableVariant, UnmarkedVariant, - #[stable] + #[stable(feature = "rust1", since = "1.0.0")] StableVariant, - #[frozen] - FrozenVariant, - #[locked] - LockedVariant, } - #[deprecated] + #[unstable(feature = "test_feature")] + #[deprecated(since = "1.0.0")] pub struct DeprecatedTupleStruct(isize); - #[unstable] - pub struct ExperimentalTupleStruct(isize); - #[unstable] + #[unstable(feature = "test_feature")] pub struct UnstableTupleStruct(isize); pub struct UnmarkedTupleStruct(isize); - #[stable] + #[stable(feature = "rust1", since = "1.0.0")] pub struct StableTupleStruct(isize); - #[frozen] - pub struct FrozenTupleStruct(isize); - #[locked] - pub struct LockedTupleStruct(isize); fn test() { // Only the deprecated cases of the following should generate @@ -361,14 +291,6 @@ mod this_crate { foo.method_deprecated_text(); //~ ERROR use of deprecated item: text foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text - experimental(); - foo.method_experimental(); - foo.trait_experimental(); - - experimental_text(); - foo.method_experimental_text(); - foo.trait_experimental_text(); - unstable(); foo.method_unstable(); foo.trait_unstable(); @@ -389,60 +311,30 @@ mod this_crate { foo.method_stable_text(); foo.trait_stable_text(); - frozen(); - foo.method_frozen(); - foo.trait_frozen(); - - frozen_text(); - foo.method_frozen_text(); - foo.trait_frozen_text(); - - locked(); - foo.method_locked(); - foo.trait_locked(); - - locked_text(); - foo.method_locked_text(); - foo.trait_locked_text(); - let _ = DeprecatedStruct { i: 0 }; //~ ERROR use of deprecated item - let _ = ExperimentalStruct { i: 0 }; let _ = UnstableStruct { i: 0 }; let _ = UnmarkedStruct { i: 0 }; let _ = StableStruct { i: 0 }; - let _ = FrozenStruct { i: 0 }; - let _ = LockedStruct { i: 0 }; let _ = DeprecatedUnitStruct; //~ ERROR use of deprecated item - let _ = ExperimentalUnitStruct; let _ = UnstableUnitStruct; let _ = UnmarkedUnitStruct; let _ = StableUnitStruct; - let _ = FrozenUnitStruct; - let _ = LockedUnitStruct; let _ = Enum::DeprecatedVariant; //~ ERROR use of deprecated item - let _ = Enum::ExperimentalVariant; let _ = Enum::UnstableVariant; let _ = Enum::UnmarkedVariant; let _ = Enum::StableVariant; - let _ = Enum::FrozenVariant; - let _ = Enum::LockedVariant; let _ = DeprecatedTupleStruct (1); //~ ERROR use of deprecated item - let _ = ExperimentalTupleStruct (1); let _ = UnstableTupleStruct (1); let _ = UnmarkedTupleStruct (1); let _ = StableTupleStruct (1); - let _ = FrozenTupleStruct (1); - let _ = LockedTupleStruct (1); } fn test_method_param<F: Trait>(foo: F) { foo.trait_deprecated(); //~ ERROR use of deprecated item foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text - foo.trait_experimental(); - foo.trait_experimental_text(); foo.trait_unstable(); foo.trait_unstable_text(); foo.trait_unmarked(); @@ -452,29 +344,30 @@ mod this_crate { fn test_method_object(foo: &Trait) { foo.trait_deprecated(); //~ ERROR use of deprecated item foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text - foo.trait_experimental(); - foo.trait_experimental_text(); foo.trait_unstable(); foo.trait_unstable_text(); foo.trait_unmarked(); foo.trait_stable(); } - #[deprecated] + #[unstable(feature = "test_feature")] + #[deprecated(since = "1.0.0")] fn test_fn_body() { fn fn_in_body() {} fn_in_body(); } impl MethodTester { - #[deprecated] + #[unstable(feature = "test_feature")] + #[deprecated(since = "1.0.0")] fn test_method_body(&self) { fn fn_in_body() {} fn_in_body(); } } - #[deprecated] + #[unstable(feature = "test_feature")] + #[deprecated(since = "1.0.0")] pub trait DeprecatedTrait {} struct S; diff --git a/src/test/compile-fail/lint-unknown-feature-default.rs b/src/test/compile-fail/lint-unknown-feature-default.rs new file mode 100644 index 00000000000..d5e9cc630c3 --- /dev/null +++ b/src/test/compile-fail/lint-unknown-feature-default.rs @@ -0,0 +1,15 @@ +// 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. + +// Tests the default for the unused_features lint + +#![feature(this_is_not_a_feature)] //~ ERROR: unused or unknown feature + +fn main() { } diff --git a/src/test/compile-fail/lint-unknown-feature.rs b/src/test/compile-fail/lint-unknown-feature.rs index 6252e01749b..ac1720b339e 100644 --- a/src/test/compile-fail/lint-unknown-feature.rs +++ b/src/test/compile-fail/lint-unknown-feature.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![deny(unknown_features)] +#![deny(unused_features)] -#![feature(this_is_not_a_feature)] //~ ERROR: unknown feature +#![feature(this_is_not_a_feature)] //~ ERROR: unused or unknown feature fn main() {} diff --git a/src/test/compile-fail/lint-unused-extern-crate.rs b/src/test/compile-fail/lint-unused-extern-crate.rs index ae156356b79..03bb7cc1f15 100644 --- a/src/test/compile-fail/lint-unused-extern-crate.rs +++ b/src/test/compile-fail/lint-unused-extern-crate.rs @@ -12,7 +12,9 @@ #![deny(unused_extern_crates)] #![allow(unused_variables)] -#![allow(unstable)] +#![feature(libc)] +#![feature(collections)] +#![feature(rand)] extern crate libc; //~ ERROR: unused extern crate diff --git a/src/test/compile-fail/lint-uppercase-variables.rs b/src/test/compile-fail/lint-uppercase-variables.rs index 6f1e997e7bf..057b8e3acc6 100644 --- a/src/test/compile-fail/lint-uppercase-variables.rs +++ b/src/test/compile-fail/lint-uppercase-variables.rs @@ -11,8 +11,9 @@ // ignore-tidy-linelength #![allow(dead_code)] -#![allow(unstable)] #![deny(non_snake_case)] +#![feature(path)] +#![feature(io)] use std::old_io::File; use std::old_io::IoError; diff --git a/src/test/compile-fail/liveness-unused.rs b/src/test/compile-fail/liveness-unused.rs index f27ee376f52..4a3f7e9cad9 100644 --- a/src/test/compile-fail/liveness-unused.rs +++ b/src/test/compile-fail/liveness-unused.rs @@ -10,8 +10,9 @@ #![deny(unused_variables)] #![deny(unused_assignments)] -#![allow(unstable)] #![allow(dead_code, non_camel_case_types)] +#![feature(core)] +#![feature(os)] fn f1(x: isize) { //~^ ERROR unused variable: `x` diff --git a/src/test/compile-fail/missing_debug_impls.rs b/src/test/compile-fail/missing_debug_impls.rs index 4adae2f3680..5b781a40fe5 100644 --- a/src/test/compile-fail/missing_debug_impls.rs +++ b/src/test/compile-fail/missing_debug_impls.rs @@ -10,7 +10,8 @@ // compile-flags: --crate-type lib #![deny(missing_debug_implementations)] -#![allow(unused, unstable, missing_copy_implementations)] +#![allow(unused, missing_copy_implementations)] +#![feature(core)] use std::fmt; diff --git a/src/test/compile-fail/overloaded-calls-bad.rs b/src/test/compile-fail/overloaded-calls-bad.rs index d784ba2d0d6..61752e62abd 100644 --- a/src/test/compile-fail/overloaded-calls-bad.rs +++ b/src/test/compile-fail/overloaded-calls-bad.rs @@ -17,7 +17,9 @@ struct S { y: isize, } -impl FnMut<(isize,),isize> for S { +impl FnMut<(isize,)> for S { + type Output = isize; + extern "rust-call" fn call_mut(&mut self, (z,): (isize,)) -> isize { self.x * self.y * z } diff --git a/src/test/compile-fail/overloaded-calls-nontuple.rs b/src/test/compile-fail/overloaded-calls-nontuple.rs index c06ab04cd84..41ecf714613 100644 --- a/src/test/compile-fail/overloaded-calls-nontuple.rs +++ b/src/test/compile-fail/overloaded-calls-nontuple.rs @@ -17,7 +17,8 @@ struct S { y: isize, } -impl FnMut<isize,isize> for S { +impl FnMut<isize> for S { + type Output = isize; extern "rust-call" fn call_mut(&mut self, z: isize) -> isize { self.x + self.y + z } diff --git a/src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs b/src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs index 2e634dfe3eb..2a246124f6f 100644 --- a/src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs +++ b/src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs @@ -9,15 +9,15 @@ // except according to those terms. -struct invariant<'a> { +struct Invariant<'a> { f: Box<for<'b> FnOnce() -> &'b mut &'a isize + 'static>, } -fn to_same_lifetime<'r>(bi: invariant<'r>) { - let bj: invariant<'r> = bi; +fn to_same_lifetime<'r>(bi: Invariant<'r>) { + let bj: Invariant<'r> = bi; } -fn to_longer_lifetime<'r>(bi: invariant<'r>) -> invariant<'static> { +fn to_longer_lifetime<'r>(bi: Invariant<'r>) -> Invariant<'static> { bi //~ ERROR mismatched types } diff --git a/src/test/compile-fail/shift-various-bad-types.rs b/src/test/compile-fail/shift-various-bad-types.rs index 66aef0ec3a1..901ae1d5e2a 100644 --- a/src/test/compile-fail/shift-various-bad-types.rs +++ b/src/test/compile-fail/shift-various-bad-types.rs @@ -29,7 +29,7 @@ fn foo(p: &Panolpy) { // known to be an integer, but meh. let x; 22 >> x; - //~^ ERROR right-hand-side of a shift operation must have integral type + //~^ ERROR the type of this value must be known in this context 22 >> 1; // Integer literal types are OK diff --git a/src/test/compile-fail/simd-binop.rs b/src/test/compile-fail/simd-binop.rs index 0c2d8972ce7..f028c9af462 100644 --- a/src/test/compile-fail/simd-binop.rs +++ b/src/test/compile-fail/simd-binop.rs @@ -10,7 +10,6 @@ // ignore-tidy-linelength -#![allow(unstable)] use std::simd::f32x4; diff --git a/src/test/compile-fail/slice-mut.rs b/src/test/compile-fail/slice-mut.rs index a1747f3b6bd..e6acc325451 100644 --- a/src/test/compile-fail/slice-mut.rs +++ b/src/test/compile-fail/slice-mut.rs @@ -13,9 +13,10 @@ fn main() { let x: &[isize] = &[1, 2, 3, 4, 5]; // Immutable slices are not mutable. + let y: &mut[_] = &x[2..4]; //~^ ERROR mismatched types //~| expected `&mut [_]` - //~| found `&_` + //~| found `&[isize]` //~| values differ in mutability } diff --git a/src/test/compile-fail/stability-attribute-sanity.rs b/src/test/compile-fail/stability-attribute-sanity.rs new file mode 100644 index 00000000000..dcbb1880b10 --- /dev/null +++ b/src/test/compile-fail/stability-attribute-sanity.rs @@ -0,0 +1,95 @@ +// 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. + +// Various checks that stability attributes are used correctly, per RFC 507 + +#![feature(staged_api)] +#![staged_api] + +mod bogus_attribute_types_1 { + #[stable(feature = "a", since = "a", reason)] //~ ERROR incorrect meta item + fn f1() { } + + #[stable(feature = "a", since, reason = "a")] //~ ERROR incorrect meta item + fn f2() { } + + #[stable(feature, since = "a", reason = "a")] //~ ERROR incorrect meta item + fn f3() { } + + #[stable(feature = "a", since = "a", reason(b))] //~ ERROR incorrect meta item + fn f4() { } + + #[stable(feature = "a", since(b), reason = "a")] //~ ERROR incorrect meta item + fn f5() { } + + #[stable(feature(b), since = "a", reason = "a")] //~ ERROR incorrect meta item + fn f6() { } +} + +mod bogus_attribute_types_2 { + #[unstable] //~ ERROR incorrect stability attribute type + fn f1() { } + + #[unstable = "a"] //~ ERROR incorrect stability attribute type + fn f2() { } + + #[stable] //~ ERROR incorrect stability attribute type + fn f3() { } + + #[stable = "a"] //~ ERROR incorrect stability attribute type + fn f4() { } + + #[stable(feature = "a", since = "b")] + #[deprecated] //~ ERROR incorrect stability attribute type + fn f5() { } + + #[stable(feature = "a", since = "b")] + #[deprecated = "a"] //~ ERROR incorrect stability attribute type + fn f6() { } +} + +mod missing_feature_names { + #[unstable(since = "a")] //~ ERROR missing 'feature' + fn f1() { } + + #[stable(since = "a")] //~ ERROR missing 'feature' + fn f2() { } +} + +mod missing_version { + #[stable(feature = "a")] //~ ERROR missing 'since' + fn f1() { } + + #[stable(feature = "a", since = "b")] + #[deprecated(reason = "a")] //~ ERROR missing 'since' + fn f2() { } +} + +#[unstable(feature = "a", since = "b")] +#[stable(feature = "a", since = "b")] +fn multiple1() { } //~ ERROR multiple stability levels + +#[unstable(feature = "a", since = "b")] +#[unstable(feature = "a", since = "b")] +fn multiple2() { } //~ ERROR multiple stability levels + +#[stable(feature = "a", since = "b")] +#[stable(feature = "a", since = "b")] +fn multiple3() { } //~ ERROR multiple stability levels + +#[stable(feature = "a", since = "b")] +#[deprecated(since = "b")] +#[deprecated(since = "b")] +fn multiple4() { } //~ ERROR multiple deprecated attributes + +#[deprecated(since = "a")] +fn deprecated_without_unstable_or_stable() { } //~ ERROR deprecated attribute must be paired + +fn main() { } diff --git a/src/test/compile-fail/simd-experimental.rs b/src/test/compile-fail/staged_api.rs index aea970f90b2..53d687b5cfe 100644 --- a/src/test/compile-fail/simd-experimental.rs +++ b/src/test/compile-fail/staged_api.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,10 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![deny(unstable)] +#![staged_api] //~ ERROR staged_api is for use by rustc only -use std::simd; - -fn main() { - let _ = simd::i64x2(0, 0); //~ ERROR: experimental -} +fn main() { } diff --git a/src/test/compile-fail/traits-multidispatch-bad.rs b/src/test/compile-fail/traits-multidispatch-bad.rs index e9a4005b4b4..2e29a61846e 100644 --- a/src/test/compile-fail/traits-multidispatch-bad.rs +++ b/src/test/compile-fail/traits-multidispatch-bad.rs @@ -26,7 +26,7 @@ where T : Convert<U> } fn a() { - test(22is, 44is); //~ ERROR not implemented + test(22is, 44is); //~ ERROR mismatched types } fn main() {} diff --git a/src/test/compile-fail/unboxed-closure-feature-gate.rs b/src/test/compile-fail/unboxed-closure-feature-gate.rs index 5eb67a9bb71..3536244f011 100644 --- a/src/test/compile-fail/unboxed-closure-feature-gate.rs +++ b/src/test/compile-fail/unboxed-closure-feature-gate.rs @@ -11,7 +11,8 @@ // Check that parenthetical notation is feature-gated except with the // `Fn` traits. -trait Foo<A,R> { +trait Foo<A> { + type Output; } 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 0d9e406b086..870377bc1ad 100644 --- a/src/test/compile-fail/unboxed-closure-sugar-default.rs +++ b/src/test/compile-fail/unboxed-closure-sugar-default.rs @@ -14,8 +14,9 @@ #![feature(unboxed_closures)] #![allow(dead_code)] -trait Foo<T,U,V=T> { - fn dummy(&self, t: T, u: U, v: V); +trait Foo<T,V=T> { + type Output; + fn dummy(&self, t: T, v: V); } trait Eq<X: ?Sized> { } @@ -24,14 +25,14 @@ fn eq<A: ?Sized,B: ?Sized>() where A : Eq<B> { } fn test<'a,'b>() { // Parens are equivalent to omitting default in angle. - eq::< Foo<(isize,),()>, Foo(isize) >(); + eq::< Foo<(isize,),Output=()>, Foo(isize) >(); // In angle version, we supply something other than the default - eq::< Foo<(isize,),(),isize>, Foo(isize) >(); + eq::< Foo<(isize,),isize,Output=()>, Foo(isize) >(); //~^ ERROR not implemented // Supply default explicitly. - eq::< Foo<(isize,),(),(isize,)>, Foo(isize) >(); + eq::< Foo<(isize,),(isize,),Output=()>, Foo(isize) >(); } fn main() { } diff --git a/src/test/compile-fail/unboxed-closure-sugar-equiv.rs b/src/test/compile-fail/unboxed-closure-sugar-equiv.rs index 9dff0e9e01e..dc5576aee65 100644 --- a/src/test/compile-fail/unboxed-closure-sugar-equiv.rs +++ b/src/test/compile-fail/unboxed-closure-sugar-equiv.rs @@ -16,8 +16,9 @@ #![feature(unboxed_closures)] #![allow(dead_code)] -trait Foo<T,U> { - fn dummy(&self, t: T, u: U); +trait Foo<T> { + type Output; + fn dummy(&self, t: T, u: Self::Output); } trait Eq<X: ?Sized> { } @@ -26,31 +27,32 @@ fn eq<A: ?Sized,B: ?Sized +Eq<A>>() { } fn test<'a,'b>() { // No errors expected: - eq::< Foo<(),()>, Foo() >(); - eq::< Foo<(isize,),()>, Foo(isize) >(); - eq::< Foo<(isize,usize),()>, Foo(isize,usize) >(); - eq::< Foo<(isize,usize),usize>, Foo(isize,usize) -> usize >(); - eq::< Foo<(&'a isize,&'b usize),usize>, Foo(&'a isize,&'b usize) -> usize >(); + eq::< Foo<(),Output=()>, Foo() >(); + eq::< Foo<(isize,),Output=()>, Foo(isize) >(); + eq::< Foo<(isize,usize),Output=()>, Foo(isize,usize) >(); + eq::< Foo<(isize,usize),Output=usize>, Foo(isize,usize) -> usize >(); + eq::< Foo<(&'a isize,&'b usize),Output=usize>, Foo(&'a isize,&'b usize) -> usize >(); // Test that anonymous regions in `()` form are equivalent // to fresh bound regions, and that we can intermingle // named and anonymous as we choose: - eq::< for<'x,'y> Foo<(&'x isize,&'y usize),usize>, + eq::< for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>, for<'x,'y> Foo(&'x isize,&'y usize) -> usize >(); - eq::< for<'x,'y> Foo<(&'x isize,&'y usize),usize>, + eq::< for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>, for<'x> Foo(&'x isize,&usize) -> usize >(); - eq::< for<'x,'y> Foo<(&'x isize,&'y usize),usize>, + eq::< for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>, for<'y> Foo(&isize,&'y usize) -> usize >(); - eq::< for<'x,'y> Foo<(&'x isize,&'y usize),usize>, + eq::< for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>, Foo(&isize,&usize) -> usize >(); // lifetime elision - eq::< for<'x> Foo<(&'x isize,), &'x isize>, + eq::< for<'x> Foo<(&'x isize,), Output=&'x isize>, Foo(&isize) -> &isize >(); // Errors expected: - eq::< Foo<(),()>, Foo(char) >(); - //~^ ERROR not implemented + eq::< Foo<(),Output=()>, + Foo(char) >(); + //~^^ ERROR not implemented } fn main() { } 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 29429c708d2..d2f781bba11 100644 --- a/src/test/compile-fail/unboxed-closure-sugar-lifetime-elision.rs +++ b/src/test/compile-fail/unboxed-closure-sugar-lifetime-elision.rs @@ -16,8 +16,9 @@ #![feature(unboxed_closures)] #![allow(dead_code)] -trait Foo<T,U> { - fn dummy(&self, t: T, u: U); +trait Foo<T> { + type Output; + fn dummy(&self, t: T); } trait Eq<X: ?Sized> { } @@ -25,9 +26,9 @@ impl<X: ?Sized> Eq<X> for X { } fn eq<A: ?Sized,B: ?Sized +Eq<A>>() { } fn main() { - eq::< for<'a> Foo<(&'a isize,), &'a isize>, + eq::< for<'a> Foo<(&'a isize,), Output=&'a isize>, Foo(&isize) -> &isize >(); - eq::< for<'a> Foo<(&'a isize,), (&'a isize, &'a isize)>, + eq::< for<'a> Foo<(&'a isize,), Output=(&'a isize, &'a isize)>, Foo(&isize) -> (&isize, &isize) >(); let _: Foo(&isize, &usize) -> &usize; //~ ERROR missing lifetime specifier diff --git a/src/test/compile-fail/unboxed-closure-sugar-not-used-on-fn.rs b/src/test/compile-fail/unboxed-closure-sugar-not-used-on-fn.rs index 21844e5b986..1f0d5aae36d 100644 --- a/src/test/compile-fail/unboxed-closure-sugar-not-used-on-fn.rs +++ b/src/test/compile-fail/unboxed-closure-sugar-not-used-on-fn.rs @@ -11,11 +11,11 @@ // Test that the `Fn` traits require `()` form without a feature gate. -fn bar1(x: &Fn<(),()>) { +fn bar1(x: &Fn<()>) { //~^ ERROR angle-bracket notation is not stable when used with the `Fn` family } -fn bar2<T>(x: &T) where T: Fn<(),()> { +fn bar2<T>(x: &T) where T: Fn<()> { //~^ ERROR angle-bracket notation is not stable when used with the `Fn` family } diff --git a/src/test/compile-fail/unboxed-closure-sugar-region.rs b/src/test/compile-fail/unboxed-closure-sugar-region.rs index c8dd33c11fd..75688e44e80 100644 --- a/src/test/compile-fail/unboxed-closure-sugar-region.rs +++ b/src/test/compile-fail/unboxed-closure-sugar-region.rs @@ -17,8 +17,9 @@ use std::marker; -trait Foo<'a,T,U> { - fn dummy(&'a self) -> &'a (T,U); +trait Foo<'a,T> { + type Output; + fn dummy(&'a self) -> &'a (T,Self::Output); } trait Eq<X: ?Sized> { } @@ -29,16 +30,17 @@ fn same_type<A,B:Eq<A>>(a: A, b: B) { } fn test<'a,'b>() { // Parens are equivalent to omitting default in angle. - eq::< Foo<(isize,),()>, Foo(isize) >(); + eq::< Foo<(isize,),Output=()>, Foo(isize) >(); // Here we specify 'static explicitly in angle-bracket version. // Parenthesized winds up getting inferred. - eq::< Foo<'static, (isize,),()>, Foo(isize) >(); + eq::< Foo<'static, (isize,),Output=()>, Foo(isize) >(); } -fn test2(x: &Foo<(isize,),()>, y: &Foo(isize)) { +fn test2(x: &Foo<(isize,),Output=()>, y: &Foo(isize)) { // Here, the omitted lifetimes are expanded to distinct things. same_type(x, y) //~ ERROR cannot infer + //~^ ERROR cannot infer } fn main() { } diff --git a/src/test/compile-fail/unboxed-closure-sugar-used-on-struct-1.rs b/src/test/compile-fail/unboxed-closure-sugar-used-on-struct-1.rs index a6184caf68b..a3991a87b78 100644 --- a/src/test/compile-fail/unboxed-closure-sugar-used-on-struct-1.rs +++ b/src/test/compile-fail/unboxed-closure-sugar-used-on-struct-1.rs @@ -11,13 +11,14 @@ // Test that parentheses form doesn't work with struct types appearing in local variables. -struct Bar<A,R> { - f: A, r: R +struct Bar<A> { + f: A } fn bar() { let x: Box<Bar()> = panic!(); //~^ ERROR parenthesized parameters may only be used with a trait + //~^^ ERROR associated type bindings are not allowed here } fn main() { } diff --git a/src/test/compile-fail/unboxed-closure-sugar-used-on-struct.rs b/src/test/compile-fail/unboxed-closure-sugar-used-on-struct.rs index d5fb505715e..ad85cdcaa03 100644 --- a/src/test/compile-fail/unboxed-closure-sugar-used-on-struct.rs +++ b/src/test/compile-fail/unboxed-closure-sugar-used-on-struct.rs @@ -10,12 +10,13 @@ // Test that parentheses form doesn't work with struct types appearing in argument types. -struct Bar<A,R> { - f: A, r: R +struct Bar<A> { + f: A } fn foo(b: Box<Bar()>) { //~^ ERROR parenthesized parameters may only be used with a trait + //~^^ ERROR associated type bindings are not allowed here } fn main() { } diff --git a/src/test/compile-fail/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs b/src/test/compile-fail/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs index d9efab974d8..c9837da58e7 100644 --- a/src/test/compile-fail/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs +++ b/src/test/compile-fail/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs @@ -12,7 +12,7 @@ trait One<A> { fn foo(&self) -> A; } -fn foo(_: &One()) //~ ERROR wrong number of type arguments +fn foo(_: &One()) //~ ERROR no associated type `Output` defined in `One<()>` {} fn main() { } diff --git a/src/test/compile-fail/unboxed-closure-sugar-wrong-trait.rs b/src/test/compile-fail/unboxed-closure-sugar-wrong-trait.rs index b58e08355c1..e63f510b890 100644 --- a/src/test/compile-fail/unboxed-closure-sugar-wrong-trait.rs +++ b/src/test/compile-fail/unboxed-closure-sugar-wrong-trait.rs @@ -13,7 +13,7 @@ trait Trait {} fn f<F:Trait(isize) -> isize>(x: F) {} -//~^ ERROR wrong number of type arguments: expected 0, found 2 +//~^ ERROR wrong number of type arguments: expected 0, found 1 fn main() {} diff --git a/src/test/compile-fail/unboxed-closures-fnmut-as-fn.rs b/src/test/compile-fail/unboxed-closures-fnmut-as-fn.rs index fc87ec9f959..bbafd5109ed 100644 --- a/src/test/compile-fail/unboxed-closures-fnmut-as-fn.rs +++ b/src/test/compile-fail/unboxed-closures-fnmut-as-fn.rs @@ -18,7 +18,9 @@ use std::ops::{Fn,FnMut,FnOnce}; struct S; -impl FnMut<(isize,),isize> for S { +impl FnMut<(isize,)> for S { + type Output = isize; + extern "rust-call" fn call_mut(&mut self, (x,): (isize,)) -> isize { x * x } @@ -29,6 +31,8 @@ fn call_it<F:Fn(isize)->isize>(f: &F, x: isize) -> isize { } fn main() { - let x = call_it(&S, 22); //~ ERROR not implemented + let x = call_it(&S, 22); + //~^ ERROR not implemented + //~| ERROR not implemented } diff --git a/src/test/compile-fail/unboxed-closures-unsafe-extern-fn.rs b/src/test/compile-fail/unboxed-closures-unsafe-extern-fn.rs index ab909717cab..23f7ee2b010 100644 --- a/src/test/compile-fail/unboxed-closures-unsafe-extern-fn.rs +++ b/src/test/compile-fail/unboxed-closures-unsafe-extern-fn.rs @@ -21,7 +21,9 @@ fn call_it_mut<F:FnMut(&isize)->isize>(_: &mut F, _: isize) -> isize { 0 } fn call_it_once<F:FnOnce(&isize)->isize>(_: F, _: isize) -> isize { 0 } fn a() { - let x = call_it(&square, 22); //~ ERROR not implemented + let x = call_it(&square, 22); + //~^ ERROR not implemented + //~| ERROR not implemented } fn b() { diff --git a/src/test/compile-fail/unboxed-closures-vtable-mismatch.rs b/src/test/compile-fail/unboxed-closures-vtable-mismatch.rs index 95673a51319..305dd33e5a0 100644 --- a/src/test/compile-fail/unboxed-closures-vtable-mismatch.rs +++ b/src/test/compile-fail/unboxed-closures-vtable-mismatch.rs @@ -12,13 +12,15 @@ use std::ops::FnMut; -fn call_it<F:FnMut<(isize,isize),isize>>(y: isize, mut f: F) -> isize { +fn call_it<F:FnMut(isize,isize)->isize>(y: isize, mut f: F) -> isize { f(2, y) } pub fn main() { let f = |&mut: x: usize, y: isize| -> isize { (x as isize) + y }; - let z = call_it(3, f); //~ ERROR type mismatch + let z = call_it(3, f); + //~^ ERROR type mismatch + //~| ERROR type mismatch println!("{}", z); } diff --git a/src/test/compile-fail/unboxed-closures-wrong-abi.rs b/src/test/compile-fail/unboxed-closures-wrong-abi.rs index 4a0b55558c0..96619bef36f 100644 --- a/src/test/compile-fail/unboxed-closures-wrong-abi.rs +++ b/src/test/compile-fail/unboxed-closures-wrong-abi.rs @@ -21,7 +21,9 @@ fn call_it_mut<F:FnMut(&isize)->isize>(_: &mut F, _: isize) -> isize { 0 } fn call_it_once<F:FnOnce(&isize)->isize>(_: F, _: isize) -> isize { 0 } fn a() { - let x = call_it(&square, 22); //~ ERROR not implemented + let x = call_it(&square, 22); + //~^ ERROR not implemented + //~| ERROR not implemented } fn b() { diff --git a/src/test/compile-fail/unboxed-closures-wrong-arg-type-extern-fn.rs b/src/test/compile-fail/unboxed-closures-wrong-arg-type-extern-fn.rs index b2fdf792630..ebcbdbbc006 100644 --- a/src/test/compile-fail/unboxed-closures-wrong-arg-type-extern-fn.rs +++ b/src/test/compile-fail/unboxed-closures-wrong-arg-type-extern-fn.rs @@ -22,7 +22,9 @@ fn call_it_mut<F:FnMut(&isize)->isize>(_: &mut F, _: isize) -> isize { 0 } fn call_it_once<F:FnOnce(&isize)->isize>(_: F, _: isize) -> isize { 0 } fn a() { - let x = call_it(&square, 22); //~ ERROR not implemented + let x = call_it(&square, 22); + //~^ ERROR not implemented + //~| ERROR not implemented } fn b() { diff --git a/src/test/compile-fail/unboxed-closures-wrong-trait.rs b/src/test/compile-fail/unboxed-closures-wrong-trait.rs index e4255d0024f..2ada0dd22e7 100644 --- a/src/test/compile-fail/unboxed-closures-wrong-trait.rs +++ b/src/test/compile-fail/unboxed-closures-wrong-trait.rs @@ -18,5 +18,6 @@ fn main() { let z: isize = 7; assert_eq!(c(|&mut: x: isize, y| x + y + z), 10); //~^ ERROR not implemented + //~| ERROR not implemented } diff --git a/src/test/compile-fail/unused-attr.rs b/src/test/compile-fail/unused-attr.rs index b04f2edd142..50217ff9e5d 100644 --- a/src/test/compile-fail/unused-attr.rs +++ b/src/test/compile-fail/unused-attr.rs @@ -9,7 +9,7 @@ // except according to those terms. #![deny(unused_attributes)] #![allow(dead_code, unused_imports)] -#![allow(unstable)] +#![feature(core)] #![foo] //~ ERROR unused attribute diff --git a/src/test/compile-fail/variance-object-types.rs b/src/test/compile-fail/variance-object-types.rs new file mode 100644 index 00000000000..972ec96f5f2 --- /dev/null +++ b/src/test/compile-fail/variance-object-types.rs @@ -0,0 +1,24 @@ +// 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 Cell is considered invariant with respect to its +// type. + +use std::cell::Cell; + +// For better or worse, associated types are invariant, and hence we +// get an invariant result for `'a`. +#[rustc_variance] +struct Foo<'a> { //~ ERROR regions=[[o];[];[]] + x: Box<Fn(i32) -> &'a i32 + 'static> +} + +fn main() { +} diff --git a/src/test/debuginfo/simd.rs b/src/test/debuginfo/simd.rs index 4aaa3e0b75f..578ea4479ec 100644 --- a/src/test/debuginfo/simd.rs +++ b/src/test/debuginfo/simd.rs @@ -41,7 +41,6 @@ // gdb-command:continue -#![allow(unstable)] #![allow(unused_variables)] #![omit_gdb_pretty_printer_section] diff --git a/src/test/run-make/allow-non-lint-warnings-cmdline/1 b/src/test/run-make/allow-non-lint-warnings-cmdline/1 new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/src/test/run-make/allow-non-lint-warnings-cmdline/1 diff --git a/src/test/run-make/allow-non-lint-warnings-cmdline/Makefile b/src/test/run-make/allow-non-lint-warnings-cmdline/Makefile new file mode 100644 index 00000000000..961342591aa --- /dev/null +++ b/src/test/run-make/allow-non-lint-warnings-cmdline/Makefile @@ -0,0 +1,12 @@ +-include ../tools.mk + +# Test that -A warnings makes the 'empty trait list for derive' warning go away +OUT=$(shell $(RUSTC) foo.rs -A warnings 2>&1 | grep "warning" ) + +all: foo + test -z '$(OUT)' + +# This is just to make sure the above command actually succeeds +foo: + $(RUSTC) foo.rs -A warnings + diff --git a/src/test/run-make/allow-non-lint-warnings-cmdline/foo.rs b/src/test/run-make/allow-non-lint-warnings-cmdline/foo.rs new file mode 100644 index 00000000000..19ce5d0a7ca --- /dev/null +++ b/src/test/run-make/allow-non-lint-warnings-cmdline/foo.rs @@ -0,0 +1,15 @@ +// 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. + +#[derive()] +#[derive(Copy)] +pub struct Foo; + +pub fn main() { } diff --git a/src/test/run-make/allow-warnings-cmdline-stability/1 b/src/test/run-make/allow-warnings-cmdline-stability/1 new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/src/test/run-make/allow-warnings-cmdline-stability/1 diff --git a/src/test/run-make/allow-warnings-cmdline-stability/Makefile b/src/test/run-make/allow-warnings-cmdline-stability/Makefile new file mode 100644 index 00000000000..64b7f58caea --- /dev/null +++ b/src/test/run-make/allow-warnings-cmdline-stability/Makefile @@ -0,0 +1,19 @@ +-include ../tools.mk + +# Test that -A warnings makes the 'empty trait list for derive' warning go away +DEP=$(shell $(RUSTC) bar.rs) +OUT=$(shell $(RUSTC) foo.rs -A warnings 2>&1 | grep "warning" ) + +all: foo bar + test -z '$(OUT)' + +# These are just to ensure that the above commands actually work +bar: + $(RUSTC) bar.rs + +foo: bar + $(RUSTC) foo.rs -A warnings + + + + diff --git a/src/test/run-make/allow-warnings-cmdline-stability/bar.rs b/src/test/run-make/allow-warnings-cmdline-stability/bar.rs new file mode 100644 index 00000000000..6a683d96b03 --- /dev/null +++ b/src/test/run-make/allow-warnings-cmdline-stability/bar.rs @@ -0,0 +1,16 @@ +// 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. + +#![crate_type = "lib"] +#![feature(staged_api)] +#![staged_api] +#![unstable(feature = "test_feature")] + +pub fn baz() { } diff --git a/src/test/run-make/allow-warnings-cmdline-stability/foo.rs b/src/test/run-make/allow-warnings-cmdline-stability/foo.rs new file mode 100644 index 00000000000..fb23a214016 --- /dev/null +++ b/src/test/run-make/allow-warnings-cmdline-stability/foo.rs @@ -0,0 +1,13 @@ +// 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. + +extern crate bar; + +pub fn main() { bar::baz() } diff --git a/src/test/run-pass/associated-types-issue-21212.rs b/src/test/run-pass/associated-types-issue-21212.rs new file mode 100644 index 00000000000..ced44250e4d --- /dev/null +++ b/src/test/run-pass/associated-types-issue-21212.rs @@ -0,0 +1,28 @@ +// 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 #21212: an overflow occurred during trait +// checking where normalizing `Self::Input` led to normalizing the +// where clauses in the environment which in turn required normalizing +// `Self::Input`. + +pub trait Parser { + type Input; + + fn parse(input: <Self as Parser>::Input) { + panic!() + } +} +impl <P> Parser for P { + type Input = (); +} + +fn main() { +} diff --git a/src/test/run-pass/associated-types-normalize-in-bounds-binding.rs b/src/test/run-pass/associated-types-normalize-in-bounds-binding.rs new file mode 100644 index 00000000000..dd5814f875b --- /dev/null +++ b/src/test/run-pass/associated-types-normalize-in-bounds-binding.rs @@ -0,0 +1,42 @@ +// 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 we normalize associated types that appear in a bound that +// contains a binding. Issue #21664. + +#![allow(dead_code)] + +pub trait Integral { + type Opposite; +} + +impl Integral for i32 { + type Opposite = u32; +} + +impl Integral for u32 { + type Opposite = i32; +} + +pub trait FnLike<A> { + type R; +} + +fn foo<T>() + where T : FnLike<<i32 as Integral>::Opposite, R=bool> +{ + bar::<T>(); +} + +fn bar<T>() + where T : FnLike<u32, R=bool> +{} + +fn main() { } diff --git a/src/test/run-pass/associated-types-normalize-unifield-struct.rs b/src/test/run-pass/associated-types-normalize-unifield-struct.rs index c517f61de0c..5aafe93067c 100644 --- a/src/test/run-pass/associated-types-normalize-unifield-struct.rs +++ b/src/test/run-pass/associated-types-normalize-unifield-struct.rs @@ -11,7 +11,6 @@ // Regression test for issue #21010: Normalize associated types in // various special paths in the `type_is_immediate` function. -#![allow(unstable)] pub trait OffsetState: Sized {} pub trait Offset { type State: OffsetState; } diff --git a/src/test/run-pass/bare-fn-implements-fn-mut.rs b/src/test/run-pass/bare-fn-implements-fn-mut.rs index 9d104afd646..fae83d4aa65 100644 --- a/src/test/run-pass/bare-fn-implements-fn-mut.rs +++ b/src/test/run-pass/bare-fn-implements-fn-mut.rs @@ -12,7 +12,7 @@ use std::ops::FnMut; -fn call_f<F:FnMut<(),()>>(mut f: F) { +fn call_f<F:FnMut()>(mut f: F) { f(); } @@ -20,7 +20,7 @@ fn f() { println!("hello"); } -fn call_g<G:FnMut<(String,String),String>>(mut g: G, x: String, y: String) +fn call_g<G:FnMut(String,String) -> String>(mut g: G, x: String, y: String) -> String { g(x, y) } diff --git a/src/test/run-pass/hrtb-parse.rs b/src/test/run-pass/hrtb-parse.rs index 41b7c0fae07..d5307c09103 100644 --- a/src/test/run-pass/hrtb-parse.rs +++ b/src/test/run-pass/hrtb-parse.rs @@ -22,23 +22,23 @@ trait Get<A,R> { // Parse HRTB with explicit `for` in a where-clause: fn foo00<T>(t: T) - where T : for<'a> Get<&'a int, &'a int> + where T : for<'a> Get<&'a i32, &'a i32> { } -fn foo01<T: for<'a> Get<&'a int, &'a int>>(t: T) +fn foo01<T: for<'a> Get<&'a i32, &'a i32>>(t: T) { } // Parse HRTB with explicit `for` in various sorts of types: -fn foo10(t: Box<for<'a> Get<int, int>>) { } -fn foo11(t: Box<for<'a> Get(int) -> int>) { } +fn foo10(t: Box<for<'a> Get<i32, i32>>) { } +fn foo11(t: Box<for<'a> Fn(i32) -> i32>) { } -fn foo20(t: for<'a> fn(int) -> int) { } -fn foo21(t: for<'a> unsafe fn(int) -> int) { } -fn foo22(t: for<'a> extern "C" fn(int) -> int) { } -fn foo23(t: for<'a> unsafe extern "C" fn(int) -> int) { } +fn foo20(t: for<'a> fn(i32) -> i32) { } +fn foo21(t: for<'a> unsafe fn(i32) -> i32) { } +fn foo22(t: for<'a> extern "C" fn(i32) -> i32) { } +fn foo23(t: for<'a> unsafe extern "C" fn(i32) -> i32) { } fn main() { } diff --git a/src/test/run-pass/hrtb-trait-object-paren-notation.rs b/src/test/run-pass/hrtb-trait-object-paren-notation.rs index e17e0ae2189..1b62a8e809c 100644 --- a/src/test/run-pass/hrtb-trait-object-paren-notation.rs +++ b/src/test/run-pass/hrtb-trait-object-paren-notation.rs @@ -16,7 +16,7 @@ trait FnLike<A,R> { fn call(&self, arg: A) -> R; } -type FnObject<'b> = for<'a> FnLike(&'a int) -> (&'a int) + 'b; +type FnObject<'b> = for<'a> FnLike<(&'a i32,), &'a i32> + 'b; struct Identity; diff --git a/src/test/run-pass/ifmt.rs b/src/test/run-pass/ifmt.rs index e273baef256..56de6726bfb 100644 --- a/src/test/run-pass/ifmt.rs +++ b/src/test/run-pass/ifmt.rs @@ -14,7 +14,6 @@ #![deny(warnings)] #![allow(unused_must_use)] #![allow(unknown_features)] -#![allow(unstable)] #![feature(box_syntax)] use std::fmt; diff --git a/src/test/run-pass/into-iterator-type-inference-shift.rs b/src/test/run-pass/into-iterator-type-inference-shift.rs new file mode 100644 index 00000000000..26a0abc76ae --- /dev/null +++ b/src/test/run-pass/into-iterator-type-inference-shift.rs @@ -0,0 +1,41 @@ +// 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 type inference failure around shifting. In this +// case, the iteration yields an int, but we hadn't run the full type +// propagation yet, and so we just saw a type variable, yielding an +// error. + +use std::u8; + +trait IntoIterator { + type Iter: Iterator; + + fn into_iter(self) -> Self::Iter; +} + +impl<I> IntoIterator for I where I: Iterator { + type Iter = I; + + fn into_iter(self) -> I { + self + } +} + +fn desugared_for_loop_bad(byte: u8) -> u8 { + let mut result = 0; + let mut x = IntoIterator::into_iter(range(0, u8::BITS)); + let mut y = Iterator::next(&mut x); + let mut z = y.unwrap(); + byte >> z; + 1 +} + +fn main() {} diff --git a/src/test/run-pass/issue-11958.rs b/src/test/run-pass/issue-11958.rs index f557f662e81..13177880c5a 100644 --- a/src/test/run-pass/issue-11958.rs +++ b/src/test/run-pass/issue-11958.rs @@ -12,7 +12,6 @@ // Pretty printing tests complain about `use std::predule::*` #![allow(unused_imports)] -#![allow(unstable)] // We shouldn't need to rebind a moved upvar as mut if it's already // marked as mut diff --git a/src/test/run-pass/issue-13655.rs b/src/test/run-pass/issue-13655.rs index 6fdaac99204..81a8b29461c 100644 --- a/src/test/run-pass/issue-13655.rs +++ b/src/test/run-pass/issue-13655.rs @@ -13,7 +13,8 @@ use std::ops::Fn; struct Foo<T>(T); -impl<T: Copy> Fn<(), T> for Foo<T> { +impl<T: Copy> Fn<()> for Foo<T> { + type Output = T; extern "rust-call" fn call(&self, _: ()) -> T { match *self { Foo(t) => t diff --git a/src/test/run-pass/issue-14958.rs b/src/test/run-pass/issue-14958.rs index 1ffd349a653..814a743648d 100644 --- a/src/test/run-pass/issue-14958.rs +++ b/src/test/run-pass/issue-14958.rs @@ -14,7 +14,8 @@ trait Foo {} struct Bar; -impl<'a> std::ops::Fn<(&'a (Foo+'a),), ()> for Bar { +impl<'a> std::ops::Fn<(&'a (Foo+'a),)> for Bar { + type Output = (); extern "rust-call" fn call(&self, _: (&'a Foo,)) {} } diff --git a/src/test/run-pass/issue-14959.rs b/src/test/run-pass/issue-14959.rs index 99472bb3610..33281d7d78f 100644 --- a/src/test/run-pass/issue-14959.rs +++ b/src/test/run-pass/issue-14959.rs @@ -33,7 +33,9 @@ impl Alloy { } } -impl<'a, 'b> Fn<(&'b mut (Response+'b),),()> for SendFile<'a> { +impl<'a, 'b> Fn<(&'b mut (Response+'b),)> for SendFile<'a> { + type Output = (); + extern "rust-call" fn call(&self, (_res,): (&'b mut (Response+'b),)) {} } diff --git a/src/test/run-pass/issue-16668.rs b/src/test/run-pass/issue-16668.rs index 75b1e11ddc1..e82add61aa3 100644 --- a/src/test/run-pass/issue-16668.rs +++ b/src/test/run-pass/issue-16668.rs @@ -15,7 +15,7 @@ #![feature(unboxed_closures)] struct Parser<'a, I, O> { - parse: Box<FnMut<(I,), Result<O, String>> + 'a> + parse: Box<FnMut(I) -> Result<O, String> + 'a> } impl<'a, I, O: 'a> Parser<'a, I, O> { diff --git a/src/test/run-pass/issue-16671.rs b/src/test/run-pass/issue-16671.rs index 56b2e038a7b..124b0205fae 100644 --- a/src/test/run-pass/issue-16671.rs +++ b/src/test/run-pass/issue-16671.rs @@ -14,7 +14,6 @@ // Pretty printing tests complain about `use std::predule::*` #![allow(unused_imports)] -#![allow(unstable)] // A var moved into a proc, that has a mutable loan path should // not trigger a misleading unused_mut warning. diff --git a/src/test/run-pass/issue-16739.rs b/src/test/run-pass/issue-16739.rs index cb6f068cf45..389baecafd1 100644 --- a/src/test/run-pass/issue-16739.rs +++ b/src/test/run-pass/issue-16739.rs @@ -15,27 +15,30 @@ // Test that unboxing shim for calling rust-call ABI methods through a // trait box works and does not cause an ICE. -struct Foo { foo: uint } +struct Foo { foo: u32 } -impl FnMut<(), uint> for Foo { - extern "rust-call" fn call_mut(&mut self, _: ()) -> uint { self.foo } +impl FnMut<()> for Foo { + type Output = u32; + extern "rust-call" fn call_mut(&mut self, _: ()) -> u32 { self.foo } } -impl FnMut<(uint,), uint> for Foo { - extern "rust-call" fn call_mut(&mut self, (x,): (uint,)) -> uint { self.foo + x } +impl FnMut<(u32,)> for Foo { + type Output = u32; + extern "rust-call" fn call_mut(&mut self, (x,): (u32,)) -> u32 { self.foo + x } } -impl FnMut<(uint, uint), uint> for Foo { - extern "rust-call" fn call_mut(&mut self, (x, y): (uint, uint)) -> uint { self.foo + x + y } +impl FnMut<(u32,u32)> for Foo { + type Output = u32; + extern "rust-call" fn call_mut(&mut self, (x, y): (u32, u32)) -> u32 { self.foo + x + y } } fn main() { - let mut f = box Foo { foo: 42 } as Box<FnMut<(), uint>>; + let mut f = box Foo { foo: 42 } as Box<FnMut() -> u32>; assert_eq!(f.call_mut(()), 42); - let mut f = box Foo { foo: 40 } as Box<FnMut<(uint,), uint>>; + let mut f = box Foo { foo: 40 } as Box<FnMut(u32) -> u32>; assert_eq!(f.call_mut((2,)), 42); - let mut f = box Foo { foo: 40 } as Box<FnMut<(uint, uint), uint>>; + let mut f = box Foo { foo: 40 } as Box<FnMut(u32, u32) -> u32>; assert_eq!(f.call_mut((1, 1)), 42); } diff --git a/src/test/run-pass/issue-19499.rs b/src/test/run-pass/issue-19499.rs new file mode 100644 index 00000000000..04017da9775 --- /dev/null +++ b/src/test/run-pass/issue-19499.rs @@ -0,0 +1,20 @@ +// 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 #19499. Due to incorrect caching of trait +// results for closures with upvars whose types were not fully +// computed, this rather bizarre little program (along with many more +// reasonable examples) let to ambiguity errors about not being able +// to infer sufficient type information. + +fn main() { + let n = 0; + let it = Some(1_us).into_iter().inspect(|_| {n;}); +} diff --git a/src/test/run-pass/issue-21058.rs b/src/test/run-pass/issue-21058.rs index cbce577451f..044d43a57fa 100644 --- a/src/test/run-pass/issue-21058.rs +++ b/src/test/run-pass/issue-21058.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(unstable)] struct NT(str); struct DST { a: u32, b: str } diff --git a/src/test/run-pass/issue-21245.rs b/src/test/run-pass/issue-21245.rs new file mode 100644 index 00000000000..9205b247e13 --- /dev/null +++ b/src/test/run-pass/issue-21245.rs @@ -0,0 +1,62 @@ +// 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 #21245. Check that we are able to infer +// the types in these examples correctly. It used to be that +// insufficient type propagation caused the type of the iterator to be +// incorrectly unified with the `*const` type to which it is coerced. + +use std::ptr; + +trait IntoIterator { + type Iter: Iterator; + + fn into_iter(self) -> Self::Iter; +} + +impl<I> IntoIterator for I where I: Iterator { + type Iter = I; + + fn into_iter(self) -> I { + self + } +} + +fn desugared_for_loop_bad<T>(v: Vec<T>) { + match IntoIterator::into_iter(v.iter()) { + mut iter => { + loop { + match ::std::iter::Iterator::next(&mut iter) { + ::std::option::Option::Some(x) => { + unsafe { ptr::read(x); } + }, + ::std::option::Option::None => break + } + } + } + } +} + +fn desugared_for_loop_good<T>(v: Vec<T>) { + match v.iter().into_iter() { + mut iter => { + loop { + match ::std::iter::Iterator::next(&mut iter) { + ::std::option::Option::Some(x) => { + unsafe { ptr::read(x); } + }, + ::std::option::Option::None => break + } + } + } + } +} + +fn main() {} diff --git a/src/test/run-pass/object-method-numbering.rs b/src/test/run-pass/object-method-numbering.rs new file mode 100644 index 00000000000..8da753acb96 --- /dev/null +++ b/src/test/run-pass/object-method-numbering.rs @@ -0,0 +1,36 @@ +// 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 for using an object with an associated type binding as the +// instantiation for a generic type with a bound. + +trait SomeTrait { + type SomeType; + + fn get(&self) -> Self::SomeType; +} + +fn get_int<T:SomeTrait<SomeType=i32>+?Sized>(x: &T) -> i32 { + x.get() +} + +impl SomeTrait for i32 { + type SomeType = i32; + fn get(&self) -> i32 { + *self + } +} + +fn main() { + let x = 22_i32; + let x1: &SomeTrait<SomeType=i32> = &x; + let y = get_int(x1); + assert_eq!(x, y); +} diff --git a/src/test/run-pass/overloaded-calls-param-vtables.rs b/src/test/run-pass/overloaded-calls-param-vtables.rs index 56887636d5d..2838909c1be 100644 --- a/src/test/run-pass/overloaded-calls-param-vtables.rs +++ b/src/test/run-pass/overloaded-calls-param-vtables.rs @@ -17,13 +17,15 @@ use std::ops::Add; struct G<A>; -impl<'a, A: Add<int, Output=int>> Fn<(A,), int> for G<A> { - extern "rust-call" fn call(&self, (arg,): (A,)) -> int { +impl<'a, A: Add<i32, Output=i32>> Fn<(A,)> for G<A> { + type Output = i32; + + extern "rust-call" fn call(&self, (arg,): (A,)) -> i32 { arg.add(1) } } fn main() { // ICE trigger - G(1i); + G(1_i32); } diff --git a/src/test/run-pass/overloaded-calls-simple.rs b/src/test/run-pass/overloaded-calls-simple.rs index bb5b88d3674..f9e838d9b3d 100644 --- a/src/test/run-pass/overloaded-calls-simple.rs +++ b/src/test/run-pass/overloaded-calls-simple.rs @@ -13,34 +13,37 @@ use std::ops::{Fn, FnMut, FnOnce}; struct S1 { - x: int, - y: int, + x: i32, + y: i32, } -impl FnMut<(int,),int> for S1 { - extern "rust-call" fn call_mut(&mut self, (z,): (int,)) -> int { +impl FnMut<(i32,)> for S1 { + type Output = i32; + extern "rust-call" fn call_mut(&mut self, (z,): (i32,)) -> i32 { self.x * self.y * z } } struct S2 { - x: int, - y: int, + x: i32, + y: i32, } -impl Fn<(int,),int> for S2 { - extern "rust-call" fn call(&self, (z,): (int,)) -> int { +impl Fn<(i32,)> for S2 { + type Output = i32; + extern "rust-call" fn call(&self, (z,): (i32,)) -> i32 { self.x * self.y * z } } struct S3 { - x: int, - y: int, + x: i32, + y: i32, } -impl FnOnce<(int,int),int> for S3 { - extern "rust-call" fn call_once(self, (z,zz): (int,int)) -> int { +impl FnOnce<(i32,i32)> for S3 { + type Output = i32; + extern "rust-call" fn call_once(self, (z,zz): (i32,i32)) -> i32 { self.x * self.y * z * zz } } diff --git a/src/test/run-pass/overloaded-calls-zero-args.rs b/src/test/run-pass/overloaded-calls-zero-args.rs index 809a251fe80..ce7395673b3 100644 --- a/src/test/run-pass/overloaded-calls-zero-args.rs +++ b/src/test/run-pass/overloaded-calls-zero-args.rs @@ -13,12 +13,13 @@ use std::ops::{FnMut}; struct S { - x: int, - y: int, + x: i32, + y: i32, } -impl FnMut<(),int> for S { - extern "rust-call" fn call_mut(&mut self, (): ()) -> int { +impl FnMut<()> for S { + type Output = i32; + extern "rust-call" fn call_mut(&mut self, (): ()) -> i32 { self.x * self.y } } diff --git a/src/test/run-pass/simd-binop.rs b/src/test/run-pass/simd-binop.rs index 690ad351247..482eea19823 100644 --- a/src/test/run-pass/simd-binop.rs +++ b/src/test/run-pass/simd-binop.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(unstable)] use std::simd::{i32x4, f32x4, u32x4}; diff --git a/src/test/run-pass/simd-issue-10604.rs b/src/test/run-pass/simd-issue-10604.rs index 6f0db23e2a6..7f1be4b7d70 100644 --- a/src/test/run-pass/simd-issue-10604.rs +++ b/src/test/run-pass/simd-issue-10604.rs @@ -9,7 +9,6 @@ // except according to those terms. -#![allow(unstable)] #![feature(simd)] pub fn main() { diff --git a/src/test/run-pass/tcp-connect-timeouts.rs b/src/test/run-pass/tcp-connect-timeouts.rs index 4f67baa69b2..23c5501b4a4 100644 --- a/src/test/run-pass/tcp-connect-timeouts.rs +++ b/src/test/run-pass/tcp-connect-timeouts.rs @@ -16,7 +16,6 @@ // one test task to ensure that errors are timeouts, not file descriptor // exhaustion. -#![allow(unstable)] #![reexport_test_harness_main = "test_main"] #![allow(unused_imports)] diff --git a/src/test/run-pass/unboxed-closures-boxed.rs b/src/test/run-pass/unboxed-closures-boxed.rs index dc35d5bf2ca..27528ca5d56 100644 --- a/src/test/run-pass/unboxed-closures-boxed.rs +++ b/src/test/run-pass/unboxed-closures-boxed.rs @@ -14,9 +14,9 @@ use std::ops::FnMut; - fn make_adder(x: int) -> Box<FnMut<(int,),int>+'static> { - (box move |&mut: y: int| -> int { x + y }) as - Box<FnMut<(int,),int>+'static> + fn make_adder(x: i32) -> Box<FnMut(i32)->i32+'static> { + (box move |&mut: y: i32| -> i32 { x + y }) as + Box<FnMut(i32)->i32+'static> } pub fn main() { diff --git a/src/test/run-pass/unboxed-closures-fn-as-fnmut-and-fnonce.rs b/src/test/run-pass/unboxed-closures-fn-as-fnmut-and-fnonce.rs index 8af0547e5e5..5d6029e703b 100644 --- a/src/test/run-pass/unboxed-closures-fn-as-fnmut-and-fnonce.rs +++ b/src/test/run-pass/unboxed-closures-fn-as-fnmut-and-fnonce.rs @@ -18,21 +18,22 @@ use std::ops::{Fn,FnMut,FnOnce}; struct S; -impl Fn<(int,),int> for S { - extern "rust-call" fn call(&self, (x,): (int,)) -> int { +impl Fn<(i32,)> for S { + type Output = i32; + extern "rust-call" fn call(&self, (x,): (i32,)) -> i32 { x * x } } -fn call_it<F:Fn(int)->int>(f: &F, x: int) -> int { +fn call_it<F:Fn(i32)->i32>(f: &F, x: i32) -> i32 { f(x) } -fn call_it_mut<F:FnMut(int)->int>(f: &mut F, x: int) -> int { +fn call_it_mut<F:FnMut(i32)->i32>(f: &mut F, x: i32) -> i32 { f(x) } -fn call_it_once<F:FnOnce(int)->int>(f: F, x: int) -> int { +fn call_it_once<F:FnOnce(i32)->i32>(f: F, x: i32) -> i32 { f(x) } diff --git a/src/test/run-pass/unboxed-closures-fnmut-as-fnonce.rs b/src/test/run-pass/unboxed-closures-fnmut-as-fnonce.rs index 068080e256d..95dae41c684 100644 --- a/src/test/run-pass/unboxed-closures-fnmut-as-fnonce.rs +++ b/src/test/run-pass/unboxed-closures-fnmut-as-fnonce.rs @@ -18,17 +18,19 @@ use std::ops::{FnMut,FnOnce}; struct S; -impl FnMut<(int,),int> for S { - extern "rust-call" fn call_mut(&mut self, (x,): (int,)) -> int { +impl FnMut<(i32,)> for S { + type Output = i32; + + extern "rust-call" fn call_mut(&mut self, (x,): (i32,)) -> i32 { x * x } } -fn call_it_mut<F:FnMut(int)->int>(f: &mut F, x: int) -> int { +fn call_it_mut<F:FnMut(i32)->i32>(f: &mut F, x: i32) -> i32 { f(x) } -fn call_it_once<F:FnOnce(int)->int>(f: F, x: int) -> int { +fn call_it_once<F:FnOnce(i32)->i32>(f: F, x: i32) -> i32 { f(x) } diff --git a/src/test/run-pass/unboxed-closures-generic.rs b/src/test/run-pass/unboxed-closures-generic.rs index 0edeeb8d198..04c124946c9 100644 --- a/src/test/run-pass/unboxed-closures-generic.rs +++ b/src/test/run-pass/unboxed-closures-generic.rs @@ -12,12 +12,12 @@ use std::ops::FnMut; -fn call_it<F:FnMut<(int,int),int>>(y: int, mut f: F) -> int { +fn call_it<F:FnMut(i32,i32)->i32>(y: i32, mut f: F) -> i32 { f(2, y) } pub fn main() { - let f = |&mut: x: int, y: int| -> int { x + y }; + let f = |&mut: x: i32, y: i32| -> i32 { x + y }; let z = call_it(3, f); println!("{}", z); assert_eq!(z, 5); diff --git a/src/test/run-pass/unboxed-closures-manual-impl.rs b/src/test/run-pass/unboxed-closures-manual-impl.rs index 88c9ceae4a1..37075de0405 100644 --- a/src/test/run-pass/unboxed-closures-manual-impl.rs +++ b/src/test/run-pass/unboxed-closures-manual-impl.rs @@ -15,17 +15,19 @@ use std::ops::FnMut; struct S; -impl FnMut<(int,),int> for S { - extern "rust-call" fn call_mut(&mut self, (x,): (int,)) -> int { +impl FnMut<(i32,)> for S { + type Output = i32; + + extern "rust-call" fn call_mut(&mut self, (x,): (i32,)) -> i32 { x * x } } -fn call_it<F:FnMut(int)->int>(mut f: F, x: int) -> int { +fn call_it<F:FnMut(i32)->i32>(mut f: F, x: i32) -> i32 { f(x) + 3 } -fn call_box(f: &mut FnMut(int) -> int, x: int) -> int { +fn call_box(f: &mut FnMut(i32) -> i32, x: i32) -> i32 { f(x) + 3 } diff --git a/src/test/run-pass/unboxed-closures-monomorphization.rs b/src/test/run-pass/unboxed-closures-monomorphization.rs index c1b7166b24e..6d192daca2f 100644 --- a/src/test/run-pass/unboxed-closures-monomorphization.rs +++ b/src/test/run-pass/unboxed-closures-monomorphization.rs @@ -16,17 +16,17 @@ #![feature(unboxed_closures)] fn main(){ - fn bar<'a, T:Clone+'a> (t: T) -> Box<FnMut<(),T> + 'a> { + fn bar<'a, T:Clone+'a> (t: T) -> Box<FnMut()->T + 'a> { box move |&mut:| t.clone() } - let mut f = bar(42u); + let mut f = bar(42_u32); assert_eq!(f.call_mut(()), 42); let mut f = bar("forty-two"); assert_eq!(f.call_mut(()), "forty-two"); - let x = 42u; + let x = 42_u32; let mut f = bar(&x); assert_eq!(f.call_mut(()), &x); diff --git a/src/test/run-pass/unboxed-closures-sugar-object.rs b/src/test/run-pass/unboxed-closures-sugar-object.rs index d65de438514..fff841a2f05 100644 --- a/src/test/run-pass/unboxed-closures-sugar-object.rs +++ b/src/test/run-pass/unboxed-closures-sugar-object.rs @@ -29,7 +29,7 @@ impl<X> Getter<X,X> for Identity { } fn main() { - let x: &Getter(int) -> (int,) = &Identity; + let x: &Getter<(i32,), (i32,)> = &Identity; let (y,) = x.get((22,)); assert_eq!(y, 22); } |
