Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove #[rustc_deprecated] #95960

Merged
merged 6 commits into from
May 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions compiler/rustc_attr/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -679,12 +679,12 @@ where
continue;
}

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

let Some(meta) = attr.meta() else {
Expand Down Expand Up @@ -742,12 +742,24 @@ where
continue 'outer;
}
}
// FIXME(jhpratt) remove this after a bootstrap occurs. Emitting an
// error specific to the renaming would be a good idea as well.
// FIXME(jhpratt) remove this eventually
sym::reason if attr.has_name(sym::rustc_deprecated) => {
if !get(mi, &mut note) {
continue 'outer;
}

let mut diag = diagnostic
.struct_span_err(mi.span, "`reason` has been renamed");
match note {
Some(note) => diag.span_suggestion(
mi.span,
"use `note` instead",
format!("note = \"{note}\""),
Applicability::MachineApplicable,
),
None => diag.span_help(mi.span, "use `note` instead"),
};
diag.emit();
}
sym::suggestion => {
if !sess.features_untracked().deprecated_suggestion {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_error_codes/src/error_codes/E0539.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Erroneous code example:
#![feature(staged_api)]
#![stable(since = "1.0.0", feature = "test")]

#[rustc_deprecated(reason)] // error!
#[deprecated(note)] // error!
#[unstable(feature = "deprecated_fn", issue = "123")]
fn deprecated() {}

Expand All @@ -30,7 +30,7 @@ To fix these issues you need to give required key-value pairs.
#![feature(staged_api)]
#![stable(since = "1.0.0", feature = "test")]

#[rustc_deprecated(since = "1.39.0", reason = "reason")] // ok!
#[deprecated(since = "1.39.0", note = "reason")] // ok!
#[unstable(feature = "deprecated_fn", issue = "123")]
fn deprecated() {}

Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_error_codes/src/error_codes/E0542.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ fn _stable_fn() {}
const fn _stable_const_fn() {}

#[stable(feature = "_deprecated_fn", since = "0.1.0")]
#[rustc_deprecated(
reason = "explanation for deprecation"
#[deprecated(
note = "explanation for deprecation"
)] // invalid
fn _deprecated_fn() {}
```
Expand All @@ -32,9 +32,9 @@ fn _stable_fn() {}
const fn _stable_const_fn() {}

#[stable(feature = "_deprecated_fn", since = "0.1.0")]
#[rustc_deprecated(
#[deprecated(
since = "1.0.0",
reason = "explanation for deprecation"
note = "explanation for deprecation"
)] // ok!
fn _deprecated_fn() {}
```
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_error_codes/src/error_codes/E0543.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
The `reason` value is missing in a stability attribute.
The `note` value is missing in a stability attribute.

Erroneous code example:

Expand All @@ -7,22 +7,22 @@ Erroneous code example:
#![stable(since = "1.0.0", feature = "test")]

#[stable(since = "0.1.0", feature = "_deprecated_fn")]
#[rustc_deprecated(
#[deprecated(
since = "1.0.0"
)] // invalid
fn _deprecated_fn() {}
```

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

```
#![feature(staged_api)]
#![stable(since = "1.0.0", feature = "test")]

#[stable(since = "0.1.0", feature = "_deprecated_fn")]
#[rustc_deprecated(
#[deprecated(
since = "1.0.0",
reason = "explanation for deprecation"
note = "explanation for deprecation"
)] // ok!
fn _deprecated_fn() {}
```
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_error_codes/src/error_codes/E0549.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
A `rustc_deprecated` attribute wasn't paired with a `stable`/`unstable`
attribute.
A `deprecated` attribute wasn't paired with a `stable`/`unstable` attribute with
`#![feature(staged_api)]` enabled.

Erroneous code example:

```compile_fail,E0549
#![feature(staged_api)]
#![stable(since = "1.0.0", feature = "test")]

#[rustc_deprecated(
#[deprecated(
since = "1.0.1",
reason = "explanation for deprecation"
note = "explanation for deprecation"
)] // invalid
fn _deprecated_fn() {}
```
Expand All @@ -22,9 +22,9 @@ Example:
#![stable(since = "1.0.0", feature = "test")]

