about summary refs log tree commit diff
path: root/src/librustdoc/clean
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2025-01-02 11:58:15 -0700
committerMichael Howell <michael@notriddle.com>2025-01-02 12:03:24 -0700
commitc7cb8224e2020d30df6bceb8ea2e16e7a2594585 (patch)
treedfeb2704cf3ee65983388a703fd7a8c1560f2b51 /src/librustdoc/clean
parent6ca66598ad63aa73d253f2390e3dbec6ba19ab24 (diff)
downloadrust-c7cb8224e2020d30df6bceb8ea2e16e7a2594585.tar.gz
rust-c7cb8224e2020d30df6bceb8ea2e16e7a2594585.zip
rustdoc: treat `allowed_through_unstable_modules` as deprecation
This ensures `std::intrinsics::transmute` is deemphasized
in the search engine and other UI, by cleaning it into a deprecation
without propagating it through reexports when the parent module
is stable.
Diffstat (limited to 'src/librustdoc/clean')
-rw-r--r--src/librustdoc/clean/types.rs22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs
index 3c4fad4bca9..dcee96978d2 100644
--- a/src/librustdoc/clean/types.rs
+++ b/src/librustdoc/clean/types.rs
@@ -400,7 +400,27 @@ impl Item {
     }
 
     pub(crate) fn deprecation(&self, tcx: TyCtxt<'_>) -> Option<Deprecation> {
-        self.def_id().and_then(|did| tcx.lookup_deprecation(did))
+        self.def_id().and_then(|did| tcx.lookup_deprecation(did)).or_else(|| {
+            // `allowed_through_unstable_modules` is a bug-compatibility hack for old rustc
+            // versions; the paths that are exposed through it are "deprecated" because they
+            // were never supposed to work at all.
+            let stab = self.stability(tcx)?;
+            if let rustc_attr_parsing::StabilityLevel::Stable {
+                allowed_through_unstable_modules: true,
+                ..
+            } = stab.level
+            {
+                Some(Deprecation {
+                    // FIXME(#131676, #135003): when a note is added to this stability tag,
+                    // translate it here
+                    since: rustc_attr_parsing::DeprecatedSince::Unspecified,
+                    note: None,
+                    suggestion: None,
+                })
+            } else {
+                None
+            }
+        })
     }
 
     pub(crate) fn inner_docs(&self, tcx: TyCtxt<'_>) -> bool {