rustdoc: Elide const-unstable if also unstable overall · rust-lang/rust@fa7a3f9 (original) (raw)
File tree
2 files changed
lines changed
- src/librustdoc/html/render
2 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1016,18 +1016,23 @@ fn render_stability_since_raw_with_extra( | ||
1016 | 1016 | .map(|since |
1017 | 1017 | } |
1018 | 1018 | Some(ConstStability { level: StabilityLevel::Unstable { issue, .. }, feature, .. }) => { |
1019 | -let unstable = if let Some(n) = issue { | |
1020 | -format!( | |
1021 | -"<a \ | |
1019 | +if stable_version.is_none() { | |
1020 | +// don't display const unstable if entirely unstable | |
1021 | +None | |
1022 | +} else { | |
1023 | +let unstable = if let Some(n) = issue { | |
1024 | +format!( | |
1025 | +"<a \ | |
1022 | 1026 | href=\"https://github.com/rust-lang/rust/issues/{n}\\" \ |
1023 | 1027 | title=\"Tracking issue for {feature}\"\ |
1024 | 1028 | >unstable" |
1025 | -) | |
1026 | -} else { | |
1027 | -String::from("unstable") | |
1028 | -}; | |
1029 | + ) | |
1030 | + } else { | |
1031 | + String::from("unstable") | |
1032 | + }; | |
1029 | 1033 | |
1030 | -Some((String::from("const unstable"), format!("const: {unstable}"))) | |
1034 | +Some((String::from("const unstable"), format!("const: {unstable}"))) | |
1035 | +} | |
1031 | 1036 | } |
1032 | 1037 | _ => None, |
1033 | 1038 | }; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -24,6 +24,12 @@ pub const unsafe fn foo_unsafe() -> u32 { 42 } | ||
24 | 24 | #[unstable(feature = "humans", issue = "none")] |
25 | 25 | pub const fn foo2() -> u32 { 42 } |
26 | 26 | |
27 | +// @has 'foo/fn.foo3.html' '//pre' 'pub fn foo3() -> u32' | |
28 | +// @!hasraw - '//span[@class="since"]' | |
29 | +#[unstable(feature = "humans", issue = "none")] | |
30 | +#[rustc_const_unstable(feature = "humans", issue = "none")] | |
31 | +pub const fn foo3() -> u32 { 42 } | |
32 | + | |
27 | 33 | // @has 'foo/fn.bar2.html' '//pre' 'pub const fn bar2() -> u32' |
28 | 34 | // @has - //span '1.0.0 (const: 1.0.0)' |
29 | 35 | #[stable(feature = "rust1", since = "1.0.0")] |