rustdoc: Elide const-unstable if also unstable overall · rust-lang/rust@fa7a3f9

File tree

2 files changed

lines changed

  • src/librustdoc/html/render

2 files changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -1016,18 +1016,23 @@ fn render_stability_since_raw_with_extra(

10161016

.map(|since| (format!("const since {since}"), format!("const: {since}")))

10171017

}

10181018

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 \

10221026

href=\"https://github.com/rust-lang/rust/issues/{n}\" \

10231027

title=\"Tracking issue for {feature}\"\

10241028

>unstable</a>"

1025-

)

1026-

} else {

1027-

String::from("unstable")

1028-

};

1029+

)

1030+

} else {

1031+

String::from("unstable")

1032+

};

10291033
1030-

Some((String::from("const unstable"), format!("const: {unstable}")))

1034+

Some((String::from("const unstable"), format!("const: {unstable}")))

1035+

}

10311036

}

10321037

_ => None,

10331038

};

Original file line numberDiff line numberDiff line change

@@ -24,6 +24,12 @@ pub const unsafe fn foo_unsafe() -> u32 { 42 }

2424

#[unstable(feature = "humans", issue = "none")]

2525

pub const fn foo2() -> u32 { 42 }

2626
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+
2733

// @has 'foo/fn.bar2.html' '//pre' 'pub const fn bar2() -> u32'

2834

// @has - //span '1.0.0 (const: 1.0.0)'

2935

#[stable(feature = "rust1", since = "1.0.0")]