#[stable(since = "1.0.0", feature = "test")]
#[rustc_deprecated(
#[deprecated(
since = "1.0.1",
reason = "explanation for deprecation"
note = "explanation for deprecation"
)] // ok!
fn _deprecated_fn() {}
```
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_error_codes/src/error_codes/E0550.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#### Note: this error code is no longer emitted by the compiler

More than one `deprecated` attribute has been put on an item.

Erroneous code example:

```compile_fail,E0550
```compile_fail
#[deprecated(note = "because why not?")]
#[deprecated(note = "right?")] // error!
fn the_banished() {}
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_error_codes/src/error_codes/E0734.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ A stability attribute has been used outside of the standard library.
Erroneous code example:

```compile_fail,E0734
#[rustc_deprecated(since = "b", reason = "text")] // invalid
#[stable(feature = "a", since = "b")] // invalid
#[unstable(feature = "b", issue = "none")] // invalid
fn foo(){}
Expand Down
7 changes: 3 additions & 4 deletions compiler/rustc_feature/src/builtin_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
List: r#"/*opt*/ since = "version", /*opt*/ note = "reason""#,
NameValueStr: "reason"
),
// This has special duplicate handling in E0550 to handle duplicates with rustc_deprecated
DuplicatesOk
ErrorFollowing
),

// Crate properties:
Expand Down Expand Up @@ -463,10 +462,10 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
// ==========================================================================

