Skip to content

Commit 8a2fe75

Browse files
committed
Auto merge of #95960 - jhpratt:remove-rustc_deprecated, r=compiler-errors
Remove `#[rustc_deprecated]` This removes `#[rustc_deprecated]` and introduces diagnostics to help users to the right direction (that being `#[deprecated]`). All uses of `#[rustc_deprecated]` have been converted. CI is expected to fail initially; this requires #95958, which includes converting `stdarch`. I plan on following up in a short while (maybe a bootstrap cycle?) removing the diagnostics, as they're only intended to be short-term.
2 parents db5b365 + dac487a commit 8a2fe75

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+406
-437
lines changed

compiler/rustc_attr/src/builtin.rs

+19-7
Original file line numberDiff line numberDiff line change
@@ -679,12 +679,12 @@ where
679679
continue;
680680
}
681681

682-
if let Some((_, span)) = &depr {
683-
struct_span_err!(diagnostic, attr.span, E0550, "multiple deprecated attributes")
684-
.span_label(attr.span, "repeated deprecation attribute")
685-
.span_label(*span, "first deprecation attribute")
682+
// FIXME(jhpratt) remove this eventually
683+
if attr.has_name(sym::rustc_deprecated) {
684+
diagnostic
685+
.struct_span_err(attr.span, "`#[rustc_deprecated]` has been removed")
686+
.help("use `#[deprecated]` instead")
686687
.emit();
687-
break;
688688
}
689689

690690
let Some(meta) = attr.meta() else {
@@ -742,12 +742,24 @@ where
742742
continue 'outer;
743743
}
744744
}
745-
// FIXME(jhpratt) remove this after a bootstrap occurs. Emitting an
746-
// error specific to the renaming would be a good idea as well.
745+
// FIXME(jhpratt) remove this eventually
747746
sym::reason if attr.has_name(sym::rustc_deprecated) => {
748747
if !get(mi, &mut note) {
749748
continue 'outer;
750749
}
750+
751+
let mut diag = diagnostic
752+
.struct_span_err(mi.span, "`reason` has been renamed");
753+
match note {
754+
Some(note) => diag.span_suggestion(
755+
mi.span,
756+
"use `note` instead",
757+
format!("note = \"{note}\""),
758+
Applicability::MachineApplicable,
759+
),
760+
None => diag.span_help(mi.span, "use `note` instead"),
761+
};
762+
diag.emit();
751763
}
752764
sym::suggestion => {
753765
if !sess.features_untracked().deprecated_suggestion {

compiler/rustc_error_codes/src/error_codes/E0539.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Erroneous code example:
66
#![feature(staged_api)]
77
#![stable(since = "1.0.0", feature = "test")]
88
9-
#[rustc_deprecated(reason)] // error!
9+
#[deprecated(note)] // error!
1010
#[unstable(feature = "deprecated_fn", issue = "123")]
1111
fn deprecated() {}
1212
@@ -30,7 +30,7 @@ To fix these issues you need to give required key-value pairs.
3030
#![feature(staged_api)]
3131
#![stable(since = "1.0.0", feature = "test")]
3232
33-
#[rustc_deprecated(since = "1.39.0", reason = "reason")] // ok!
33+
#[deprecated(since = "1.39.0", note = "reason")] // ok!
3434
#[unstable(feature = "deprecated_fn", issue = "123")]
3535
fn deprecated() {}
3636

compiler/rustc_error_codes/src/error_codes/E0542.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ fn _stable_fn() {}
1313
const fn _stable_const_fn() {}
1414
1515
#[stable(feature = "_deprecated_fn", since = "0.1.0")]
16-
#[rustc_deprecated(
17-
reason = "explanation for deprecation"
16+
#[deprecated(
17+
note = "explanation for deprecation"
1818
)] // invalid
1919
fn _deprecated_fn() {}
2020
```
@@ -32,9 +32,9 @@ fn _stable_fn() {}
3232
const fn _stable_const_fn() {}
3333
3434
#[stable(feature = "_deprecated_fn", since = "0.1.0")]
35-
#[rustc_deprecated(
35+
#[deprecated(
3636
since = "1.0.0",
37-
reason = "explanation for deprecation"
37+
note = "explanation for deprecation"
3838
)] // ok!
3939
fn _deprecated_fn() {}
4040
```

compiler/rustc_error_codes/src/error_codes/E0543.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The `reason` value is missing in a stability attribute.
1+
The `note` value is missing in a stability attribute.
22

33
Erroneous code example:
44

