Skip to content

Commit 626b02a

Browse files
committed
Auto merge of rust-lang#102121 - JohnTitor:rollup-3fb1wrt, r=JohnTitor
Rollup of 12 pull requests Successful merges: - rust-lang#101952 (Avoid panicking on missing fallback) - rust-lang#102030 (Don't crate-locally reexport walk functions in tidy) - rust-lang#102032 (Adding ignore fuchsia tests for signal interpretation cases) - rust-lang#102033 (Adding needs-unwind to nicer-assert-messages compiler ui tests) - rust-lang#102054 (Unify "all items" page's sidebar with other pages) - rust-lang#102071 (Adding needs-unwind for tests testing memory size of Futures/Closures) - rust-lang#102073 (Adding ignore fuchsia tests for execvp) - rust-lang#102075 (rustdoc: remove no-op CSS `.content > .methods > .method`) - rust-lang#102079 (Update books) - rust-lang#102084 (Adding needs-unwind for test using panic::catch_unwind) - rust-lang#102100 (Prevent usage of .stab elements to create scrollable areas in doc blocks) - rust-lang#102102 (Add doc aliases on Sized trait) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 4a4fd12 + 15b4788 commit 626b02a

40 files changed

+246
-79
lines changed

library/core/src/marker.rs

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ impl<T: ?Sized> !Send for *mut T {}
8181
/// ```
8282
///
8383
/// [trait object]: ../../book/ch17-02-trait-objects.html
84+
#[doc(alias = "?", alias = "?Sized")]
8485
#[stable(feature = "rust1", since = "1.0.0")]
8586
#[lang = "sized"]
8687
#[rustc_on_unimplemented(

src/doc/embedded-book

src/doc/nomicon

src/librustdoc/html/render/context.rs

+16-8
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ use super::print_item::{full_path, item_path, print_item};
1717
use super::search_index::build_index;
1818
use super::write_shared::write_shared;
1919
use super::{
20-
collect_spans_and_sources, print_sidebar, scrape_examples_help, AllTypes, LinkFromSrc, NameDoc,
21-
StylePath, BASIC_KEYWORDS,
20+
collect_spans_and_sources, print_sidebar, scrape_examples_help, sidebar_module_like, AllTypes,
21+
LinkFromSrc, NameDoc, StylePath, BASIC_KEYWORDS,
2222
};
2323

2424
use crate::clean::{self, types::ExternalLocation, ExternalCrate};
@@ -597,16 +597,24 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
597597
keywords: BASIC_KEYWORDS,
598598
resource_suffix: &shared.resource_suffix,
599599
};
600-
let sidebar = if shared.cache.crate_version.is_some() {
601-
format!("<h2 class=\"location\">Crate {}</h2>", crate_name)
602-
} else {
603-
String::new()
604-
};
605600
let all = shared.all.replace(AllTypes::new());
601+
let mut sidebar = Buffer::html();
602+
if shared.cache.crate_version.is_some() {
603+
write!(sidebar, "<h2 class=\"location\">Crate {}</h2>", crate_name)
604+
};
605+
606+
let mut items = Buffer::html();
607+
sidebar_module_like(&mut items, all.item_sections());
608+
if !items.is_empty() {
609+
sidebar.push_str("<div class=\"sidebar-elems\">");
610+
sidebar.push_buffer(items);
611+
sidebar.push_str("</div>");
612+
}
613+
606614
let v = layout::render(
607615
&shared.layout,
608616
&page,
609-
sidebar,
617+
sidebar.into_inner(),
610618
|buf: &mut Buffer| all.print(buf),
611619
&shared.style_files,
612620
);

src/librustdoc/html/render/mod.rs

+88-36
Original file line numberDiff line numberDiff line change
@@ -290,19 +290,66 @@ impl AllTypes {
290290
};
291291
}
292292
}
293-
}
294293

