Skip to content

Commit a2016aa

Browse files
committed
Auto merge of #135352 - notriddle:notriddle/stability-shown, r=camelid
rustdoc: use import stability marker in display Fixes #135078
2 parents 047bc17 + 916cfbc commit a2016aa

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

src/librustdoc/passes/propagate_stability.rs

+20-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,26 @@ impl DocFolder for StabilityPropagator<'_, '_> {
3636

3737
let stability = match item.item_id {
3838
ItemId::DefId(def_id) => {
39-
let own_stability = self.cx.tcx.lookup_stability(def_id);
39+
let item_stability = self.cx.tcx.lookup_stability(def_id);
40+
let inline_stability =
41+
item.inline_stmt_id.and_then(|did| self.cx.tcx.lookup_stability(did));
42+
let own_stability = if let Some(item_stab) = item_stability
43+
&& let StabilityLevel::Stable { since: _, allowed_through_unstable_modules } =
44+
item_stab.level
45+
&& let Some(mut inline_stab) = inline_stability
46+
&& let StabilityLevel::Stable {
47+
since: inline_since,
48+
allowed_through_unstable_modules: _,
49+
} = inline_stab.level
50+
{
51+
inline_stab.level = StabilityLevel::Stable {
52+
since: inline_since,
53+
allowed_through_unstable_modules,
54+
};
55+
Some(inline_stab)
56+
} else {
57+
item_stability
58+
};
4059

4160
let (ItemKind::StrippedItem(box kind) | kind) = &item.kind;
4261
match kind {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// https://github.com/rust-lang/rust/issues/135078
2+
#![crate_name = "foo"]
3+
#![feature(staged_api)]
4+
#![stable(feature = "v1", since="1.0.0")]
5+
6+
#[stable(feature = "v1", since="1.0.0")]
7+
pub mod ffi {
8+
#[stable(feature = "core_ffi", since="1.99.0")]
9+
//@ has "foo/ffi/struct.CStr.html" "//span[@class='sub-heading']/span[@class='since']" "1.99.0"
10+
//@ !has - "//span[@class='sub-heading']/span[@class='since']" "1.0.0"
11+
pub struct CStr;
12+
}
13+
14+
#[stable(feature = "v1", since = "1.0.0")]
15+
#[doc(inline)]
16+
//@ has "foo/struct.CStr.html" "//span[@class='sub-heading']/span[@class='since']" "1.0.0"
17+
//@ !has - "//span[@class='sub-heading']/span[@class='since']" "1.99.0"
18+
pub use ffi::CStr;

0 commit comments

Comments
 (0)