Skip to content

Commit 6efc8e3

Browse files
committed
Change rustc_deprecated to use note
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]`.
1 parent 9fcbc32 commit 6efc8e3

22 files changed

+146
-143
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
438438
.emit();
439439
}
440440
} else {
441+
// FIXME(jhpratt) remove this after the two attributes are merged
441442
if attr.has_name(sym::deprecated) {
442443
self.sess
443444
.struct_span_err(attr.span, "`#[deprecated]` cannot be used in staged API")

compiler/rustc_attr/src/builtin.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -729,11 +729,13 @@ where
729729
continue 'outer;
730730
}
731731
}
732-
sym::note if attr.has_name(sym::deprecated) => {
732+
sym::note => {
733733
if !get(mi, &mut note) {
734734
continue 'outer;
735735
}
736736
}
737+
// FIXME(jhpratt) remove this after a bootstrap occurs. Emitting an
738+
// error specific to the renaming would be a good idea as well.
737739
sym::reason if attr.has_name(sym::rustc_deprecated) => {
738740
if !get(mi, &mut note) {
739741
continue 'outer;
@@ -753,7 +755,7 @@ where
753755
if attr.has_name(sym::deprecated) {
754756
&["since", "note"]
755757
} else {
756-
&["since", "reason", "suggestion"]
758+
&["since", "note", "suggestion"]
757759
},
758760
),
759761
);
@@ -787,7 +789,7 @@ where
787789
}
788790

789791
if note.is_none() {
790-
struct_span_err!(diagnostic, attr.span, E0543, "missing 'reason'").emit();
792+
struct_span_err!(diagnostic, attr.span, E0543, "missing 'note'").emit();
791793
continue;
792794
}
793795
}