295-
impl AllTypes {
294+
fn item_sections(&self) -> FxHashSet<ItemSection> {
295+
let mut sections = FxHashSet::default();
296+
297+
if !self.structs.is_empty() {
298+
sections.insert(ItemSection::Structs);
299+
}
300+
if !self.enums.is_empty() {
301+
sections.insert(ItemSection::Enums);
302+
}
303+
if !self.unions.is_empty() {
304+
sections.insert(ItemSection::Unions);
305+
}
306+
if !self.primitives.is_empty() {
307+
sections.insert(ItemSection::PrimitiveTypes);
308+
}
309+
if !self.traits.is_empty() {
310+
sections.insert(ItemSection::Traits);
311+
}
312+
if !self.macros.is_empty() {
313+
sections.insert(ItemSection::Macros);
314+
}
315+
if !self.functions.is_empty() {
316+
sections.insert(ItemSection::Functions);
317+
}
318+
if !self.typedefs.is_empty() {
319+
sections.insert(ItemSection::TypeDefinitions);
320+
}
321+
if !self.opaque_tys.is_empty() {
322+
sections.insert(ItemSection::OpaqueTypes);
323+
}
324+
if !self.statics.is_empty() {
325+
sections.insert(ItemSection::Statics);
326+
}
327+
if !self.constants.is_empty() {
328+
sections.insert(ItemSection::Constants);
329+
}
330+
if !self.attributes.is_empty() {
331+
sections.insert(ItemSection::AttributeMacros);
332+
}
333+
if !self.derives.is_empty() {
334+
sections.insert(ItemSection::DeriveMacros);
335+
}
336+
if !self.trait_aliases.is_empty() {
337+
sections.insert(ItemSection::TraitAliases);
338+
}
339+
340+
sections
341+
}
342+
296343
fn print(self, f: &mut Buffer) {
297-
fn print_entries(f: &mut Buffer, e: &FxHashSet<ItemEntry>, title: &str) {
344+
fn print_entries(f: &mut Buffer, e: &FxHashSet<ItemEntry>, kind: ItemSection) {
298345
if !e.is_empty() {
299346
let mut e: Vec<&ItemEntry> = e.iter().collect();
300347
e.sort();
301348
write!(
302349
f,
303-
"<h3 id=\"{}\">{}</h3><ul class=\"all-items\">",
304-
title.replace(' ', "-"), // IDs cannot contain whitespaces.
305-
title
350+
"<h3 id=\"{id}\">{title}</h3><ul class=\"all-items\">",
351+
id = kind.id(),
352+
title = kind.name(),
306353
);
307354

308355
for s in e.iter() {
@@ -320,20 +367,20 @@ impl AllTypes {
320367
);
321368
// Note: print_entries does not escape the title, because we know the current set of titles
322369
// doesn't require escaping.
323-
print_entries(f, &self.structs, "Structs");
324-
print_entries(f, &self.enums, "Enums");
325-
print_entries(f, &self.unions, "Unions");
326-
print_entries(f, &self.primitives, "Primitives");
327-
print_entries(f, &self.traits, "Traits");
328-
print_entries(f, &self.macros, "Macros");
329-
print_entries(f, &self.attributes, "Attribute Macros");
330-
print_entries(f, &self.derives, "Derive Macros");
331-
print_entries(f, &self.functions, "Functions");
332-
print_entries(f, &self.typedefs, "Typedefs");
333-
print_entries(f, &self.trait_aliases, "Trait Aliases");
334-
print_entries(f, &self.opaque_tys, "Opaque Types");
335-
print_entries(f, &self.statics, "Statics");
336-
print_entries(f, &self.constants, "Constants");
370+
print_entries(f, &self.structs, ItemSection::Structs);
371+
print_entries(f, &self.enums, ItemSection::Enums);
372+
print_entries(f, &self.unions, ItemSection::Unions);
373+
print_entries(f, &self.primitives, ItemSection::PrimitiveTypes);
374+
print_entries(f, &self.traits, ItemSection::Traits);
375+
print_entries(f, &self.macros, ItemSection::Macros);
376+
print_entries(f, &self.attributes, ItemSection::AttributeMacros);
377+
print_entries(f, &self.derives, ItemSection::DeriveMacros);
378+
print_entries(f, &self.functions, ItemSection::Functions);
379+
print_entries(f, &self.typedefs, ItemSection::TypeDefinitions);
380+
print_entries(f, &self.trait_aliases, ItemSection::TraitAliases);
381+
print_entries(f, &self.opaque_tys, ItemSection::OpaqueTypes);
382+
print_entries(f, &self.statics, ItemSection::Statics);
383+
print_entries(f, &self.constants, ItemSection::Constants);
337384
}
338385
}
339386

@@ -2468,7 +2515,7 @@ fn sidebar_enum(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item, e: &clean:
24682515
}
24692516

24702517
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
2471-
enum ItemSection {
2518+
pub(crate) enum ItemSection {
24722519
Reexports,
24732520
PrimitiveTypes,
24742521
Modules,
@@ -2620,25 +2667,11 @@ fn item_ty_to_section(ty: ItemType) -> ItemSection {
26202667
}
26212668
}
26222669

2623-
fn sidebar_module(buf: &mut Buffer, items: &[clean::Item]) {
2670+
pub(crate) fn sidebar_module_like(buf: &mut Buffer, item_sections_in_use: FxHashSet<ItemSection>) {
26242671
use std::fmt::Write as _;
26252672

26262673
let mut sidebar = String::new();
26272674

2628-
let item_sections_in_use: FxHashSet<_> = items
2629-
.iter()
2630-
.filter(|it| {
2631-
!it.is_stripped()
2632-
&& it
2633-
.name
2634-
.or_else(|| {
2635-
if let clean::ImportItem(ref i) = *it.kind &&
2636-
let clean::ImportKind::Simple(s) = i.kind { Some(s) } else { None }
2637-
})
2638-
.is_some()
2639-
})
2640-
.map(|it| item_ty_to_section(it.type_()))
2641-
.collect();
26422675
for &sec in ItemSection::ALL.iter().filter(|sec| item_sections_in_use.contains(sec)) {
26432676
let _ = write!(sidebar, "<li><a href=\"#{}\">{}</a></li>", sec.id(), sec.name());
26442677
}
@@ -2656,6 +2689,25 @@ fn sidebar_module(buf: &mut Buffer, items: &[clean::Item]) {
26562689
}
26572690
}
26582691

2692+
fn sidebar_module(buf: &mut Buffer, items: &[clean::Item]) {
2693+
let item_sections_in_use: FxHashSet<_> = items
2694+
.iter()
2695+
.filter(|it| {
2696+
!it.is_stripped()
2697+
&& it
2698+
.name
2699+
.or_else(|| {
2700+
if let clean::ImportItem(ref i) = *it.kind &&
2701+
let clean::ImportKind::Simple(s) = i.kind { Some(s) } else { None }
2702+
})
2703+
.is_some()
2704+
})
2705+
.map(|it| item_ty_to_section(it.type_()))
2706+
.collect();
2707+
2708+
sidebar_module_like(buf, item_sections_in_use);
2709+
}
2710+
26592711
fn sidebar_foreign_type(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item) {
26602712
let mut sidebar = Buffer::new();
26612713
sidebar_assoc_items(cx, &mut sidebar, it);

src/librustdoc/html/static/css/rustdoc.css

+6-4
Original file line numberDiff line numberDiff line change
@@ -728,10 +728,6 @@ pre, .rustdoc.source .example-wrap {
728728
padding: 0;
729729
}
730730

731-
.content > .methods > .method {
732-
font-size: 1rem;
733-
position: relative;
734-
}
735731
/* Shift "where ..." part of method or fn definition down a line */
736732
.content .method .where,
737733
.content .fn .where,
@@ -1092,6 +1088,12 @@ so that we can apply CSS-filters to change the arrow color in themes */
10921088
margin-right: 0.3rem;
10931089
}
10941090

1091+
/* This is to prevent the `.stab` elements to overflow the .docblock elements. */
1092+
.docblock .stab {
1093+
padding: 0 0.125em;
1094+
margin-bottom: 0;
1095+
}
1096+
10951097
/* Black one-pixel outline around emoji shapes */
10961098
.emoji {
10971099
text-shadow:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// This test checks that using `.stab` attributes in `.docblock` elements doesn't
2+
// create scrollable paragraphs.
3+
goto: file://|DOC_PATH|/test_docs/index.html
4+
// Needs the text to be display to check for scrollable content.
5+
show-text: true
6+
size: (786, 600)
7+
// Confirms that there 3 paragraphs.
8+
assert-count: (".top-doc .docblock p", 3)
9+
// Checking that there is no scrollable content.
10+
assert-property: (
11+
".top-doc .docblock p:nth-of-type(1)",
12+
{"scrollHeight": "120", "clientHeight": "120", "scrollWidth": "502", "clientWidth": "502"},
13+
)
14+
assert-property: (
15+
".top-doc .docblock p:nth-of-type(2)",
16+
{"scrollHeight": "48", "clientHeight": "48", "scrollWidth": "502", "clientWidth": "502"},
17+
)
18+
assert-property: (
19+
".top-doc .docblock p:nth-of-type(3)",
20+
{"scrollHeight": "48", "clientHeight": "48", "scrollWidth": "502", "clientWidth": "502"},
21+
)

src/test/rustdoc-gui/src/test_docs/lib.rs

+18
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,24 @@
66
#![feature(rustdoc_internals)]
77
#![feature(doc_cfg)]
88

9+
/*!
10+
Enable the feature <span class="stab portability"><code>some-feature</code></span> to enjoy
11+
this crate even more!
12+
Enable the feature <span class="stab portability"><code>some-feature</code></span> to enjoy
13+
this crate even more!
14+
Enable the feature <span class="stab portability"><code>some-feature</code></span> to enjoy
15+
this crate even more!
16+
17+
Also, stop using `bar` as it's <span class="stab deprecated" title="">deprecated</span>.
18+
Also, stop using `bar` as it's <span class="stab deprecated" title="">deprecated</span>.
19+
Also, stop using `bar` as it's <span class="stab deprecated" title="">deprecated</span>.
20+
21+
Finally, you can use `quz` only on <span class="stab portability"><code>Unix or x86-64</code>
22+
</span>.
23+
Finally, you can use `quz` only on <span class="stab portability"><code>Unix or x86-64</code>
24+
</span>.
25+
*/
26+
927
use std::convert::AsRef;
1028
use std::fmt;
1129

src/test/rustdoc/sidebar-all-page.rs

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#![crate_name = "foo"]
2+
3+
#![feature(rustdoc_internals)]
4+
5+
// @has 'foo/all.html'
6+
// @has - '//*[@class="sidebar-elems"]//li' 'Structs'
7+
// @has - '//*[@class="sidebar-elems"]//li' 'Enums'
8+
// @has - '//*[@class="sidebar-elems"]//li' 'Unions'
9+
// @has - '//*[@class="sidebar-elems"]//li' 'Functions'
10+
// @has - '//*[@class="sidebar-elems"]//li' 'Traits'
11+
// @has - '//*[@class="sidebar-elems"]//li' 'Macros'
12+
// @has - '//*[@class="sidebar-elems"]//li' 'Type Definitions'
13+
// @has - '//*[@class="sidebar-elems"]//li' 'Constants'
14+
// @has - '//*[@class="sidebar-elems"]//li' 'Statics'
15+
// @has - '//*[@class="sidebar-elems"]//li' 'Primitive Types'
16+
17+
pub struct Foo;
18+
pub enum Enum {
19+
A,
20+
}
21+
pub union Bar {
22+
a: u8,
23+
b: u16,
24+
}
25+
pub fn foo() {}
26+
pub trait Trait {}
27+
#[macro_export]
28+
macro_rules! foo {
29+
() => {}
30+
}
31+
pub type Type = u8;
32+
pub const FOO: u8 = 0;
33+
pub static BAR: u8 = 0;
34+
#[doc(primitive = "u8")]
35+
mod u8 {}

src/test/ui/abi/segfault-no-out-of-stack.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#![allow(unused_imports)]
44
// ignore-emscripten can't run commands
55
// ignore-sgx no processes
6+
// ignore-fuchsia must translate zircon signal to SIGSEGV/SIGBUS, FIXME (#58590)
67
#![feature(rustc_private)]
78

89
extern crate libc;

src/test/ui/abi/stack-probes-lto.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// ignore-sgx no processes
1313
// ignore-musl FIXME #31506
1414
// ignore-pretty
15+
// ignore-fuchsia no exception handler registered for segfault
1516
// compile-flags: -C lto
1617
// no-prefer-dynamic
1718

src/test/ui/abi/stack-probes.rs

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
// ignore-wasm
1111
// ignore-emscripten no processes
1212
// ignore-sgx no processes
13+
// ignore-fuchsia no exception handler registered for segfault
1314

1415
use std::env;
1516
use std::mem::MaybeUninit;

src/test/ui/async-await/async-fn-size-moved-locals.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// See issue #59123 for a full explanation.
99

1010
// ignore-emscripten (sizes don't match)
11+
// needs-unwind Size of Futures change on panic=abort
1112
// run-pass
1213

1314
// edition:2018

src/test/ui/async-await/async-fn-size-uninit-locals.rs

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// being reflected in the size.
66

77
// ignore-emscripten (sizes don't match)
8+
// needs-unwind Size of Futures change on panic=abort
89
// run-pass
910

1011
// edition:2018

src/test/ui/command/command-exec.rs

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// ignore-pretty issue #37199
66
// ignore-emscripten no processes
77
// ignore-sgx no processes
8+
// ignore-fuchsia no execvp syscall provided
89

910
#![feature(process_exec)]
1011

0 commit comments

Comments
 (0)