summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_attr/src/builtin.rs24
-rw-r--r--compiler/rustc_lint_defs/src/builtin.rs9
-rw-r--r--compiler/rustc_middle/src/middle/stability.rs5
-rw-r--r--src/librustdoc/html/render/mod.rs4
-rw-r--r--src/test/rustdoc/deprecated-future-staged-api.rs18
-rw-r--r--src/test/rustdoc/inline_cross/macros.rs3
-rw-r--r--src/test/rustdoc/rustc_deprecated-future.rs18
-rw-r--r--src/test/ui/deprecation/deprecation-in-future.stderr2
-rw-r--r--src/test/ui/deprecation/deprecation-lint.rs2
-rw-r--r--src/test/ui/deprecation/rustc_deprecated.rs13
-rw-r--r--src/test/ui/deprecation/rustc_deprecated.stderr21
11 files changed, 85 insertions, 34 deletions
diff --git a/compiler/rustc_attr/src/builtin.rs b/compiler/rustc_attr/src/builtin.rs
index 8e748aaa58b..466ab82031d 100644
--- a/compiler/rustc_attr/src/builtin.rs
+++ b/compiler/rustc_attr/src/builtin.rs
@@ -687,6 +687,14 @@ where
             break;
         }
 
+        // 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();
+        }
+
         let Some(meta) = attr.meta() else {
             continue;
         };
@@ -742,12 +750,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 {
diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs
index 89ce307d12c..ae8fd026dbc 100644
--- a/compiler/rustc_lint_defs/src/builtin.rs
+++ b/compiler/rustc_lint_defs/src/builtin.rs
@@ -2201,11 +2201,10 @@ 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
     pub DEPRECATED_IN_FUTURE,
diff --git a/compiler/rustc_middle/src/middle/stability.rs b/compiler/rustc_middle/src/middle/stability.rs
index fd6e241346d..22f7c38d097 100644
--- a/compiler/rustc_middle/src/middle/stability.rs
+++ b/compiler/rustc_middle/src/middle/stability.rs
@@ -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;
     }
 