@@ -7,22 +7,22 @@ Erroneous code example:
77
#![stable(since = "1.0.0", feature = "test")]
88
99
#[stable(since = "0.1.0", feature = "_deprecated_fn")]
10-
#[rustc_deprecated(
10+
#[deprecated(
1111
since = "1.0.0"
1212
)] // invalid
1313
fn _deprecated_fn() {}
1414
```
1515

16-
To fix this issue, you need to provide the `reason` field. Example:
16+
To fix this issue, you need to provide the `note` field. Example:
1717

1818
```
1919
#![feature(staged_api)]
2020
#![stable(since = "1.0.0", feature = "test")]
2121
2222
#[stable(since = "0.1.0", feature = "_deprecated_fn")]
23-
#[rustc_deprecated(
23+
#[deprecated(
2424
since = "1.0.0",
25-
reason = "explanation for deprecation"
25+
note = "explanation for deprecation"
2626
)] // ok!
2727
fn _deprecated_fn() {}
2828
```

compiler/rustc_error_codes/src/error_codes/E0549.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
A `rustc_deprecated` attribute wasn't paired with a `stable`/`unstable`
2-
attribute.
1+
A `deprecated` attribute wasn't paired with a `stable`/`unstable` attribute with
2+
`#![feature(staged_api)]` enabled.
33

44
Erroneous code example:
55

66
```compile_fail,E0549
77
#![feature(staged_api)]
88
#![stable(since = "1.0.0", feature = "test")]
99
10-
#[rustc_deprecated(
10+
#[deprecated(
1111
since = "1.0.1",
12-
reason = "explanation for deprecation"
12+
note = "explanation for deprecation"
1313
)] // invalid
1414
fn _deprecated_fn() {}
1515
```
@@ -22,9 +22,9 @@ Example:
2222
#![stable(since = "1.0.0", feature = "test")]
2323
2424
#[stable(since = "1.0.0", feature = "test")]
25-
#[rustc_deprecated(
25+
#[deprecated(
2626
since = "1.0.1",
27-
reason = "explanation for deprecation"
27+
note = "explanation for deprecation"
2828
)] // ok!
2929
fn _deprecated_fn() {}
3030
```

compiler/rustc_error_codes/src/error_codes/E0550.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
#### Note: this error code is no longer emitted by the compiler
2+
13
More than one `deprecated` attribute has been put on an item.
24

35
Erroneous code example:
46

5-
```compile_fail,E0550
7+
```compile_fail
68
#[deprecated(note = "because why not?")]
79
#[deprecated(note = "right?")] // error!
810
fn the_banished() {}

compiler/rustc_error_codes/src/error_codes/E0734.md

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ A stability attribute has been used outside of the standard library.
33
Erroneous code example:
44

55
```compile_fail,E0734
6-
#[rustc_deprecated(since = "b", reason = "text")] // invalid
76
#[stable(feature = "a", since = "b")] // invalid
87
#[unstable(feature = "b", issue = "none")] // invalid
98
fn foo(){}

compiler/rustc_feature/src/builtin_attrs.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
304304
List: r#"/*opt*/ since = "version", /*opt*/ note = "reason""#,
305305
NameValueStr: "reason"
306306
),
307-
// This has special duplicate handling in E0550 to handle duplicates with rustc_deprecated
308-
DuplicatesOk
307+
ErrorFollowing
309308
),
310309

311310
// Crate properties:
@@ -469,10 +468,10 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
469468
// ==========================================================================
470469

