Skip to content

Commit

Permalink
Change rustc_deprecated to use note
Browse files Browse the repository at this point in the history
This keeps `reason` around for the time being. This is necessary to
avoid breakage during the bootstrap process. This change, as a whole,
brings `#[rustc_deprecated]` more in line with `#[deprecated]`.
  • Loading branch information
jhpratt committed Mar 4, 2022
1 parent 9fcbc32 commit 6efc8e3
Show file tree
Hide file tree
Showing 22 changed files with 146 additions and 143 deletions.
1 change: 1 addition & 0 deletions compiler/rustc_ast_passes/src/feature_gate.rs
Expand Up @@ -438,6 +438,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
.emit();
}
} else {
// FIXME(jhpratt) remove this after the two attributes are merged
if attr.has_name(sym::deprecated) {
self.sess
.struct_span_err(attr.span, "`#[deprecated]` cannot be used in staged API")
Expand Down
8 changes: 5 additions & 3 deletions compiler/rustc_attr/src/builtin.rs
Expand Up @@ -729,11 +729,13 @@ where
continue 'outer;
}
}
sym::note if attr.has_name(sym::deprecated) => {
sym::note => {
if !get(mi, &mut note) {
continue 'outer;
}
}
// FIXME(jhpratt) remove this after a bootstrap occurs. Emitting an
// error specific to the renaming would be a good idea as well.
sym::reason if attr.has_name(sym::rustc_deprecated) => {
if !get(mi, &mut note) {
continue 'outer;
Expand All @@ -753,7 +755,7 @@ where
if attr.has_name(sym::deprecated) {
&["since", "note"]
} else {
&["since", "reason", "suggestion"]
&["since", "note", "suggestion"]
},
),
);
Expand Down Expand Up @@ -787,7 +789,7 @@ where
}

