Skip to content

Rollup of 13 pull requests #93119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 40 commits into from
Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
763703c
Remove redundant check for promoteds
tmiasko Oct 11, 2021
d5a91f3
Use `IndexVec::indices` instead of reimplementing it
tmiasko Oct 11, 2021
c3e71d8
Fix a variant index and variant discriminant confusion
tmiasko Oct 11, 2021
cd626fe
Stabilize -Z print-link-args as --print link-args
joshtriplett Dec 6, 2021
371bd46
Document `--print link-args`
joshtriplett Dec 6, 2021
36a1141
Make message for &T -> &mut T transmute more accurate
5225225 Jan 9, 2022
dc1c39b
rustdoc: decouple stability and const-stability
euclio Dec 9, 2021
c280752
Help optimize out backtraces when disabled
kornelski Jan 17, 2022
a8b7116
change `ct_infer` to a delay_span_bug
lcnr Jan 5, 2022
621e60a
remove unnecessary fixme
lcnr Jan 5, 2022
b2d8f0c
generic_arg_infer: placeholder in signature err
lcnr Jan 5, 2022
cbc6d35
privacy: update `visit_infer`
lcnr Jan 10, 2022
217458b
intra-doc links
lcnr Jan 17, 2022
29a2d6b
intra-doc: Use the impl's assoc item where possible
camelid Jan 8, 2022
2938be6
Correctly handle starts in block doc comments
GuillaumeGomez Jan 18, 2022
06b00ad
Add test for block doc comments
GuillaumeGomez Jan 18, 2022
5ab67bf
Fix CVE-2022-21658 for Windows
ChrisDenton Jan 6, 2022
54e22eb
Fix CVE-2022-21658 for UNIX-like
hkratz Dec 18, 2021
cb748a2
Fix CVE-2022-21658 for WASI
alexcrichton Jan 4, 2022
32080ad
Update std::fs::remove_dir_all documentation
pietroalbini Jan 19, 2022
5c96dcf
Add MaybeUninit::as_bytes
Amanieu Oct 10, 2021
6487845
Properly account for binders in get_impl_future_output_ty
tmandry Dec 21, 2021
5c15ad7
NiceRegionError: Use written return type for async fn
tmandry Nov 20, 2021
698631e
Simplify error reporting code, remove await point wording
tmandry Dec 10, 2021
152e888
Rustdoc mobile: put out-of-band on its own line
jsha Jan 13, 2022
3b10045
:arrow_up: rust-analyzer
lnicola Jan 20, 2022
0a6c9ad
Fix compilation for a few tier 2 targets
hkratz Jan 20, 2022
98cb338
Rollup merge of #89747 - Amanieu:maybeuninit_bytes, r=m-ou-se
matthiaskrgr Jan 20, 2022
d188287
Rollup merge of #89764 - tmiasko:uninhabited-enums, r=wesleywiser
matthiaskrgr Jan 20, 2022
02379e9
Rollup merge of #91606 - joshtriplett:stabilize-print-link-args, r=pn…
matthiaskrgr Jan 20, 2022
405cf20
Rollup merge of #91694 - euclio:stability-improvements, r=GuillaumeGomez
matthiaskrgr Jan 20, 2022
413f490
Rollup merge of #92183 - tmandry:issue-74256, r=estebank
matthiaskrgr Jan 20, 2022
db1253f
Rollup merge of #92582 - lcnr:generic-arg-infer, r=BoxyUwU
matthiaskrgr Jan 20, 2022
1839829
Rollup merge of #92680 - camelid:assoc-item-cleanup, r=petrochenkov
matthiaskrgr Jan 20, 2022
5c10dbd
Rollup merge of #92704 - 5225225:std_mem_transmute_ref_t_mut_t, r=mic…
matthiaskrgr Jan 20, 2022
ed3bf67
Rollup merge of #92861 - jsha:mobile-column-flex, r=GuillaumeGomez
matthiaskrgr Jan 20, 2022
1cb57e2
Rollup merge of #92992 - kornelski:backtraceopt, r=Mark-Simulacrum
matthiaskrgr Jan 20, 2022
6c627d2
Rollup merge of #93038 - GuillaumeGomez:block-doc-comments, r=notriddle
matthiaskrgr Jan 20, 2022
d893b0a
Rollup merge of #93108 - lnicola:rust-analyzer-2022-01-20, r=lnicola
matthiaskrgr Jan 20, 2022
dbc9749
Rollup merge of #93112 - pietroalbini:pa-cve-2022-21658-nightly, r=pi…
matthiaskrgr Jan 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rustdoc: decouple stability and const-stability
  • Loading branch information
