"(const: unstable)" for stable-but-const-unstable
This commit is contained in:
parent
39260f6d49
commit
9c495b30ef
@ -42,7 +42,7 @@ use std::str;
|
||||
use std::string::ToString;
|
||||
|
||||
use rustc_ast_pretty::pprust;
|
||||
use rustc_attr::{Deprecation, StabilityLevel};
|
||||
use rustc_attr::{ConstStability, Deprecation, StabilityLevel};
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::CtorKind;
|
||||
@ -826,21 +826,43 @@ fn assoc_type(
|
||||
fn render_stability_since_raw(
|
||||
w: &mut Buffer,
|
||||
ver: Option<&str>,
|
||||
const_ver: Option<&str>,
|
||||
const_stability: Option<&ConstStability>,
|
||||
containing_ver: Option<&str>,
|
||||
containing_const_ver: Option<&str>,
|
||||
) {
|
||||
let ver = ver.filter(|inner| !inner.is_empty());
|
||||
let const_ver = const_ver.filter(|inner| !inner.is_empty());
|
||||
|
||||
match (ver, const_ver) {
|
||||
(Some(v), Some(cv)) if const_ver != containing_const_ver => {
|
||||
match (ver, const_stability) {
|
||||
(Some(v), Some(ConstStability { level: StabilityLevel::Stable { since }, .. }))
|
||||
if Some(since.as_str()).as_deref() != containing_const_ver =>
|
||||
{
|
||||
write!(
|
||||
w,
|
||||
"<span class=\"since\" title=\"Stable since Rust version {0}, const since {1}\">{0} (const: {1})</span>",
|
||||
v, cv
|
||||
v,
|
||||
since.as_str()
|
||||
);
|
||||
}
|
||||
(
|
||||
Some(v),
|
||||
Some(ConstStability { level: StabilityLevel::Unstable { issue, .. }, feature, .. }),
|
||||
) => {
|
||||
write!(
|
||||
w,
|
||||
"<span class=\"since\" title=\"Stable since Rust version {0}, const unstable\">{0} (const: ",
|
||||
v
|
||||
);
|
||||
if let Some(n) = issue {
|
||||
write!(
|
||||
w,
|
||||
"<a href=\"https://github.com/rust-lang/rust/issues/{}\" title=\"Tracking issue for {}\">unstable</a>",
|
||||
n, feature
|
||||
);
|
||||
} else {
|
||||
write!(w, "unstable");
|
||||
}
|
||||
write!(w, ")</span>");
|
||||
}
|
||||
(Some(v), _) if ver != containing_ver => {
|
||||
write!(
|
||||
w,
|
||||
@ -1583,7 +1605,7 @@ fn render_rightside(
|
||||
render_stability_since_raw(
|
||||
w,
|
||||
item.stable_since(tcx).as_deref(),
|
||||
item.const_stable_since(tcx).as_deref(),
|
||||
item.const_stability(tcx),
|
||||
containing_item.stable_since(tcx).as_deref(),
|
||||
containing_item.const_stable_since(tcx).as_deref(),
|
||||
);
|
||||
|
@ -94,7 +94,7 @@ pub(super) fn print_item(cx: &Context<'_>, item: &clean::Item, buf: &mut Buffer,
|
||||
render_stability_since_raw(
|
||||
buf,
|
||||
item.stable_since(cx.tcx()).as_deref(),
|
||||
item.const_stable_since(cx.tcx()).as_deref(),
|
||||
item.const_stability(cx.tcx()),
|
||||
None,
|
||||
None,
|
||||
);
|
||||
@ -1291,7 +1291,7 @@ fn render_stability_since(
|
||||
render_stability_since_raw(
|
||||
w,
|
||||
item.stable_since(tcx).as_deref(),
|
||||
item.const_stable_since(tcx).as_deref(),
|
||||
item.const_stability(tcx),
|
||||
containing_item.stable_since(tcx).as_deref(),
|
||||
containing_item.const_stable_since(tcx).as_deref(),
|
||||
)
|
||||
|
@ -8,6 +8,7 @@
|
||||
#![feature(staged_api)]
|
||||
|
||||
// @has 'foo/fn.foo.html' '//pre' 'pub unsafe fn foo() -> u32'
|
||||
// @has - '//span[@class="since"]' '1.0.0 (const: unstable)'
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature="foo", issue = "none")]
|
||||
pub const unsafe fn foo() -> u32 { 42 }
|
||||
@ -39,6 +40,7 @@ pub struct Foo;
|
||||
|
||||
impl Foo {
|
||||
// @has 'foo/struct.Foo.html' '//div[@id="method.gated"]/code' 'pub unsafe fn gated() -> u32'
|
||||
// @has - '//span[@class="since"]' '1.0.0 (const: unstable)'
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature="foo", issue = "none")]
|
||||
pub const unsafe fn gated() -> u32 { 42 }
|
||||
|
Loading…
x
Reference in New Issue
Block a user