if note.is_none() {
struct_span_err!(diagnostic, attr.span, E0543, "missing 'reason'").emit();
struct_span_err!(diagnostic, attr.span, E0543, "missing 'note'").emit();
continue;
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_feature/src/builtin_attrs.rs
Expand Up @@ -461,7 +461,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
// DuplicatesOk since it has its own validation
ungated!(
rustc_deprecated, Normal,
template!(List: r#"since = "version", reason = "...""#), DuplicatesOk // See E0550
template!(List: r#"since = "version", note = "...""#), DuplicatesOk // See E0550
),
// DuplicatesOk since it has its own validation
ungated!(
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/deprecation/rustc_deprecation-in-future.rs
Expand Up @@ -4,11 +4,11 @@

#![stable(feature = "rustc_deprecation-in-future-test", since = "1.0.0")]

#[rustc_deprecated(since = "99.99.99", reason = "effectively never")]
#[rustc_deprecated(since = "99.99.99", note = "effectively never")]
#[stable(feature = "rustc_deprecation-in-future-test", since = "1.0.0")]
pub struct S1;

#[rustc_deprecated(since = "TBD", reason = "literally never")]
#[rustc_deprecated(since = "TBD", note = "literally never")]
#[stable(feature = "rustc_deprecation-in-future-test", since = "1.0.0")]
pub struct S2;

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-17337.rs
Expand Up @@ -7,7 +7,7 @@ struct Foo;

impl Foo {
#[unstable(feature = "unstable_test_feature", issue = "none")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
fn foo(self) {}
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/lint/auxiliary/inherited_stability.rs
Expand Up @@ -20,7 +20,7 @@ pub mod stable_mod {
#[unstable(feature = "unstable_test_feature", issue = "none")]
pub mod unstable_mod {
#[stable(feature = "stable_test_feature", since = "1.0.0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
pub fn deprecated() {}

pub fn unstable() {}
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/lint/auxiliary/lint_output_format.rs
Expand Up @@ -4,7 +4,7 @@
#![unstable(feature = "unstable_test_feature", issue = "none")]

#[stable(feature = "stable_test_feature", since = "1.0.0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
pub fn foo() -> usize {
20
}
Expand Down
46 changes: 23 additions & 23 deletions src/test/ui/lint/auxiliary/lint_stability.rs
Expand Up @@ -5,21 +5,21 @@
#![stable(feature = "lint_stability", since = "1.0.0")]

#[stable(feature = "stable_test_feature", since = "1.0.0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
pub fn deprecated() {}
#[stable(feature = "stable_test_feature", since = "1.0.0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
pub fn deprecated_text() {}

#[stable(feature = "stable_test_feature", since = "1.0.0")]
#[rustc_deprecated(since = "99.99.99", reason = "text")]
#[rustc_deprecated(since = "99.99.99", note = "text")]
pub fn deprecated_future() {}

#[unstable(feature = "unstable_test_feature", issue = "none")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
pub fn deprecated_unstable() {}
#[unstable(feature = "unstable_test_feature", issue = "none")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
pub fn deprecated_unstable_text() {}

#[unstable(feature = "unstable_test_feature", issue = "none")]
Expand All @@ -37,17 +37,17 @@ pub struct MethodTester;

impl MethodTester {
#[stable(feature = "stable_test_feature", since = "1.0.0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
pub fn method_deprecated(&self) {}
#[stable(feature = "stable_test_feature", since = "1.0.0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
pub fn method_deprecated_text(&self) {}

#[unstable(feature = "unstable_test_feature", issue = "none")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
pub fn method_deprecated_unstable(&self) {}
#[unstable(feature = "unstable_test_feature", issue = "none")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
pub fn method_deprecated_unstable_text(&self) {}

#[unstable(feature = "unstable_test_feature", issue = "none")]
Expand All @@ -64,17 +64,17 @@ impl MethodTester {
#[stable(feature = "stable_test_feature", since = "1.0.0")]
pub trait Trait {
#[stable(feature = "stable_test_feature", since = "1.0.0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
fn trait_deprecated(&self) {}
#[stable(feature = "stable_test_feature", since = "1.0.0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
fn trait_deprecated_text(&self) {}

#[unstable(feature = "unstable_test_feature", issue = "none")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
fn trait_deprecated_unstable(&self) {}
#[unstable(feature = "unstable_test_feature", issue = "none")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
fn trait_deprecated_unstable_text(&self) {}

#[unstable(feature = "unstable_test_feature", issue = "none")]
Expand All @@ -93,7 +93,7 @@ pub trait TraitWithAssociatedTypes {
#[unstable(feature = "unstable_test_feature", issue = "none")]
type TypeUnstable = u8;
#[stable(feature = "stable_test_feature", since = "1.0.0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
type TypeDeprecated = u8;
}

Expand All @@ -104,18 +104,18 @@ impl Trait for MethodTester {}
pub trait UnstableTrait { fn dummy(&self) { } }

#[stable(feature = "stable_test_feature", since = "1.0.0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
pub trait DeprecatedTrait {
#[stable(feature = "stable_test_feature", since = "1.0.0")] fn dummy(&self) { }
}

#[stable(feature = "stable_test_feature", since = "1.0.0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
pub struct DeprecatedStruct {
#[stable(feature = "stable_test_feature", since = "1.0.0")] pub i: isize
}
#[unstable(feature = "unstable_test_feature", issue = "none")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
pub struct DeprecatedUnstableStruct {
#[stable(feature = "stable_test_feature", since = "1.0.0")] pub i: isize
}
Expand All @@ -133,10 +133,10 @@ pub enum UnstableEnum {}
pub enum StableEnum {}

#[stable(feature = "stable_test_feature", since = "1.0.0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
pub struct DeprecatedUnitStruct;
#[unstable(feature = "unstable_test_feature", issue = "none")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
pub struct DeprecatedUnstableUnitStruct;
#[unstable(feature = "unstable_test_feature", issue = "none")]
pub struct UnstableUnitStruct;
Expand All @@ -146,10 +146,10 @@ pub struct StableUnitStruct;
#[stable(feature = "stable_test_feature", since = "1.0.0")]
pub enum Enum {
#[stable(feature = "stable_test_feature", since = "1.0.0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
DeprecatedVariant,
#[unstable(feature = "unstable_test_feature", issue = "none")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
DeprecatedUnstableVariant,
#[unstable(feature = "unstable_test_feature", issue = "none")]
UnstableVariant,
Expand All @@ -159,10 +159,10 @@ pub enum Enum {
}

#[stable(feature = "stable_test_feature", since = "1.0.0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
pub struct DeprecatedTupleStruct(#[stable(feature = "rust1", since = "1.0.0")] pub isize);
#[unstable(feature = "unstable_test_feature", issue = "none")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
pub struct DeprecatedUnstableTupleStruct(#[stable(feature = "rust1", since = "1.0.0")] pub isize);
#[unstable(feature = "unstable_test_feature", issue = "none")]
pub struct UnstableTupleStruct(#[stable(feature = "rust1", since = "1.0.0")] pub isize);
Expand Down
14 changes: 7 additions & 7 deletions src/test/ui/lint/auxiliary/lint_stability_fields.rs
Expand Up @@ -6,7 +6,7 @@ pub struct Stable {
pub inherit: u8,
#[unstable(feature = "unstable_test_feature", issue = "none")]
pub override1: u8,
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
#[unstable(feature = "unstable_test_feature", issue = "none")]
pub override2: u8,
#[stable(feature = "rust2", since = "2.0.0")]
Expand All @@ -17,7 +17,7 @@ pub struct Stable {
pub struct Stable2(#[stable(feature = "rust2", since = "2.0.0")] pub u8,
#[unstable(feature = "unstable_test_feature", issue = "none")] pub u8,
#[unstable(feature = "unstable_test_feature", issue = "none")]
#[rustc_deprecated(since = "1.0.0", reason = "text")] pub u8,
#[rustc_deprecated(since = "1.0.0", note = "text")] pub u8,
pub u8);

#[stable(feature = "rust1", since = "1.0.0")]
Expand All @@ -28,7 +28,7 @@ pub enum Stable3 {
Override1,
#[unstable(feature = "unstable_test_feature", issue = "none")]
Override2,
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
#[unstable(feature = "unstable_test_feature", issue = "none")]
Override3,
}
Expand All @@ -38,7 +38,7 @@ pub struct Unstable {
pub inherit: u8,
#[stable(feature = "rust1", since = "1.0.0")]
pub override1: u8,
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
#[unstable(feature = "unstable_test_feature", issue = "none")]
pub override2: u8,
}
Expand All @@ -47,10 +47,10 @@ pub struct Unstable {
pub struct Unstable2(pub u8,
#[stable(feature = "rust1", since = "1.0.0")] pub u8,
#[unstable(feature = "unstable_test_feature", issue = "none")]
#[rustc_deprecated(since = "1.0.0", reason = "text")] pub u8);
#[rustc_deprecated(since = "1.0.0", note = "text")] pub u8);

#[unstable(feature = "unstable_test_feature", issue = "none")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
pub struct Deprecated {
pub inherit: u8,
#[stable(feature = "rust1", since = "1.0.0")]
Expand All @@ -60,7 +60,7 @@ pub struct Deprecated {
}

#[unstable(feature = "unstable_test_feature", issue = "none")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
pub struct Deprecated2(pub u8,
#[stable(feature = "rust1", since = "1.0.0")] pub u8,
#[unstable(feature = "unstable_test_feature", issue = "none")] pub u8);
26 changes: 13 additions & 13 deletions src/test/ui/lint/lint-stability-2.rs
Expand Up @@ -169,10 +169,10 @@ mod cross_crate {

mod this_crate {
#[unstable(feature = "unstable_test_feature", issue = "none")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
pub fn deprecated() {}
#[unstable(feature = "unstable_test_feature", issue = "none")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
pub fn deprecated_text() {}

#[unstable(feature = "unstable_test_feature", issue = "none")]
Expand All @@ -190,10 +190,10 @@ mod this_crate {

impl MethodTester {
#[unstable(feature = "unstable_test_feature", issue = "none")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
pub fn method_deprecated(&self) {}
#[unstable(feature = "unstable_test_feature", issue = "none")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
pub fn method_deprecated_text(&self) {}

#[unstable(feature = "unstable_test_feature", issue = "none")]
Expand All @@ -209,10 +209,10 @@ mod this_crate {

pub trait Trait {
#[unstable(feature = "unstable_test_feature", issue = "none")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
fn trait_deprecated(&self) {}
#[unstable(feature = "unstable_test_feature", issue = "none")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
fn trait_deprecated_text(&self) {}

#[unstable(feature = "unstable_test_feature", issue = "none")]
Expand All @@ -229,7 +229,7 @@ mod this_crate {
impl Trait for MethodTester {}

#[unstable(feature = "unstable_test_feature", issue = "none")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
pub struct DeprecatedStruct {
#[stable(feature = "stable_test_feature", since = "1.0.0")] i: isize
}
Expand All @@ -243,7 +243,7 @@ mod this_crate {
}

#[unstable(feature = "unstable_test_feature", issue = "none")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
pub struct DeprecatedUnitStruct;
#[unstable(feature = "unstable_test_feature", issue = "none")]
pub struct UnstableUnitStruct;
Expand All @@ -252,7 +252,7 @@ mod this_crate {

pub enum Enum {
#[unstable(feature = "unstable_test_feature", issue = "none")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
DeprecatedVariant,
#[unstable(feature = "unstable_test_feature", issue = "none")]
UnstableVariant,
Expand All @@ -262,7 +262,7 @@ mod this_crate {
}

#[unstable(feature = "unstable_test_feature", issue = "none")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
pub struct DeprecatedTupleStruct(isize);
#[unstable(feature = "unstable_test_feature", issue = "none")]
pub struct UnstableTupleStruct(isize);
Expand Down Expand Up @@ -382,23 +382,23 @@ mod this_crate {
}

#[unstable(feature = "unstable_test_feature", issue = "none")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
fn test_fn_body() {
fn fn_in_body() {}
fn_in_body();
}

impl MethodTester {
#[unstable(feature = "unstable_test_feature", issue = "none")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
fn test_method_body(&self) {
fn fn_in_body() {}
fn_in_body();
}
}

#[unstable(feature = "unstable_test_feature", issue = "none")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[rustc_deprecated(since = "1.0.0", note = "text")]
pub trait DeprecatedTrait {
fn dummy(&self) { }
}
Expand Down

0 comments on commit 6efc8e3

Please sign in to comment.