compiler/rustc_feature/src/builtin_attrs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
461461
// DuplicatesOk since it has its own validation
462462
ungated!(
463463
rustc_deprecated, Normal,
464-
template!(List: r#"since = "version", reason = "...""#), DuplicatesOk // See E0550
464+
template!(List: r#"since = "version", note = "...""#), DuplicatesOk // See E0550
465465
),
466466
// DuplicatesOk since it has its own validation
467467
ungated!(

src/test/ui/deprecation/rustc_deprecation-in-future.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

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

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

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

src/test/ui/issues/issue-17337.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ struct Foo;
77

88
impl Foo {
99
#[unstable(feature = "unstable_test_feature", issue = "none")]
10-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
10+
#[rustc_deprecated(since = "1.0.0", note = "text")]
1111
fn foo(self) {}
1212
}
1313

src/test/ui/lint/auxiliary/inherited_stability.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub mod stable_mod {
2020
#[unstable(feature = "unstable_test_feature", issue = "none")]
2121
pub mod unstable_mod {
2222
#[stable(feature = "stable_test_feature", since = "1.0.0")]
23-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
23+
#[rustc_deprecated(since = "1.0.0", note = "text")]
2424
pub fn deprecated() {}
2525

2626
pub fn unstable() {}

src/test/ui/lint/auxiliary/lint_output_format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#![unstable(feature = "unstable_test_feature", issue = "none")]
55

66
#[stable(feature = "stable_test_feature", since = "1.0.0")]
7-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
7+
#[rustc_deprecated(since = "1.0.0", note = "text")]
88
pub fn foo() -> usize {
99
20
1010
}

src/test/ui/lint/auxiliary/lint_stability.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@
55
#![stable(feature = "lint_stability", since = "1.0.0")]
66

77
#[stable(feature = "stable_test_feature", since = "1.0.0")]
8-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
8+
#[rustc_deprecated(since = "1.0.0", note = "text")]
99
pub fn deprecated() {}
1010
#[stable(feature = "stable_test_feature", since = "1.0.0")]
11-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
11+
#[rustc_deprecated(since = "1.0.0", note = "text")]
1212
pub fn deprecated_text() {}
1313

1414
#[stable(feature = "stable_test_feature", since = "1.0.0")]
15-
#[rustc_deprecated(since = "99.99.99", reason = "text")]
15+
#[rustc_deprecated(since = "99.99.99", note = "text")]
1616
pub fn deprecated_future() {}
1717

1818
#[unstable(feature = "unstable_test_feature", issue = "none")]
19-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
19+
#[rustc_deprecated(since = "1.0.0", note = "text")]
2020
pub fn deprecated_unstable() {}
2121
#[unstable(feature = "unstable_test_feature", issue = "none")]
22-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
22+
#[rustc_deprecated(since = "1.0.0", note = "text")]
2323
pub fn deprecated_unstable_text() {}
2424

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

3838
impl MethodTester {
3939
#[stable(feature = "stable_test_feature", since = "1.0.0")]
40-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
40+
#[rustc_deprecated(since = "1.0.0", note = "text")]
4141
pub fn method_deprecated(&self) {}
4242
#[stable(feature = "stable_test_feature", since = "1.0.0")]
43-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
43+
#[rustc_deprecated(since = "1.0.0", note = "text")]
4444
pub fn method_deprecated_text(&self) {}
4545

4646
#[unstable(feature = "unstable_test_feature", issue = "none")]
47-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
47+
#[rustc_deprecated(since = "1.0.0", note = "text")]
4848
pub fn method_deprecated_unstable(&self) {}
4949
#[unstable(feature = "unstable_test_feature", issue = "none")]
50-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
50+
#[rustc_deprecated(since = "1.0.0", note = "text")]
5151
pub fn method_deprecated_unstable_text(&self) {}
5252

5353
#[unstable(feature = "unstable_test_feature", issue = "none")]
@@ -64,17 +64,17 @@ impl MethodTester {
6464
#[stable(feature = "stable_test_feature", since = "1.0.0")]
6565
pub trait Trait {
6666
#[stable(feature = "stable_test_feature", since = "1.0.0")]
67-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
67+
#[rustc_deprecated(since = "1.0.0", note = "text")]
6868
fn trait_deprecated(&self) {}
6969
#[stable(feature = "stable_test_feature", since = "1.0.0")]
70-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
70+
#[rustc_deprecated(since = "1.0.0", note = "text")]
7171
fn trait_deprecated_text(&self) {}
7272

7373
#[unstable(feature = "unstable_test_feature", issue = "none")]
74-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
74+
#[rustc_deprecated(since = "1.0.0", note = "text")]
7575
fn trait_deprecated_unstable(&self) {}
7676
#[unstable(feature = "unstable_test_feature", issue = "none")]
77-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
77+
#[rustc_deprecated(since = "1.0.0", note = "text")]
7878
fn trait_deprecated_unstable_text(&self) {}
7979

8080
#[unstable(feature = "unstable_test_feature", issue = "none")]
@@ -93,7 +93,7 @@ pub trait TraitWithAssociatedTypes {
9393
#[unstable(feature = "unstable_test_feature", issue = "none")]
9494
type TypeUnstable = u8;
9595
#[stable(feature = "stable_test_feature", since = "1.0.0")]
96-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
96+
#[rustc_deprecated(since = "1.0.0", note = "text")]
9797
type TypeDeprecated = u8;
9898
}
9999

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

106106
#[stable(feature = "stable_test_feature", since = "1.0.0")]
107-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
107+
#[rustc_deprecated(since = "1.0.0", note = "text")]
108108
pub trait DeprecatedTrait {
109109
#[stable(feature = "stable_test_feature", since = "1.0.0")] fn dummy(&self) { }
110110
}
111111

112112
#[stable(feature = "stable_test_feature", since = "1.0.0")]
113-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
113+
#[rustc_deprecated(since = "1.0.0", note = "text")]
114114
pub struct DeprecatedStruct {
115115
#[stable(feature = "stable_test_feature", since = "1.0.0")] pub i: isize
116116
}
117117
#[unstable(feature = "unstable_test_feature", issue = "none")]
118-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
118+
#[rustc_deprecated(since = "1.0.0", note = "text")]
119119
pub struct DeprecatedUnstableStruct {
120120
#[stable(feature = "stable_test_feature", since = "1.0.0")] pub i: isize
121121
}
@@ -133,10 +133,10 @@ pub enum UnstableEnum {}
133133
pub enum StableEnum {}
134134

135135
#[stable(feature = "stable_test_feature", since = "1.0.0")]
136-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
136+
#[rustc_deprecated(since = "1.0.0", note = "text")]
137137
pub struct DeprecatedUnitStruct;
138138
#[unstable(feature = "unstable_test_feature", issue = "none")]
139-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
139+
#[rustc_deprecated(since = "1.0.0", note = "text")]
140140
pub struct DeprecatedUnstableUnitStruct;
141141
#[unstable(feature = "unstable_test_feature", issue = "none")]
142142
pub struct UnstableUnitStruct;
@@ -146,10 +146,10 @@ pub struct StableUnitStruct;
146146
#[stable(feature = "stable_test_feature", since = "1.0.0")]
147147
pub enum Enum {
148148
#[stable(feature = "stable_test_feature", since = "1.0.0")]
149-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
149+
#[rustc_deprecated(since = "1.0.0", note = "text")]
150150
DeprecatedVariant,
151151
#[unstable(feature = "unstable_test_feature", issue = "none")]
152-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
152+
#[rustc_deprecated(since = "1.0.0", note = "text")]
153153
DeprecatedUnstableVariant,
154154
#[unstable(feature = "unstable_test_feature", issue = "none")]
155155
UnstableVariant,
@@ -159,10 +159,10 @@ pub enum Enum {
159159
}
160160

161161
#[stable(feature = "stable_test_feature", since = "1.0.0")]
162-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
162+
#[rustc_deprecated(since = "1.0.0", note = "text")]
163163
pub struct DeprecatedTupleStruct(#[stable(feature = "rust1", since = "1.0.0")] pub isize);
164164
#[unstable(feature = "unstable_test_feature", issue = "none")]
165-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
165+
#[rustc_deprecated(since = "1.0.0", note = "text")]
166166
pub struct DeprecatedUnstableTupleStruct(#[stable(feature = "rust1", since = "1.0.0")] pub isize);
167167
#[unstable(feature = "unstable_test_feature", issue = "none")]
168168
pub struct UnstableTupleStruct(#[stable(feature = "rust1", since = "1.0.0")] pub isize);

src/test/ui/lint/auxiliary/lint_stability_fields.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub struct Stable {
66
pub inherit: u8,
77
#[unstable(feature = "unstable_test_feature", issue = "none")]
88
pub override1: u8,
9-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
9+
#[rustc_deprecated(since = "1.0.0", note = "text")]
1010
#[unstable(feature = "unstable_test_feature", issue = "none")]
1111
pub override2: u8,
1212
#[stable(feature = "rust2", since = "2.0.0")]
@@ -17,7 +17,7 @@ pub struct Stable {
1717
pub struct Stable2(#[stable(feature = "rust2", since = "2.0.0")] pub u8,
1818
#[unstable(feature = "unstable_test_feature", issue = "none")] pub u8,
1919
#[unstable(feature = "unstable_test_feature", issue = "none")]
20-
#[rustc_deprecated(since = "1.0.0", reason = "text")] pub u8,
20+
#[rustc_deprecated(since = "1.0.0", note = "text")] pub u8,
2121
pub u8);
2222

2323
#[stable(feature = "rust1", since = "1.0.0")]
@@ -28,7 +28,7 @@ pub enum Stable3 {
2828
Override1,
2929
#[unstable(feature = "unstable_test_feature", issue = "none")]
3030
Override2,
31-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
31+
#[rustc_deprecated(since = "1.0.0", note = "text")]
3232
#[unstable(feature = "unstable_test_feature", issue = "none")]
3333
Override3,
3434
}
@@ -38,7 +38,7 @@ pub struct Unstable {
3838
pub inherit: u8,
3939
#[stable(feature = "rust1", since = "1.0.0")]
4040
pub override1: u8,
41-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
41+
#[rustc_deprecated(since = "1.0.0", note = "text")]
4242
#[unstable(feature = "unstable_test_feature", issue = "none")]
4343
pub override2: u8,
4444
}
@@ -47,10 +47,10 @@ pub struct Unstable {
4747
pub struct Unstable2(pub u8,
4848
#[stable(feature = "rust1", since = "1.0.0")] pub u8,
4949
#[unstable(feature = "unstable_test_feature", issue = "none")]
50-
#[rustc_deprecated(since = "1.0.0", reason = "text")] pub u8);
50+
#[rustc_deprecated(since = "1.0.0", note = "text")] pub u8);
5151

5252
#[unstable(feature = "unstable_test_feature", issue = "none")]
53-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
53+
#[rustc_deprecated(since = "1.0.0", note = "text")]
5454
pub struct Deprecated {
5555
pub inherit: u8,
5656
#[stable(feature = "rust1", since = "1.0.0")]
@@ -60,7 +60,7 @@ pub struct Deprecated {
6060
}
6161

6262
#[unstable(feature = "unstable_test_feature", issue = "none")]
63-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
63+
#[rustc_deprecated(since = "1.0.0", note = "text")]
6464
pub struct Deprecated2(pub u8,
6565
#[stable(feature = "rust1", since = "1.0.0")] pub u8,
6666
#[unstable(feature = "unstable_test_feature", issue = "none")] pub u8);

src/test/ui/lint/lint-stability-2.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,10 @@ mod cross_crate {
169169

170170
mod this_crate {
171171
#[unstable(feature = "unstable_test_feature", issue = "none")]
172-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
172+
#[rustc_deprecated(since = "1.0.0", note = "text")]
173173
pub fn deprecated() {}
174174
#[unstable(feature = "unstable_test_feature", issue = "none")]
175-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
175+
#[rustc_deprecated(since = "1.0.0", note = "text")]
176176
pub fn deprecated_text() {}
177177

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

191191
impl MethodTester {
192192
#[unstable(feature = "unstable_test_feature", issue = "none")]
193-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
193+
#[rustc_deprecated(since = "1.0.0", note = "text")]
194194
pub fn method_deprecated(&self) {}
195195
#[unstable(feature = "unstable_test_feature", issue = "none")]
196-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
196+
#[rustc_deprecated(since = "1.0.0", note = "text")]
197197
pub fn method_deprecated_text(&self) {}
198198

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

210210
pub trait Trait {
211211
#[unstable(feature = "unstable_test_feature", issue = "none")]
212-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
212+
#[rustc_deprecated(since = "1.0.0", note = "text")]
213213
fn trait_deprecated(&self) {}
214214
#[unstable(feature = "unstable_test_feature", issue = "none")]
215-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
215+
#[rustc_deprecated(since = "1.0.0", note = "text")]
216216
fn trait_deprecated_text(&self) {}
217217

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

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

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

253253
pub enum Enum {
254254
#[unstable(feature = "unstable_test_feature", issue = "none")]
255-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
255+
#[rustc_deprecated(since = "1.0.0", note = "text")]
256256
DeprecatedVariant,
257257
#[unstable(feature = "unstable_test_feature", issue = "none")]
258258
UnstableVariant,
@@ -262,7 +262,7 @@ mod this_crate {
262262
}
263263

264264
#[unstable(feature = "unstable_test_feature", issue = "none")]
265-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
265+
#[rustc_deprecated(since = "1.0.0", note = "text")]
266266
pub struct DeprecatedTupleStruct(isize);
267267
#[unstable(feature = "unstable_test_feature", issue = "none")]
268268
pub struct UnstableTupleStruct(isize);
@@ -382,23 +382,23 @@ mod this_crate {
382382
}
383383

384384
#[unstable(feature = "unstable_test_feature", issue = "none")]
385-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
385+
#[rustc_deprecated(since = "1.0.0", note = "text")]
386386
fn test_fn_body() {
387387
fn fn_in_body() {}
388388
fn_in_body();
389389
}
390390

391391
impl MethodTester {
392392
#[unstable(feature = "unstable_test_feature", issue = "none")]
393-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
393+
#[rustc_deprecated(since = "1.0.0", note = "text")]
394394
fn test_method_body(&self) {
395395
fn fn_in_body() {}
396396
fn_in_body();
397397
}
398398
}
399399

400400
#[unstable(feature = "unstable_test_feature", issue = "none")]
401-
#[rustc_deprecated(since = "1.0.0", reason = "text")]
401+
#[rustc_deprecated(since = "1.0.0", note = "text")]
402402
pub trait DeprecatedTrait {
403403
fn dummy(&self) { }
404404
}

0 commit comments

Comments
 (0)