From 6bbf4558ac096b6f2cc7cef3920681b8c42e13ef Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sun, 19 Jul 2020 18:20:01 -0400 Subject: [PATCH] Feature gate is always present --- src/librustdoc/clean/mod.rs | 2 +- src/librustdoc/clean/types.rs | 2 +- src/librustdoc/html/render/mod.rs | 30 +++++++++++++++--------------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 3afd3671d6b..801d06e6101 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -2358,7 +2358,7 @@ impl Clean for attr::Stability { fn clean(&self, _: &DocContext<'_>) -> Stability { Stability { level: stability::StabilityLevel::from_attr_level(&self.level), - feature: Some(self.feature.to_string()).filter(|f| !f.is_empty()), + feature: self.feature.to_string(), since: match self.level { attr::Stable { ref since } => since.to_string(), _ => String::new(), diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 50eca75d7ca..627f88df45c 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -1525,7 +1525,7 @@ pub struct ProcMacro { #[derive(Clone, Debug)] pub struct Stability { pub level: stability::StabilityLevel, - pub feature: Option, + pub feature: String, pub since: String, pub unstable_reason: Option, pub issue: Option, diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 4cbc56333b1..54ad4e8f4ec 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -2126,7 +2126,7 @@ fn stability_tags(item: &clean::Item) -> String { if item .stability .as_ref() - .map(|s| s.level == stability::Unstable && s.feature.as_deref() != Some("rustc_private")) + .map(|s| s.level == stability::Unstable && s.feature != "rustc_private") == Some(true) { tags += &tag_html("unstable", "Experimental"); @@ -2177,25 +2177,25 @@ fn short_stability(item: &clean::Item, cx: &Context) -> Vec { // Render unstable items. But don't render "rustc_private" crates (internal compiler crates). // Those crates are permanently unstable so it makes no sense to render "unstable" everywhere. - if let Some(stab) = item.stability.as_ref().filter(|stab| { - stab.level == stability::Unstable && stab.feature.as_deref() != Some("rustc_private") - }) { + if let Some(stab) = item + .stability + .as_ref() + .filter(|stab| stab.level == stability::Unstable && stab.feature != "rustc_private") + { let mut message = "🔬 This is a nightly-only experimental API.".to_owned(); - if let Some(feature) = stab.feature.as_deref() { - let mut feature = format!("{}", Escape(&feature)); - if let (Some(url), Some(issue)) = (&cx.shared.issue_tracker_base_url, stab.issue) { - feature.push_str(&format!( - " #{issue}", - url = url, - issue = issue - )); - } - - message.push_str(&format!(" ({})", feature)); + let mut feature = format!("{}", Escape(&stab.feature)); + if let (Some(url), Some(issue)) = (&cx.shared.issue_tracker_base_url, stab.issue) { + feature.push_str(&format!( + " #{issue}", + url = url, + issue = issue + )); } + message.push_str(&format!(" ({})", feature)); + if let Some(unstable_reason) = &stab.unstable_reason { let mut ids = cx.id_map.borrow_mut(); message = format!(