diff options
| author | Michael Howell <michael@notriddle.com> | 2025-01-02 11:58:15 -0700 |
|---|---|---|
| committer | Michael Howell <michael@notriddle.com> | 2025-01-02 12:03:24 -0700 |
| commit | c7cb8224e2020d30df6bceb8ea2e16e7a2594585 (patch) | |
| tree | dfeb2704cf3ee65983388a703fd7a8c1560f2b51 /src | |
| parent | 6ca66598ad63aa73d253f2390e3dbec6ba19ab24 (diff) | |
| download | rust-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')
| -rw-r--r-- | src/librustdoc/clean/types.rs | 22 | ||||
| -rw-r--r-- | src/librustdoc/passes/propagate_stability.rs | 9 |
2 files changed, 30 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 { diff --git a/src/librustdoc/passes/propagate_stability.rs b/src/librustdoc/passes/propagate_stability.rs index 4c682c3d4ca..9e06102bef6 100644 --- a/src/librustdoc/passes/propagate_stability.rs +++ b/src/librustdoc/passes/propagate_stability.rs @@ -107,6 +107,15 @@ fn merge_stability( || parent_stab.stable_since().is_some_and(|parent_since| parent_since > own_since)) { parent_stability + } else if let Some(mut own_stab) = own_stability + && let StabilityLevel::Stable { since, allowed_through_unstable_modules: true } = + own_stab.level + && let Some(parent_stab) = parent_stability + && parent_stab.is_stable() + { + // this property does not apply transitively through re-exports + own_stab.level = StabilityLevel::Stable { since, allowed_through_unstable_modules: false }; + Some(own_stab) } else { own_stability } |
