Skip to content

Commit 6bbf455

Browse files
Mark-Simulacrumpetrochenkov
authored andcommitted
Feature gate is always present
1 parent 20c5044 commit 6bbf455

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

src/librustdoc/clean/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2358,7 +2358,7 @@ impl Clean<Stability> for attr::Stability {
23582358
fn clean(&self, _: &DocContext<'_>) -> Stability {
23592359
Stability {
23602360
level: stability::StabilityLevel::from_attr_level(&self.level),
2361-
feature: Some(self.feature.to_string()).filter(|f| !f.is_empty()),
2361+
feature: self.feature.to_string(),
23622362
since: match self.level {
23632363
attr::Stable { ref since } => since.to_string(),
23642364
_ => String::new(),

src/librustdoc/clean/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1525,7 +1525,7 @@ pub struct ProcMacro {
15251525
#[derive(Clone, Debug)]
15261526
pub struct Stability {
15271527
pub level: stability::StabilityLevel,
1528-
pub feature: Option<String>,
1528+
pub feature: String,
15291529
pub since: String,
15301530
pub unstable_reason: Option<String>,
15311531
pub issue: Option<NonZeroU32>,

src/librustdoc/html/render/mod.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -2126,7 +2126,7 @@ fn stability_tags(item: &clean::Item) -> String {
21262126
if item
21272127
.stability
21282128
.as_ref()
2129-
.map(|s| s.level == stability::Unstable && s.feature.as_deref() != Some("rustc_private"))
2129+
.map(|s| s.level == stability::Unstable && s.feature != "rustc_private")
21302130
== Some(true)
21312131
{
21322132
tags += &tag_html("unstable", "Experimental");
@@ -2177,25 +2177,25 @@ fn short_stability(item: &clean::Item, cx: &Context) -> Vec<String> {
21772177

21782178
// Render unstable items. But don't render "rustc_private" crates (internal compiler crates).
21792179
// Those crates are permanently unstable so it makes no sense to render "unstable" everywhere.
2180-
if let Some(stab) = item.stability.as_ref().filter(|stab| {
2181-
stab.level == stability::Unstable && stab.feature.as_deref() != Some("rustc_private")
2182-
}) {
2180+
if let Some(stab) = item
2181+
.stability
2182+
.as_ref()
2183+
.filter(|stab| stab.level == stability::Unstable && stab.feature != "rustc_private")
2184+
{
21832185
let mut message =
21842186
"<span class='emoji'>🔬</span> This is a nightly-only experimental API.".to_owned();
21852187

2186-
if let Some(feature) = stab.feature.as_deref() {
2187-
let mut feature = format!("<code>{}</code>", Escape(&feature));
2188-
if let (Some(url), Some(issue)) = (&cx.shared.issue_tracker_base_url, stab.issue) {
2189-
feature.push_str(&format!(
2190-
"&nbsp;<a href=\"{url}{issue}\">#{issue}</a>",
2191-
url = url,
2192-
issue = issue
2193-
));
2194-
}
2195-
2196-
message.push_str(&format!(" ({})", feature));
2188+
let mut feature = format!("<code>{}</code>", Escape(&stab.feature));
2189+
if let (Some(url), Some(issue)) = (&cx.shared.issue_tracker_base_url, stab.issue) {
2190+
feature.push_str(&format!(
2191+
"&nbsp;<a href=\"{url}{issue}\">#{issue}</a>",
2192+
url = url,
2193+
issue = issue
2194+
));
21972195
}
21982196

2197+
message.push_str(&format!(" ({})", feature));
2198+
21992199
if let Some(unstable_reason) = &stab.unstable_reason {
22002200
let mut ids = cx.id_map.borrow_mut();
22012201
message = format!(

0 commit comments

Comments
 (0)