Rollup merge of #135043 - notriddle:notriddle/allowed-through-unstable-modules-is-a-deprecation-flag, r=GuillaumeGomez

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.

Fixes #131676

Related to #135003

r? ``@GuillaumeGomez``

``@RalfJung`` ``@workingjubilee``
This commit is contained in:
Matthias Krüger 2025-01-03 22:12:44 +01:00 committed by GitHub
commit f0c03f640a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 44 additions and 3 deletions

View file

@ -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 {

View file

@ -107,6 +107,14 @@ 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
&& parent_stability.is_some_and(|stab| 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
}