euclio committed Jan 13, 2022
commit dc1c39b10ed4650de784e860e2778c3e246f585e
91 changes: 55 additions & 36 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -792,58 +792,77 @@ fn assoc_type(
}
}

/// Writes a span containing the versions at which an item became stable and/or const-stable. For
/// example, if the item became stable at 1.0.0, and const-stable at 1.45.0, this function would
/// write a span containing "1.0.0 (const: 1.45.0)".
///
/// Returns `true` if a stability annotation was rendered.
///
/// Stability and const-stability are considered separately. If the item is unstable, no version
/// will be written. If the item is const-unstable, "const: unstable" will be appended to the
/// span, with a link to the tracking issue if present. If an item's stability or const-stability
/// version matches the version of its enclosing item, that version will be omitted.
///
/// Note that it is possible for an unstable function to be const-stable. In that case, the span
/// will include the const-stable version, but no stable version will be emitted, as a natural
/// consequence of the above rules.
fn render_stability_since_raw(
w: &mut Buffer,
ver: Option<Symbol>,
const_stability: Option<ConstStability>,
containing_ver: Option<Symbol>,
containing_const_ver: Option<Symbol>,
) -> bool {
let ver = ver.filter(|inner| !inner.is_empty());
let stable_version = ver.filter(|inner| !inner.is_empty() && Some(*inner) != containing_ver);

match (ver, const_stability) {
// stable and const stable
(Some(v), Some(ConstStability { level: StabilityLevel::Stable { since }, .. }))
let mut title = String::new();
let mut stability = String::new();

if let Some(ver) = stable_version {
stability.push_str(&ver.as_str());
title.push_str(&format!("Stable since Rust version {}", ver));
}

let const_title_and_stability = match const_stability {
Some(ConstStability { level: StabilityLevel::Stable { since }, .. })
if Some(since) != containing_const_ver =>
{
write!(
w,
"<span class=\"since\" title=\"Stable since Rust version {0}, const since {1}\">{0} (const: {1})</span>",
v, since
);
Some((format!("const since {}", since), format!("const: {}", since)))
}
// stable and const unstable
(
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>",
Some(ConstStability { level: StabilityLevel::Unstable { issue, .. }, feature, .. }) => {
let unstable = if let Some(n) = issue {
format!(
r#"<a href="https://github.com/rust-lang/rust/issues/{}" title="Tracking issue for {}">unstable</a>"#,
n, feature
);
)
} else {
write!(w, "unstable");
}
write!(w, ")</span>");
String::from("unstable")
};

Some((String::from("const unstable"), format!("const: {}", unstable)))
}
// stable
(Some(v), _) if ver != containing_ver => {
write!(
w,
"<span class=\"since\" title=\"Stable since Rust version {0}\">{0}</span>",
v
);
_ => None,
};

if let Some((const_title, const_stability)) = const_title_and_stability {
if !title.is_empty() {
title.push_str(&format!(", {}", const_title));
} else {
title.push_str(&const_title);
}

if !stability.is_empty() {
stability.push_str(&format!(" ({})", const_stability));
} else {
stability.push_str(&const_stability);
}
_ => return false,
}
true

if !stability.is_empty() {
write!(w, r#"<span class="since" title="{}">{}</span>"#, title, stability);
}

!stability.is_empty()
}

fn render_assoc_item(
Expand Down
17 changes: 17 additions & 0 deletions src/test/rustdoc/const-display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,20 @@ impl Foo {
#[rustc_const_stable(feature = "rust1", since = "1.2.0")]
pub const fn stable_impl() -> u32 { 42 }
}

#[stable(feature = "rust1", since = "1.0.0")]
pub struct Bar;

impl Bar {
// Do not show non-const stabilities that are the same as the enclosing item.
// @matches 'foo/struct.Bar.html' '//span[@class="since"]' '^const: 1.2.0$'
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "rust1", since = "1.2.0")]
pub const fn stable_impl() -> u32 { 42 }

// Show const-stability even for unstable functions.
// @matches 'foo/struct.Bar.html' '//span[@class="since"]' '^const: 1.3.0$'
#[unstable(feature = "foo2", issue = "none")]
#[rustc_const_stable(feature = "rust1", since = "1.3.0")]
pub const fn const_stable_unstable() -> u32 { 42 }
}
2 changes: 1 addition & 1 deletion src/test/rustdoc/deref-const-fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub struct Bar;

impl Bar {
// @has - '//*[@id="method.len"]' 'pub const fn len(&self) -> usize'
// @has - '//*[@id="method.len"]//span[@class="since"]' '1.0.0 (const: 1.0.0)'
// @has - '//*[@id="method.len"]//span[@class="since"]' 'const: 1.0.0'
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "rust1", since = "1.0.0")]
pub const fn len(&self) -> usize { 0 }
Expand Down