471470
ungated!(feature, CrateLevel, template!(List: "name1, name2, ..."), DuplicatesOk),
472-
// DuplicatesOk since it has its own validation
471+
// FIXME(jhpratt) remove this eventually
473472
ungated!(
474473
rustc_deprecated, Normal,
475-
template!(List: r#"since = "version", note = "...""#), DuplicatesOk // See E0550
474+
template!(List: r#"since = "version", note = "...""#), ErrorFollowing
476475
),
477476
// DuplicatesOk since it has its own validation
478477
ungated!(

compiler/rustc_lint_defs/src/builtin.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -2201,13 +2201,12 @@ declare_lint! {
22012201
/// used by user code.
22022202
///
22032203
/// This lint is only enabled in the standard library. It works with the
2204-
/// use of `#[rustc_deprecated]` with a `since` field of a version in the
2205-
/// future. This allows something to be marked as deprecated in a future
2206-
/// version, and then this lint will ensure that the item is no longer
2207-
/// used in the standard library. See the [stability documentation] for
2208-
/// more details.
2204+
/// use of `#[deprecated]` with a `since` field of a version in the future.
2205+
/// This allows something to be marked as deprecated in a future version,
2206+
/// and then this lint will ensure that the item is no longer used in the
2207+
/// standard library. See the [stability documentation] for more details.
22092208
///
2210-
/// [stability documentation]: https://rustc-dev-guide.rust-lang.org/stability.html#rustc_deprecated
2209+
/// [stability documentation]: https://rustc-dev-guide.rust-lang.org/stability.html#deprecated
22112210
pub DEPRECATED_IN_FUTURE,
22122211
Allow,
22132212
"detects use of items that will be deprecated in a future version",

compiler/rustc_middle/src/middle/stability.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ pub fn deprecation_in_effect(depr: &Deprecation) -> bool {
118118
}
119119

120120
if !is_since_rustc_version {
121-
// The `since` field doesn't have semantic purpose in the stable `deprecated`
122-
// attribute, only in `rustc_deprecated`.
121+
// The `since` field doesn't have semantic purpose without `#![staged_api]`.
123122
return true;
124123
}
125124

@@ -336,7 +335,7 @@ impl<'tcx> TyCtxt<'tcx> {
336335
// topmost deprecation. For example, if a struct is deprecated,
337336
// the use of a field won't be linted.
338337
//
339-
// #[rustc_deprecated] however wants to emit down the whole
338+
// With #![staged_api], we want to emit down the whole
340339
// hierarchy.
341340
let depr_attr = &depr_entry.attr;
342341
if !skip || depr_attr.is_since_rustc_version {

library/alloc/src/slice.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ impl<T> [T] {
657657
/// ```
658658
#[rustc_allow_incoherent_impl]
659659
#[stable(feature = "rust1", since = "1.0.0")]
660-
#[rustc_deprecated(since = "1.3.0", reason = "renamed to join")]
660+
#[deprecated(since = "1.3.0", note = "renamed to join")]
661661
pub fn connect<Separator>(&self, sep: Separator) -> <Self as Join<Separator>>::Output
662662
where
663663
Self: Join<Separator>,

library/core/src/alloc/layout.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,9 @@ impl Layout {
419419
}
420420

421421
#[stable(feature = "alloc_layout", since = "1.28.0")]
422-
#[rustc_deprecated(
422+
#[deprecated(
423423
since = "1.52.0",
424-
reason = "Name does not follow std convention, use LayoutError",
424+
note = "Name does not follow std convention, use LayoutError",
425425
suggestion = "LayoutError"
426426
)]
427427
pub type LayoutErr = LayoutError;

library/core/src/alloc/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ pub use self::global::GlobalAlloc;
1010
#[stable(feature = "alloc_layout", since = "1.28.0")]
1111
pub use self::layout::Layout;
1212
#[stable(feature = "alloc_layout", since = "1.28.0")]
13-
#[rustc_deprecated(
13+
#[deprecated(
1414
since = "1.52.0",
15-
reason = "Name does not follow std convention, use LayoutError",
15+
note = "Name does not follow std convention, use LayoutError",
1616
suggestion = "LayoutError"
1717
)]
1818
#[allow(deprecated, deprecated_in_future)]

library/core/src/array/iter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl<T, const N: usize> IntoIterator for [T; N] {
7979
impl<T, const N: usize> IntoIter<T, N> {
8080
/// Creates a new iterator over the given `array`.
8181
#[stable(feature = "array_value_iter", since = "1.51.0")]
82-
#[rustc_deprecated(since = "1.59.0", reason = "use `IntoIterator::into_iter` instead")]
82+
#[deprecated(since = "1.59.0", note = "use `IntoIterator::into_iter` instead")]
8383
pub fn new(array: [T; N]) -> Self {
8484
IntoIterator::into_iter(array)
8585
}

library/core/src/fmt/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1653,10 +1653,10 @@ impl<'a> Formatter<'a> {
16531653
/// Flags for formatting
16541654
#[must_use]
16551655
#[stable(feature = "rust1", since = "1.0.0")]
1656-
#[rustc_deprecated(
1656+
#[deprecated(
16571657
since = "1.24.0",
1658-
reason = "use the `sign_plus`, `sign_minus`, `alternate`, \
1659-
or `sign_aware_zero_pad` methods instead"
1658+
note = "use the `sign_plus`, `sign_minus`, `alternate`, \
1659+
or `sign_aware_zero_pad` methods instead"
16601660
)]
16611661
pub fn flags(&self) -> u32 {
16621662
self.flags

library/core/src/hash/sip.rs

+11-20
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ use crate::ptr;
1414
///
1515
/// See: <https://131002.net/siphash>
1616
#[unstable(feature = "hashmap_internals", issue = "none")]
17-
#[rustc_deprecated(
18-
since = "1.13.0",
19-
reason = "use `std::collections::hash_map::DefaultHasher` instead"
20-
)]
17+
#[deprecated(since = "1.13.0", note = "use `std::collections::hash_map::DefaultHasher` instead")]
2118
#[derive(Debug, Clone, Default)]
2219
#[doc(hidden)]
2320
pub struct SipHasher13 {
@@ -28,10 +25,7 @@ pub struct SipHasher13 {
2825
///
2926
/// See: <https://131002.net/siphash/>
3027
#[unstable(feature = "hashmap_internals", issue = "none")]
31-
#[rustc_deprecated(
32-
since = "1.13.0",
33-
reason = "use `std::collections::hash_map::DefaultHasher` instead"
34-
)]
28+
#[deprecated(since = "1.13.0", note = "use `std::collections::hash_map::DefaultHasher` instead")]
3529
#[derive(Debug, Clone, Default)]
3630
struct SipHasher24 {
3731
hasher: Hasher<Sip24Rounds>,
@@ -50,10 +44,7 @@ struct SipHasher24 {
5044
/// it is not intended for cryptographic purposes. As such, all
5145
/// cryptographic uses of this implementation are _strongly discouraged_.
5246
#[stable(feature = "rust1", since = "1.0.0")]
53-
#[rustc_deprecated(
54-
since = "1.13.0",
55-
reason = "use `std::collections::hash_map::DefaultHasher` instead"
56-
)]
47+
#[deprecated(since = "1.13.0", note = "use `std::collections::hash_map::DefaultHasher` instead")]
5748
#[derive(Debug, Clone, Default)]
5849
pub struct SipHasher(SipHasher24);
5950

@@ -153,9 +144,9 @@ impl SipHasher {
153144
/// Creates a new `SipHasher` with the two initial keys set to 0.
154145
#[inline]
155146
#[stable(feature = "rust1", since = "1.0.0")]
156-
#[rustc_deprecated(
147+
#[deprecated(
157148
since = "1.13.0",
158-
reason = "use `std::collections::hash_map::DefaultHasher` instead"
149+
note = "use `std::collections::hash_map::DefaultHasher` instead"
159150
)]
160151
#[must_use]
161152
pub fn new() -> SipHasher {
@@ -165,9 +156,9 @@ impl SipHasher {
165156
/// Creates a `SipHasher` that is keyed off the provided keys.
166157
#[inline]
167158
#[stable(feature = "rust1", since = "1.0.0")]
168-
#[rustc_deprecated(
159+
#[deprecated(
169160
since = "1.13.0",
170-
reason = "use `std::collections::hash_map::DefaultHasher` instead"
161+
note = "use `std::collections::hash_map::DefaultHasher` instead"
171162
)]
172163
#[must_use]
173164
pub fn new_with_keys(key0: u64, key1: u64) -> SipHasher {
@@ -179,9 +170,9 @@ impl SipHasher13 {
179170
/// Creates a new `SipHasher13` with the two initial keys set to 0.
180171
#[inline]
181172
#[unstable(feature = "hashmap_internals", issue = "none")]
182-
#[rustc_deprecated(
173+
#[deprecated(
183174
since = "1.13.0",
184-
reason = "use `std::collections::hash_map::DefaultHasher` instead"
175+
note = "use `std::collections::hash_map::DefaultHasher` instead"
185176
)]
186177
pub fn new() -> SipHasher13 {
187178
SipHasher13::new_with_keys(0, 0)
@@ -190,9 +181,9 @@ impl SipHasher13 {
190181
/// Creates a `SipHasher13` that is keyed off the provided keys.
191182
#[inline]
192183
#[unstable(feature = "hashmap_internals", issue = "none")]
193-
#[rustc_deprecated(
184+
#[deprecated(
194185
since = "1.13.0",
195-
reason = "use `std::collections::hash_map::DefaultHasher` instead"
186+
note = "use `std::collections::hash_map::DefaultHasher` instead"
196187
)]
197188
pub fn new_with_keys(key0: u64, key1: u64) -> SipHasher13 {
198189
SipHasher13 { hasher: Hasher::new_with_keys(key0, key1) }

library/core/src/intrinsics.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,7 @@ use crate::mem;
6363
use crate::sync::atomic::{self, AtomicBool, AtomicI32, AtomicIsize, AtomicU32, Ordering};
6464

6565
#[stable(feature = "drop_in_place", since = "1.8.0")]
66-
#[rustc_deprecated(
67-
reason = "no longer an intrinsic - use `ptr::drop_in_place` directly",
68-
since = "1.52.0"
69-
)]
66+
#[deprecated(note = "no longer an intrinsic - use `ptr::drop_in_place` directly", since = "1.52.0")]
7067
#[inline]
7168
pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
7269
// SAFETY: see `ptr::drop_in_place`

0 commit comments

Comments
 (0)