Deprecated attributes don't take 'feature' names and are paired with stable/unstable
Conflicts: src/libcore/atomic.rs src/libcore/finally.rs src/test/auxiliary/inherited_stability.rs src/test/auxiliary/lint_stability.rs
This commit is contained in:
parent
cd6d9eab5d
commit
9758c488a9
39 changed files with 437 additions and 169 deletions
|
|
@ -28,7 +28,8 @@ pub mod stable_mod {
|
|||
|
||||
#[unstable(feature = "test_feature")]
|
||||
pub mod unstable_mod {
|
||||
#[deprecated(feature = "test_feature", since = "1.0.0")]
|
||||
#[stable(feature = "test_feature", since = "1.0.0")]
|
||||
#[deprecated(since = "1.0.0")]
|
||||
pub fn deprecated() {}
|
||||
|
||||
pub fn unstable() {}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@
|
|||
#![staged_api]
|
||||
#![unstable(feature = "test_feature")]
|
||||
|
||||
#[deprecated(feature = "oldstuff", since = "1.0.0")]
|
||||
#[stable(feature = "test_feature", since = "1.0.0")]
|
||||
#[deprecated(since = "1.0.0")]
|
||||
pub fn foo() -> uint {
|
||||
20
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,11 +12,20 @@
|
|||
#![feature(staged_api)]
|
||||
#![staged_api]
|
||||
|
||||
#[deprecated(feature = "oldstuff", since = "1.0.0")]
|
||||
#[stable(feature = "test_feature", since = "1.0.0")]
|
||||
#[deprecated(since = "1.0.0")]
|
||||
pub fn deprecated() {}
|
||||
#[deprecated(feature = "oldstuff", since = "1.0.0", reason = "text")]
|
||||
#[stable(feature = "test_feature", since = "1.0.0")]
|
||||
#[deprecated(since = "1.0.0", reason = "text")]
|
||||
pub fn deprecated_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(feature = "test_feature")]
|
||||
pub fn unstable() {}
|
||||
#[unstable(feature = "test_feature", reason = "text")]
|
||||
|
|
@ -33,11 +42,20 @@ pub fn stable_text() {}
|
|||
pub struct MethodTester;
|
||||
|
||||
impl MethodTester {
|
||||
#[deprecated(feature = "oldstuff", since = "1.0.0")]
|
||||
#[stable(feature = "test_feature", since = "1.0.0")]
|
||||
#[deprecated(since = "1.0.0")]
|
||||
pub fn method_deprecated(&self) {}
|
||||
#[deprecated(feature = "oldstuff", since = "1.0.0", reason = "text")]
|
||||
#[stable(feature = "test_feature", since = "1.0.0")]
|
||||
#[deprecated(since = "1.0.0", reason = "text")]
|
||||
pub fn method_deprecated_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(feature = "test_feature")]
|
||||
pub fn method_unstable(&self) {}
|
||||
#[unstable(feature = "test_feature", reason = "text")]
|
||||
|
|
@ -62,11 +80,20 @@ impl MethodTester {
|
|||
}
|
||||
|
||||
pub trait Trait {
|
||||
#[deprecated(feature = "oldstuff", since = "1.0.0")]
|
||||
#[stable(feature = "test_feature", since = "1.0.0")]
|
||||
#[deprecated(since = "1.0.0")]
|
||||
fn trait_deprecated(&self) {}
|
||||
#[deprecated(feature = "oldstuff", since = "1.0.0", reason = "text")]
|
||||
#[stable(feature = "test_feature", since = "1.0.0")]
|
||||
#[deprecated(since = "1.0.0", reason = "text")]
|
||||
fn trait_deprecated_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(feature = "test_feature")]
|
||||
fn trait_unstable(&self) {}
|
||||
#[unstable(feature = "test_feature", reason = "text")]
|
||||
|
|
@ -95,26 +122,38 @@ impl Trait for MethodTester {}
|
|||
#[unstable(feature = "test_feature")]
|
||||
pub trait UnstableTrait {}
|
||||
|
||||
#[deprecated(feature = "oldstuff", since = "1.0.0")]
|
||||
#[stable(feature = "test_feature", since = "1.0.0")]
|
||||
#[deprecated(since = "1.0.0")]
|
||||
pub struct DeprecatedStruct { pub i: int }
|
||||
#[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(feature = "grandfathered", since = "1.0.0")]
|
||||
pub struct StableStruct { pub i: int }
|
||||
|
||||
#[deprecated(feature = "oldstuff", since = "1.0.0")]
|
||||
#[stable(feature = "test_feature", since = "1.0.0")]
|
||||
#[deprecated(since = "1.0.0")]
|
||||
pub struct DeprecatedUnitStruct;
|
||||
#[unstable(feature = "test_feature")]
|
||||
#[deprecated(since = "1.0.0")]
|
||||
pub struct DeprecatedUnstableUnitStruct;
|
||||
#[unstable(feature = "test_feature")]
|
||||
pub struct UnstableUnitStruct;
|
||||
pub struct UnmarkedUnitStruct;
|
||||
#[stable(feature = "grandfathered", since = "1.0.0")]
|
||||
pub struct StableUnitStruct;
|
||||
|
||||
pub enum Enum {
|
||||
#[deprecated(feature = "oldstuff", since = "1.0.0")]
|
||||
#[stable(feature = "test_feature", since = "1.0.0")]
|
||||
#[deprecated(since = "1.0.0")]
|
||||
DeprecatedVariant,
|
||||
#[unstable(feature = "test_feature")]
|
||||
#[deprecated(since = "1.0.0")]
|
||||
DeprecatedUnstableVariant,
|
||||
#[unstable(feature = "test_feature")]
|
||||
UnstableVariant,
|
||||
|
||||
UnmarkedVariant,
|
||||
|
|
@ -122,9 +161,13 @@ pub enum Enum {
|
|||
StableVariant,
|
||||
}
|
||||
|
||||
#[deprecated(feature = "oldstuff", since = "1.0.0")]
|
||||
#[stable(feature = "test_feature", since = "1.0.0")]
|
||||
#[deprecated(since = "1.0.0")]
|
||||
pub struct DeprecatedTupleStruct(pub int);
|
||||
#[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(feature = "grandfathered", since = "1.0.0")]
|
||||
|
|
|
|||
|
|
@ -15,7 +15,8 @@
|
|||
struct Foo;
|
||||
|
||||
impl Foo {
|
||||
#[deprecated(feature = "oldstuff", since = "1.0.0")]
|
||||
#[unstable(feature = "test_feature")]
|
||||
#[deprecated(since = "1.0.0")]
|
||||
fn foo(self) {}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,20 @@ mod cross_crate {
|
|||
foo.method_deprecated_text(); //~ ERROR use of deprecated item: text
|
||||
foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text
|
||||
|
||||
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
|
||||
|
||||
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(); //~ WARNING use of unstable library feature
|
||||
foo.method_unstable(); //~ WARNING use of unstable library feature
|
||||
foo.trait_unstable(); //~ WARNING use of unstable library feature
|
||||
|
|
@ -60,21 +74,29 @@ mod cross_crate {
|
|||
foo.trait_stable_text();
|
||||
|
||||
let _ = DeprecatedStruct { i: 0 }; //~ ERROR use of deprecated 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 _ = DeprecatedUnitStruct; //~ ERROR use of deprecated 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 _ = Enum::DeprecatedVariant; //~ ERROR use of deprecated 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 _ = DeprecatedTupleStruct (1); //~ ERROR use of deprecated 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);
|
||||
|
|
@ -86,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);
|
||||
}
|
||||
|
|
@ -93,6 +117,10 @@ 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_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
|
||||
|
|
@ -102,6 +130,10 @@ mod cross_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_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
|
||||
|
|
@ -139,9 +171,11 @@ mod inheritance {
|
|||
}
|
||||
|
||||
mod this_crate {
|
||||
#[deprecated(feature = "oldstuff", since = "1.0.0")]
|
||||
#[unstable(feature = "test_feature")]
|
||||
#[deprecated(since = "1.0.0")]
|
||||
pub fn deprecated() {}
|
||||
#[deprecated(feature = "oldstuff", since = "1.0.0", reason = "text")]
|
||||
#[unstable(feature = "test_feature")]
|
||||
#[deprecated(since = "1.0.0", reason = "text")]
|
||||
pub fn deprecated_text() {}
|
||||
|
||||
#[unstable(feature = "test_feature")]
|
||||
|
|
@ -160,9 +194,11 @@ mod this_crate {
|
|||
pub struct MethodTester;
|
||||
|
||||
impl MethodTester {
|
||||
#[deprecated(feature = "oldstuff", since = "1.0.0")]
|
||||
#[unstable(feature = "test_feature")]
|
||||
#[deprecated(since = "1.0.0")]
|
||||
pub fn method_deprecated(&self) {}
|
||||
#[deprecated(feature = "oldstuff", since = "1.0.0", reason = "text")]
|
||||
#[unstable(feature = "test_feature")]
|
||||
#[deprecated(since = "1.0.0", reason = "text")]
|
||||
pub fn method_deprecated_text(&self) {}
|
||||
|
||||
#[unstable(feature = "test_feature")]
|
||||
|
|
@ -179,9 +215,11 @@ mod this_crate {
|
|||
}
|
||||
|
||||
pub trait Trait {
|
||||
#[deprecated(feature = "oldstuff", since = "1.0.0")]
|
||||
#[unstable(feature = "test_feature")]
|
||||
#[deprecated(since = "1.0.0")]
|
||||
fn trait_deprecated(&self) {}
|
||||
#[deprecated(feature = "oldstuff", since = "1.0.0", reason = "text")]
|
||||
#[unstable(feature = "test_feature")]
|
||||
#[deprecated(since = "1.0.0", reason = "text")]
|
||||
fn trait_deprecated_text(&self) {}
|
||||
|
||||
#[unstable(feature = "test_feature")]
|
||||
|
|
@ -199,7 +237,8 @@ mod this_crate {
|
|||
|
||||
impl Trait for MethodTester {}
|
||||
|
||||
#[deprecated(feature = "oldstuff", since = "1.0.0")]
|
||||
#[unstable(feature = "test_feature")]
|
||||
#[deprecated(since = "1.0.0")]
|
||||
pub struct DeprecatedStruct { i: isize }
|
||||
#[unstable(feature = "test_feature")]
|
||||
pub struct UnstableStruct { i: isize }
|
||||
|
|
@ -207,7 +246,8 @@ mod this_crate {
|
|||
#[stable(feature = "grandfathered", since = "1.0.0")]
|
||||
pub struct StableStruct { i: isize }
|
||||
|
||||
#[deprecated(feature = "oldstuff", since = "1.0.0")]
|
||||
#[unstable(feature = "test_feature")]
|
||||
#[deprecated(since = "1.0.0")]
|
||||
pub struct DeprecatedUnitStruct;
|
||||
#[unstable(feature = "test_feature")]
|
||||
pub struct UnstableUnitStruct;
|
||||
|
|
@ -216,7 +256,8 @@ mod this_crate {
|
|||
pub struct StableUnitStruct;
|
||||
|
||||
pub enum Enum {
|
||||
#[deprecated(feature = "oldstuff", since = "1.0.0")]
|
||||
#[unstable(feature = "test_feature")]
|
||||
#[deprecated(since = "1.0.0")]
|
||||
DeprecatedVariant,
|
||||
#[unstable(feature = "test_feature")]
|
||||
UnstableVariant,
|
||||
|
|
@ -226,7 +267,8 @@ mod this_crate {
|
|||
StableVariant,
|
||||
}
|
||||
|
||||
#[deprecated(feature = "oldstuff", since = "1.0.0")]
|
||||
#[unstable(feature = "test_feature")]
|
||||
#[deprecated(since = "1.0.0")]
|
||||
pub struct DeprecatedTupleStruct(isize);
|
||||
#[unstable(feature = "test_feature")]
|
||||
pub struct UnstableTupleStruct(isize);
|
||||
|
|
@ -308,21 +350,24 @@ mod this_crate {
|
|||
foo.trait_stable();
|
||||
}
|
||||
|
||||
#[deprecated(feature = "oldstuff", since = "1.0.0")]
|
||||
#[unstable(feature = "test_feature")]
|
||||
#[deprecated(since = "1.0.0")]
|
||||
fn test_fn_body() {
|
||||
fn fn_in_body() {}
|
||||
fn_in_body();
|
||||
}
|
||||
|
||||
impl MethodTester {
|
||||
#[deprecated(feature = "oldstuff", since = "1.0.0")]
|
||||
#[unstable(feature = "test_feature")]
|
||||
#[deprecated(since = "1.0.0")]
|
||||
fn test_method_body(&self) {
|
||||
fn fn_in_body() {}
|
||||
fn_in_body();
|
||||
}
|
||||
}
|
||||
|
||||
#[deprecated(feature = "oldstuff", since = "1.0.0")]
|
||||
#[unstable(feature = "test_feature")]
|
||||
#[deprecated(since = "1.0.0")]
|
||||
pub trait DeprecatedTrait {}
|
||||
|
||||
struct S;
|
||||
|
|
|
|||
95
src/test/compile-fail/stability-attribute-sanity.rs
Normal file
95
src/test/compile-fail/stability-attribute-sanity.rs
Normal file
|
|
@ -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() { }
|
||||
Loading…
Add table
Add a link
Reference in a new issue