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

rustdoc: treat allowed_through_unstable_modules as deprecation #135043

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
22 changes: 21 additions & 1 deletion src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 8 additions & 0 deletions src/librustdoc/passes/propagate_stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
11 changes: 11 additions & 0 deletions tests/rustdoc-js-std/core-transmute.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const FILTER_CRATE = "core";
const EXPECTED = [
{
'query': 'generic:T -> generic:U',
'others': [
{ 'path': 'core::intrinsics::simd', 'name': 'simd_as' },
{ 'path': 'core::intrinsics::simd', 'name': 'simd_cast' },
{ 'path': 'core::mem', 'name': 'transmute' },
],
},
];
3 changes: 2 additions & 1 deletion tests/rustdoc-js-std/transmute-fail.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// should-fail
const FILTER_CRATE = "std";
const EXPECTED = [
{
// Keep this test case identical to `transmute`, except the
Expand All @@ -7,7 +8,7 @@ const EXPECTED = [
'others': [
{ 'path': 'std::intrinsics::simd', 'name': 'simd_as' },
{ 'path': 'std::intrinsics::simd', 'name': 'simd_cast' },
{ 'path': 'std::intrinsics', 'name': 'transmute' },
{ 'path': 'std::mem', 'name': 'transmute' },
],
},
];
3 changes: 2 additions & 1 deletion tests/rustdoc-js-std/transmute.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const FILTER_CRATE = "std";
const EXPECTED = [
{
// Keep this test case identical to `transmute-fail`, except the
Expand All @@ -6,7 +7,7 @@ const EXPECTED = [
'others': [
{ 'path': 'std::intrinsics::simd', 'name': 'simd_as' },
{ 'path': 'std::intrinsics::simd', 'name': 'simd_cast' },
{ 'path': 'std::intrinsics', 'name': 'transmute' },
{ 'path': 'std::mem', 'name': 'transmute' },
],
},
];
Loading