diff options
| author | bors <bors@rust-lang.org> | 2025-01-13 04:49:27 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-01-13 04:49:27 +0000 |
| commit | a2016aaba6e3cf99acf1f132883e7b6f09c65ff5 (patch) | |
| tree | ea3930d0db741d0e74161bf689805a78c8d7c4e7 | |
| parent | 047bc17d4ff3b3546187f7f6169eb059e8012b8c (diff) | |
| parent | 916cfbcd3ed95a737b5a62103bbc4118ffe1eb2b (diff) | |
| download | rust-a2016aaba6e3cf99acf1f132883e7b6f09c65ff5.tar.gz rust-a2016aaba6e3cf99acf1f132883e7b6f09c65ff5.zip | |
Auto merge of #135352 - notriddle:notriddle/stability-shown, r=camelid
rustdoc: use import stability marker in display Fixes #135078
| -rw-r--r-- | src/librustdoc/passes/propagate_stability.rs | 21 | ||||
| -rw-r--r-- | tests/rustdoc/inline_local/staged-inline.rs | 18 |
2 files changed, 38 insertions, 1 deletions
diff --git a/src/librustdoc/passes/propagate_stability.rs b/src/librustdoc/passes/propagate_stability.rs index d892c585837..febb52a3b00 100644 --- a/src/librustdoc/passes/propagate_stability.rs +++ b/src/librustdoc/passes/propagate_stability.rs @@ -36,7 +36,26 @@ impl DocFolder for StabilityPropagator<'_, '_> { let stability = match item.item_id { ItemId::DefId(def_id) => { - let own_stability = self.cx.tcx.lookup_stability(def_id); + let item_stability = self.cx.tcx.lookup_stability(def_id); + let inline_stability = + item.inline_stmt_id.and_then(|did| self.cx.tcx.lookup_stability(did)); + let own_stability = if let Some(item_stab) = item_stability + && let StabilityLevel::Stable { since: _, allowed_through_unstable_modules } = + item_stab.level + && let Some(mut inline_stab) = inline_stability + && let StabilityLevel::Stable { + since: inline_since, + allowed_through_unstable_modules: _, + } = inline_stab.level + { + inline_stab.level = StabilityLevel::Stable { + since: inline_since, + allowed_through_unstable_modules, + }; + Some(inline_stab) + } else { + item_stability + }; let (ItemKind::StrippedItem(box kind) | kind) = &item.kind; match kind { diff --git a/tests/rustdoc/inline_local/staged-inline.rs b/tests/rustdoc/inline_local/staged-inline.rs new file mode 100644 index 00000000000..f2131ad5f94 --- /dev/null +++ b/tests/rustdoc/inline_local/staged-inline.rs @@ -0,0 +1,18 @@ +// https://github.com/rust-lang/rust/issues/135078 +#![crate_name = "foo"] +#![feature(staged_api)] +#![stable(feature = "v1", since="1.0.0")] + +#[stable(feature = "v1", since="1.0.0")] +pub mod ffi { + #[stable(feature = "core_ffi", since="1.99.0")] + //@ has "foo/ffi/struct.CStr.html" "//span[@class='sub-heading']/span[@class='since']" "1.99.0" + //@ !has - "//span[@class='sub-heading']/span[@class='since']" "1.0.0" + pub struct CStr; +} + +#[stable(feature = "v1", since = "1.0.0")] +#[doc(inline)] +//@ has "foo/struct.CStr.html" "//span[@class='sub-heading']/span[@class='since']" "1.0.0" +//@ !has - "//span[@class='sub-heading']/span[@class='since']" "1.99.0" +pub use ffi::CStr; |