ungated!(feature, CrateLevel, template!(List: "name1, name2, ..."), DuplicatesOk),
// DuplicatesOk since it has its own validation
// FIXME(jhpratt) remove this eventually
ungated!(
rustc_deprecated, Normal,
template!(List: r#"since = "version", note = "...""#), DuplicatesOk // See E0550
template!(List: r#"since = "version", note = "...""#), ErrorFollowing
),
// DuplicatesOk since it has its own validation
ungated!(
Expand Down
11 changes: 5 additions & 6 deletions compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2201,13 +2201,12 @@ declare_lint! {
/// used by user code.
///
/// This lint is only enabled in the standard library. It works with the
/// use of `#[rustc_deprecated]` with a `since` field of a version in the
/// future. This allows something to be marked as deprecated in a future
/// version, and then this lint will ensure that the item is no longer
/// used in the standard library. See the [stability documentation] for
/// more details.
/// use of `#[deprecated]` with a `since` field of a version in the future.
/// This allows something to be marked as deprecated in a future version,
/// and then this lint will ensure that the item is no longer used in the
/// standard library. See the [stability documentation] for more details.
///
/// [stability documentation]: https://rustc-dev-guide.rust-lang.org/stability.html#rustc_deprecated
/// [stability documentation]: https://rustc-dev-guide.rust-lang.org/stability.html#deprecated
pub DEPRECATED_IN_FUTURE,
Allow,
"detects use of items that will be deprecated in a future version",
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_middle/src/middle/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ pub fn deprecation_in_effect(depr: &Deprecation) -> bool {
}

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

Expand Down Expand Up @@ -336,7 +335,7 @@ impl<'tcx> TyCtxt<'tcx> {
// topmost deprecation. For example, if a struct is deprecated,
// the use of a field won't be linted.
//
// #[rustc_deprecated] however wants to emit down the whole
// With #![staged_api], we want to emit down the whole
// hierarchy.
let depr_attr = &depr_entry.attr;
if !skip || depr_attr.is_since_rustc_version {
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ impl<T> [T] {
/// ```
#[rustc_allow_incoherent_impl]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_deprecated(since = "1.3.0", reason = "renamed to join")]
#[deprecated(since = "1.3.0", note = "renamed to join")]
pub fn connect<Separator>(&self, sep: Separator) -> <Self as Join<Separator>>::Output
where
Self: Join<Separator>,
Expand Down
4 changes: 2 additions & 2 deletions library/core/src/alloc/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,9 @@ impl Layout {
}

#[stable(feature = "alloc_layout", since = "1.28.0")]
#[rustc_deprecated(
#[deprecated(
since = "1.52.0",
reason = "Name does not follow std convention, use LayoutError",
note = "Name does not follow std convention, use LayoutError",
suggestion = "LayoutError"
)]
pub type LayoutErr = LayoutError;
Expand Down
4 changes: 2 additions & 2 deletions library/core/src/alloc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ pub use self::global::GlobalAlloc;
#[stable(feature = "alloc_layout", since = "1.28.0")]
pub use self::layout::Layout;
#[stable(feature = "alloc_layout", since = "1.28.0")]
#[rustc_deprecated(
#[deprecated(
since = "1.52.0",
reason = "Name does not follow std convention, use LayoutError",
note = "Name does not follow std convention, use LayoutError",
suggestion = "LayoutError"
)]
#[allow(deprecated, deprecated_in_future)]
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/array/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl<T, const N: usize> IntoIterator for [T; N] {
impl<T, const N: usize> IntoIter<T, N> {
/// Creates a new iterator over the given `array`.
#[stable(feature = "array_value_iter", since = "1.51.0")]
#[rustc_deprecated(since = "1.59.0", reason = "use `IntoIterator::into_iter` instead")]
#[deprecated(since = "1.59.0", note = "use `IntoIterator::into_iter` instead")]
pub fn new(array: [T; N]) -> Self {
IntoIterator::into_iter(array)
}
Expand Down
6 changes: 3 additions & 3 deletions library/core/src/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1651,10 +1651,10 @@ impl<'a> Formatter<'a> {
/// Flags for formatting
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_deprecated(
#[deprecated(
since = "1.24.0",
reason = "use the `sign_plus`, `sign_minus`, `alternate`, \
or `sign_aware_zero_pad` methods instead"
note = "use the `sign_plus`, `sign_minus`, `alternate`, \
or `sign_aware_zero_pad` methods instead"
)]
pub fn flags(&self) -> u32 {
self.flags
Expand Down
31 changes: 11 additions & 20 deletions library/core/src/hash/sip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ use crate::ptr;
///
/// See: <https://131002.net/siphash>
#[unstable(feature = "hashmap_internals", issue = "none")]
#[rustc_deprecated(
since = "1.13.0",
reason = "use `std::collections::hash_map::DefaultHasher` instead"
)]
#[deprecated(since = "1.13.0", note = "use `std::collections::hash_map::DefaultHasher` instead")]
#[derive(Debug, Clone, Default)]
#[doc(hidden)]
pub struct SipHasher13 {
Expand All @@ -28,10 +25,7 @@ pub struct SipHasher13 {
///
/// See: <https://131002.net/siphash/>
#[unstable(feature = "hashmap_internals", issue = "none")]
#[rustc_deprecated(
since = "1.13.0",
reason = "use `std::collections::hash_map::DefaultHasher` instead"
)]
#[deprecated(since = "1.13.0", note = "use `std::collections::hash_map::DefaultHasher` instead")]
#[derive(Debug, Clone, Default)]
struct SipHasher24 {
hasher: Hasher<Sip24Rounds>,
Expand All @@ -50,10 +44,7 @@ struct SipHasher24 {
/// it is not intended for cryptographic purposes. As such, all
/// cryptographic uses of this implementation are _strongly discouraged_.
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_deprecated(
since = "1.13.0",
reason = "use `std::collections::hash_map::DefaultHasher` instead"
)]
#[deprecated(since = "1.13.0", note = "use `std::collections::hash_map::DefaultHasher` instead")]
#[derive(Debug, Clone, Default)]
pub struct SipHasher(SipHasher24);

Expand Down Expand Up @@ -153,9 +144,9 @@ impl SipHasher {
/// Creates a new `SipHasher` with the two initial keys set to 0.
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_deprecated(
#[deprecated(
since = "1.13.0",
reason = "use `std::collections::hash_map::DefaultHasher` instead"
note = "use `std::collections::hash_map::DefaultHasher` instead"
)]
#[must_use]
pub fn new() -> SipHasher {
Expand All @@ -165,9 +156,9 @@ impl SipHasher {
/// Creates a `SipHasher` that is keyed off the provided keys.
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_deprecated(
#[deprecated(
since = "1.13.0",
reason = "use `std::collections::hash_map::DefaultHasher` instead"
note = "use `std::collections::hash_map::DefaultHasher` instead"
)]
#[must_use]
pub fn new_with_keys(key0: u64, key1: u64) -> SipHasher {
Expand All @@ -179,9 +170,9 @@ impl SipHasher13 {
/// Creates a new `SipHasher13` with the two initial keys set to 0.
#[inline]
#[unstable(feature = "hashmap_internals", issue = "none")]
#[rustc_deprecated(
#[deprecated(
since = "1.13.0",
reason = "use `std::collections::hash_map::DefaultHasher` instead"
note = "use `std::collections::hash_map::DefaultHasher` instead"
)]
pub fn new() -> SipHasher13 {
SipHasher13::new_with_keys(0, 0)
Expand All @@ -190,9 +181,9 @@ impl SipHasher13 {
/// Creates a `SipHasher13` that is keyed off the provided keys.
#[inline]
#[unstable(feature = "hashmap_internals", issue = "none")]
#[rustc_deprecated(
#[deprecated(
since = "1.13.0",
reason = "use `std::collections::hash_map::DefaultHasher` instead"
note = "use `std::collections::hash_map::DefaultHasher` instead"
)]
pub fn new_with_keys(key0: u64, key1: u64) -> SipHasher13 {
SipHasher13 { hasher: Hasher::new_with_keys(key0, key1) }
Expand Down
5 changes: 1 addition & 4 deletions library/core/src/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,7 @@ use crate::mem;
use crate::sync::atomic::{self, AtomicBool, AtomicI32, AtomicIsize, AtomicU32, Ordering};

#[stable(feature = "drop_in_place", since = "1.8.0")]
#[rustc_deprecated(
reason = "no longer an intrinsic - use `ptr::drop_in_place` directly",
since = "1.52.0"
)]
#[deprecated(note = "no longer an intrinsic - use `ptr::drop_in_place` directly", since = "1.52.0")]
#[inline]
pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
// SAFETY: see `ptr::drop_in_place`
Expand Down
Loading