diff options
| author | Noah Lev <camelidcamel@gmail.com> | 2024-05-25 23:05:27 -0700 |
|---|---|---|
| committer | Noah Lev <camelidcamel@gmail.com> | 2024-05-25 23:05:27 -0700 |
| commit | fa7a3f9049c6d3f781516ca10c163efcf3e01326 (patch) | |
| tree | cafd525a6645a2ad9b4c3a397058ff8b55a122e4 /src/librustdoc/html | |
| parent | 72d8d8d9f91122c59601b52c7f495f4e4dc50e29 (diff) | |
| download | rust-fa7a3f9049c6d3f781516ca10c163efcf3e01326.tar.gz rust-fa7a3f9049c6d3f781516ca10c163efcf3e01326.zip | |
rustdoc: Elide const-unstable if also unstable overall
It's confusing because if a function is unstable overall, there's no need to highlight the constness is also unstable. Technically, these attributes (overall stability and const-stability) are separate, but in practice, we don't even show the const-unstable's feature flag (it's normally the same as the overall function).
Diffstat (limited to 'src/librustdoc/html')
| -rw-r--r-- | src/librustdoc/html/render/mod.rs | 21 |
1 files changed, 13 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, }; |