@@ -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 {
diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs
index a4cc42e2a01..27b13a158ad 100644
--- a/src/librustdoc/html/render/mod.rs
+++ b/src/librustdoc/html/render/mod.rs
@@ -659,8 +659,8 @@ fn short_item_info(
     if let Some(depr @ Deprecation { note, since, is_since_rustc_version: _, suggestion: _ }) =
         item.deprecation(cx.tcx())
     {
-        // We display deprecation messages for #[deprecated] and #[rustc_deprecated]
-        // but only display the future-deprecation messages for #[rustc_deprecated].
+        // We display deprecation messages for #[deprecated], but only display
+        // the future-deprecation messages for rustc versions.
         let mut message = if let Some(since) = since {
             let since = since.as_str();
             if !stability::deprecation_in_effect(&depr) {
diff --git a/src/test/rustdoc/deprecated-future-staged-api.rs b/src/test/rustdoc/deprecated-future-staged-api.rs
new file mode 100644
index 00000000000..2670e7f5d04
--- /dev/null
+++ b/src/test/rustdoc/deprecated-future-staged-api.rs
@@ -0,0 +1,18 @@
+#![feature(staged_api)]
+#![stable(feature = "deprecated-future-staged-api", since = "1.0.0")]
+
+// @has deprecated_future_staged_api/index.html '//*[@class="stab deprecated"]' \
+//      'Deprecation planned'
+// @has deprecated_future_staged_api/struct.S1.html '//*[@class="stab deprecated"]' \
+//      'Deprecating in 99.99.99: effectively never'
+#[deprecated(since = "99.99.99", note = "effectively never")]
+#[stable(feature = "deprecated-future-staged-api", since = "1.0.0")]
+pub struct S1;
+
+// @has deprecated_future_staged_api/index.html '//*[@class="stab deprecated"]' \
+//      'Deprecation planned'
+// @has deprecated_future_staged_api/struct.S2.html '//*[@class="stab deprecated"]' \
+//      'Deprecating in a future Rust version: literally never'
+#[deprecated(since = "TBD", note = "literally never")]
+#[stable(feature = "deprecated-future-staged-api", since = "1.0.0")]
+pub struct S2;
diff --git a/src/test/rustdoc/inline_cross/macros.rs b/src/test/rustdoc/inline_cross/macros.rs
index 9cb933c177b..13b4c3c7f61 100644
--- a/src/test/rustdoc/inline_cross/macros.rs
+++ b/src/test/rustdoc/inline_cross/macros.rs
@@ -2,7 +2,6 @@
 // build-aux-docs
 
 #![feature(macro_test)]
-
 #![crate_name = "foo"]
 
 extern crate macros;
@@ -16,5 +15,5 @@ extern crate macros;
 // @has - '//*[@class="docblock"]' 'docs for my_macro'
 // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.2.3: text'
 // @has - '//*[@class="stab unstable"]' 'macro_test'
-// @has - '//a/@href' '../src/macros/macros.rs.html#9-11'
+// @has - '//a/@href' '../src/macros/macros.rs.html#8-10'
 pub use macros::my_macro;
diff --git a/src/test/rustdoc/rustc_deprecated-future.rs b/src/test/rustdoc/rustc_deprecated-future.rs
deleted file mode 100644
index 9bc99d712ec..00000000000
--- a/src/test/rustdoc/rustc_deprecated-future.rs
+++ /dev/null
@@ -1,18 +0,0 @@
-#![feature(staged_api)]
-#![stable(feature = "rustc_deprecated-future-test", since = "1.0.0")]
-
-// @has rustc_deprecated_future/index.html '//*[@class="stab deprecated"]' \
-//      'Deprecation planned'
-// @has rustc_deprecated_future/struct.S1.html '//*[@class="stab deprecated"]' \
-//      'Deprecating in 99.99.99: effectively never'
-#[deprecated(since = "99.99.99", note = "effectively never")]
-#[stable(feature = "rustc_deprecated-future-test", since = "1.0.0")]
-pub struct S1;
-
-// @has rustc_deprecated_future/index.html '//*[@class="stab deprecated"]' \
-//      'Deprecation planned'
-// @has rustc_deprecated_future/struct.S2.html '//*[@class="stab deprecated"]' \
-//      'Deprecating in a future Rust version: literally never'
-#[deprecated(since = "TBD", note = "literally never")]
-#[stable(feature = "rustc_deprecated-future-test", since = "1.0.0")]
-pub struct S2;
diff --git a/src/test/ui/deprecation/deprecation-in-future.stderr b/src/test/ui/deprecation/deprecation-in-future.stderr
index 6561ec74349..99d1c73413a 100644
--- a/src/test/ui/deprecation/deprecation-in-future.stderr
+++ b/src/test/ui/deprecation/deprecation-in-future.stderr
@@ -1,7 +1,7 @@
 warning: use of deprecated function `deprecated_future`: text
   --> $DIR/deprecation-in-future.rs:9:5
    |
-LL |     deprecated_future(); // ok; deprecated_in_future only applies to rustc_deprecated
+LL |     deprecated_future(); // ok; deprecated_in_future only applies with `#![feature(staged_api)]`
    |     ^^^^^^^^^^^^^^^^^
    |
    = note: `#[warn(deprecated)]` on by default
diff --git a/src/test/ui/deprecation/deprecation-lint.rs b/src/test/ui/deprecation/deprecation-lint.rs
index a1a149ab3a0..65cc4e2ef1e 100644
--- a/src/test/ui/deprecation/deprecation-lint.rs
+++ b/src/test/ui/deprecation/deprecation-lint.rs
@@ -260,7 +260,7 @@ mod this_crate {
         <Foo>::trait_deprecated_text(&foo); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text
         <Foo as Trait>::trait_deprecated_text(&foo); //~ ERROR use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text
 
-        // Future deprecations are only permitted for rustc_deprecated.
+        // Future deprecations are only permitted with `#![feature(staged_api)]`
         deprecated_future(); //~ ERROR use of deprecated function
         deprecated_future_text(); //~ ERROR use of deprecated function
 
diff --git a/src/test/ui/deprecation/rustc_deprecated.rs b/src/test/ui/deprecation/rustc_deprecated.rs
new file mode 100644
index 00000000000..b87bd069c60
--- /dev/null
+++ b/src/test/ui/deprecation/rustc_deprecated.rs
@@ -0,0 +1,13 @@
+// compile-flags: --crate-type=lib
+
+#![feature(staged_api)]
+#![stable(since = "1.0.0", feature = "rust1")]
+
+#[rustc_deprecated( //~ ERROR `#[rustc_deprecated]` has been removed
+    //~^ HELP use `#[deprecated]` instead
+    since = "1.100.0",
+    reason = "text" //~ ERROR `reason` has been renamed
+    //~^ HELP use `note` instead
+)]
+#[stable(feature = "rust1", since = "1.0.0")]
+fn foo() {}
diff --git a/src/test/ui/deprecation/rustc_deprecated.stderr b/src/test/ui/deprecation/rustc_deprecated.stderr
new file mode 100644
index 00000000000..4413e196f09
--- /dev/null
+++ b/src/test/ui/deprecation/rustc_deprecated.stderr
@@ -0,0 +1,21 @@
+error: `#[rustc_deprecated]` has been removed
+  --> $DIR/rustc_deprecated.rs:6:1
+   |
+LL | / #[rustc_deprecated(
+LL | |
+LL | |     since = "1.100.0",
+LL | |     reason = "text"
+LL | |
+LL | | )]
+   | |__^
+   |
+   = help: use `#[deprecated]` instead
+
+error: `reason` has been renamed
+  --> $DIR/rustc_deprecated.rs:9:5
+   |
+LL |     reason = "text"
+   |     ^^^^^^^^^^^^^^^ help: use `note` instead: `note = "text"`
+
+error: aborting due to 2 previous errors
+