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