diff options
| -rw-r--r-- | src/librustdoc/html/render/mod.rs | 21 | ||||
| -rw-r--r-- | tests/rustdoc/const-display.rs | 6 |
2 files changed, 19 insertions, 8 deletions
diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index f3ae4b76883..1d0bc328641 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -1016,18 +1016,23 @@ fn render_stability_since_raw_with_extra( .map(|since| (format!("const since {since}"), format!("const: {since}"))) } Some(ConstStability { level: StabilityLevel::Unstable { issue, .. }, feature, .. }) => { - let unstable = if let Some(n) = issue { - format!( - "<a \ + if stable_version.is_none() { + // don't display const unstable if entirely unstable + None + } else { + let unstable = if let Some(n) = issue { + format!( + "<a \ href=\"https://github.com/rust-lang/rust/issues/{n}\" \ title=\"Tracking issue for {feature}\"\ >unstable</a>" - ) - } else { - String::from("unstable") - }; + ) + } else { + String::from("unstable") + }; - Some((String::from("const unstable"), format!("const: {unstable}"))) + Some((String::from("const unstable"), format!("const: {unstable}"))) + } } _ => None, }; diff --git a/tests/rustdoc/const-display.rs b/tests/rustdoc/const-display.rs index c8967f426f0..35665f2aef9 100644 --- a/tests/rustdoc/const-display.rs +++ b/tests/rustdoc/const-display.rs @@ -24,6 +24,12 @@ pub const unsafe fn foo_unsafe() -> u32 { 42 } #[unstable(feature = "humans", issue = "none")] pub const fn foo2() -> u32 { 42 } +// @has 'foo/fn.foo3.html' '//pre' 'pub fn foo3() -> u32' +// @!hasraw - '//span[@class="since"]' +#[unstable(feature = "humans", issue = "none")] +#[rustc_const_unstable(feature = "humans", issue = "none")] +pub const fn foo3() -> u32 { 42 } + // @has 'foo/fn.bar2.html' '//pre' 'pub const fn bar2() -> u32' // @has - //span '1.0.0 (const: 1.0.0)' #[stable(feature = "rust1", since = "1.0.0")] |
