Skip to content

Commit

Permalink
Auto merge of rust-lang#102121 - JohnTitor:rollup-3fb1wrt, r=JohnTitor
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Sep 22, 2022
2 parents 4a4fd12 + 15b4788 commit 626b02a
Show file tree
Hide file tree
Showing 40 changed files with 246 additions and 79 deletions.
1 change: 1 addition & 0 deletions library/core/src/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ impl<T: ?Sized> !Send for *mut T {}
/// ```
///
/// [trait object]: ../../book/ch17-02-trait-objects.html
#[doc(alias = "?", alias = "?Sized")]
#[stable(feature = "rust1", since = "1.0.0")]
#[lang = "sized"]
#[rustc_on_unimplemented(
Expand Down
2 changes: 1 addition & 1 deletion src/doc/embedded-book
Submodule embedded-book updated 1 files
+7 −0 CITATION.bib
2 changes: 1 addition & 1 deletion src/doc/nomicon
Submodule nomicon updated 1 files
+1 −1 src/transmutes.md
24 changes: 16 additions & 8 deletions src/librustdoc/html/render/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use super::print_item::{full_path, item_path, print_item};
use super::search_index::build_index;
use super::write_shared::write_shared;
use super::{
collect_spans_and_sources, print_sidebar, scrape_examples_help, AllTypes, LinkFromSrc, NameDoc,
StylePath, BASIC_KEYWORDS,
collect_spans_and_sources, print_sidebar, scrape_examples_help, sidebar_module_like, AllTypes,
LinkFromSrc, NameDoc, StylePath, BASIC_KEYWORDS,
};

use crate::clean::{self, types::ExternalLocation, ExternalCrate};
Expand Down Expand Up @@ -597,16 +597,24 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
keywords: BASIC_KEYWORDS,
resource_suffix: &shared.resource_suffix,
};
let sidebar = if shared.cache.crate_version.is_some() {
format!("<h2 class=\"location\">Crate {}</h2>", crate_name)
} else {
String::new()
};
let all = shared.all.replace(AllTypes::new());
let mut sidebar = Buffer::html();
if shared.cache.crate_version.is_some() {
write!(sidebar, "<h2 class=\"location\">Crate {}</h2>", crate_name)
};

let mut items = Buffer::html();
sidebar_module_like(&mut items, all.item_sections());
if !items.is_empty() {
sidebar.push_str("<div class=\"sidebar-elems\">");
sidebar.push_buffer(items);
sidebar.push_str("</div>");
}

let v = layout::render(
&shared.layout,
&page,
sidebar,
sidebar.into_inner(),
|buf: &mut Buffer| all.print(buf),
&shared.style_files,
);
Expand Down
124 changes: 88 additions & 36 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,19 +290,66 @@ impl AllTypes {
};
}
}
}

impl AllTypes {
fn item_sections(&self) -> FxHashSet<ItemSection> {
let mut sections = FxHashSet::default();

if !self.structs.is_empty() {
sections.insert(ItemSection::Structs);
}
if !self.enums.is_empty() {
sections.insert(ItemSection::Enums);
}
if !self.unions.is_empty() {
sections.insert(ItemSection::Unions);
}
if !self.primitives.is_empty() {
sections.insert(ItemSection::PrimitiveTypes);
}
if !self.traits.is_empty() {
sections.insert(ItemSection::Traits);
}
if !self.macros.is_empty() {
sections.insert(ItemSection::Macros);
}
if !self.functions.is_empty() {
sections.insert(ItemSection::Functions);
}
if !self.typedefs.is_empty() {
sections.insert(ItemSection::TypeDefinitions);
}
if !self.opaque_tys.is_empty() {
sections.insert(ItemSection::OpaqueTypes);
}
if !self.statics.is_empty() {
sections.insert(ItemSection::Statics);
}
if !self.constants.is_empty() {
sections.insert(ItemSection::Constants);
}
if !self.attributes.is_empty() {
sections.insert(ItemSection::AttributeMacros);
}
if !self.derives.is_empty() {
sections.insert(ItemSection::DeriveMacros);
}
if !self.trait_aliases.is_empty() {
sections.insert(ItemSection::TraitAliases);
}

sections
}

fn print(self, f: &mut Buffer) {
fn print_entries(f: &mut Buffer, e: &FxHashSet<ItemEntry>, title: &str) {
fn print_entries(f: &mut Buffer, e: &FxHashSet<ItemEntry>, kind: ItemSection) {
if !e.is_empty() {
let mut e: Vec<&ItemEntry> = e.iter().collect();
e.sort();
write!(
f,
"<h3 id=\"{}\">{}</h3><ul class=\"all-items\">",
title.replace(' ', "-"), // IDs cannot contain whitespaces.
title
"<h3 id=\"{id}\">{title}</h3><ul class=\"all-items\">",
id = kind.id(),
title = kind.name(),
);

for s in e.iter() {
Expand All @@ -320,20 +367,20 @@ impl AllTypes {
);
// Note: print_entries does not escape the title, because we know the current set of titles
// doesn't require escaping.
print_entries(f, &self.structs, "Structs");
print_entries(f, &self.enums, "Enums");
print_entries(f, &self.unions, "Unions");
print_entries(f, &self.primitives, "Primitives");
print_entries(f, &self.traits, "Traits");
print_entries(f, &self.macros, "Macros");
print_entries(f, &self.attributes, "Attribute Macros");
print_entries(f, &self.derives, "Derive Macros");
print_entries(f, &self.functions, "Functions");
print_entries(f, &self.typedefs, "Typedefs");
print_entries(f, &self.trait_aliases, "Trait Aliases");
print_entries(f, &self.opaque_tys, "Opaque Types");
print_entries(f, &self.statics, "Statics");
print_entries(f, &self.constants, "Constants");
print_entries(f, &self.structs, ItemSection::Structs);
print_entries(f, &self.enums, ItemSection::Enums);
print_entries(f, &self.unions, ItemSection::Unions);
print_entries(f, &self.primitives, ItemSection::PrimitiveTypes);
print_entries(f, &self.traits, ItemSection::Traits);
print_entries(f, &self.macros, ItemSection::Macros);
print_entries(f, &self.attributes, ItemSection::AttributeMacros);
print_entries(f, &self.derives, ItemSection::DeriveMacros);
print_entries(f, &self.functions, ItemSection::Functions);
print_entries(f, &self.typedefs, ItemSection::TypeDefinitions);
print_entries(f, &self.trait_aliases, ItemSection::TraitAliases);
print_entries(f, &self.opaque_tys, ItemSection::OpaqueTypes);
print_entries(f, &self.statics, ItemSection::Statics);
print_entries(f, &self.constants, ItemSection::Constants);
}
}

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

#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
enum ItemSection {
pub(crate) enum ItemSection {
Reexports,
PrimitiveTypes,
Modules,
Expand Down Expand Up @@ -2620,25 +2667,11 @@ fn item_ty_to_section(ty: ItemType) -> ItemSection {
}
}

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

let mut sidebar = String::new();

let item_sections_in_use: FxHashSet<_> = items
.iter()
.filter(|it| {
!it.is_stripped()
&& it
.name
.or_else(|| {
if let clean::ImportItem(ref i) = *it.kind &&
let clean::ImportKind::Simple(s) = i.kind { Some(s) } else { None }
})
.is_some()
})
.map(|it| item_ty_to_section(it.type_()))
.collect();
for &sec in ItemSection::ALL.iter().filter(|sec| item_sections_in_use.contains(sec)) {
let _ = write!(sidebar, "<li><a href=\"#{}\">{}</a></li>", sec.id(), sec.name());
}
Expand All @@ -2656,6 +2689,25 @@ fn sidebar_module(buf: &mut Buffer, items: &[clean::Item]) {
}
}

fn sidebar_module(buf: &mut Buffer, items: &[clean::Item]) {
let item_sections_in_use: FxHashSet<_> = items
.iter()
.filter(|it| {
!it.is_stripped()
&& it
.name
.or_else(|| {
if let clean::ImportItem(ref i) = *it.kind &&
let clean::ImportKind::Simple(s) = i.kind { Some(s) } else { None }
})
.is_some()
})
.map(|it| item_ty_to_section(it.type_()))
.collect();

sidebar_module_like(buf, item_sections_in_use);
}

fn sidebar_foreign_type(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item) {
let mut sidebar = Buffer::new();
sidebar_assoc_items(cx, &mut sidebar, it);
Expand Down
10 changes: 6 additions & 4 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -728,10 +728,6 @@ pre, .rustdoc.source .example-wrap {
padding: 0;
}

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

/* This is to prevent the `.stab` elements to overflow the .docblock elements. */
.docblock .stab {
padding: 0 0.125em;
margin-bottom: 0;
}

/* Black one-pixel outline around emoji shapes */
.emoji {
text-shadow:
Expand Down
21 changes: 21 additions & 0 deletions src/test/rustdoc-gui/check-stab-in-docblock.goml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// This test checks that using `.stab` attributes in `.docblock` elements doesn't
// create scrollable paragraphs.
goto: file://|DOC_PATH|/test_docs/index.html
// Needs the text to be display to check for scrollable content.
show-text: true
size: (786, 600)
// Confirms that there 3 paragraphs.
assert-count: (".top-doc .docblock p", 3)
// Checking that there is no scrollable content.
assert-property: (
".top-doc .docblock p:nth-of-type(1)",
{"scrollHeight": "120", "clientHeight": "120", "scrollWidth": "502", "clientWidth": "502"},
)
assert-property: (
".top-doc .docblock p:nth-of-type(2)",
{"scrollHeight": "48", "clientHeight": "48", "scrollWidth": "502", "clientWidth": "502"},
)
assert-property: (
".top-doc .docblock p:nth-of-type(3)",
{"scrollHeight": "48", "clientHeight": "48", "scrollWidth": "502", "clientWidth": "502"},
)
18 changes: 18 additions & 0 deletions src/test/rustdoc-gui/src/test_docs/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,24 @@
#![feature(rustdoc_internals)]
#![feature(doc_cfg)]

/*!
Enable the feature <span class="stab portability"><code>some-feature</code></span> to enjoy
this crate even more!
Enable the feature <span class="stab portability"><code>some-feature</code></span> to enjoy
this crate even more!
Enable the feature <span class="stab portability"><code>some-feature</code></span> to enjoy
this crate even more!
Also, stop using `bar` as it's <span class="stab deprecated" title="">deprecated</span>.
Also, stop using `bar` as it's <span class="stab deprecated" title="">deprecated</span>.
Also, stop using `bar` as it's <span class="stab deprecated" title="">deprecated</span>.
Finally, you can use `quz` only on <span class="stab portability"><code>Unix or x86-64</code>
</span>.
Finally, you can use `quz` only on <span class="stab portability"><code>Unix or x86-64</code>
</span>.
*/

use std::convert::AsRef;
use std::fmt;

Expand Down
35 changes: 35 additions & 0 deletions src/test/rustdoc/sidebar-all-page.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#![crate_name = "foo"]

#![feature(rustdoc_internals)]

// @has 'foo/all.html'
// @has - '//*[@class="sidebar-elems"]//li' 'Structs'
// @has - '//*[@class="sidebar-elems"]//li' 'Enums'
// @has - '//*[@class="sidebar-elems"]//li' 'Unions'
// @has - '//*[@class="sidebar-elems"]//li' 'Functions'
// @has - '//*[@class="sidebar-elems"]//li' 'Traits'
// @has - '//*[@class="sidebar-elems"]//li' 'Macros'
// @has - '//*[@class="sidebar-elems"]//li' 'Type Definitions'
// @has - '//*[@class="sidebar-elems"]//li' 'Constants'
// @has - '//*[@class="sidebar-elems"]//li' 'Statics'
// @has - '//*[@class="sidebar-elems"]//li' 'Primitive Types'

pub struct Foo;
pub enum Enum {
A,
}
pub union Bar {
a: u8,
b: u16,
}
pub fn foo() {}
pub trait Trait {}
#[macro_export]
macro_rules! foo {
() => {}
}
pub type Type = u8;
pub const FOO: u8 = 0;
pub static BAR: u8 = 0;
#[doc(primitive = "u8")]
mod u8 {}
1 change: 1 addition & 0 deletions src/test/ui/abi/segfault-no-out-of-stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#![allow(unused_imports)]
// ignore-emscripten can't run commands
// ignore-sgx no processes
// ignore-fuchsia must translate zircon signal to SIGSEGV/SIGBUS, FIXME (#58590)
#![feature(rustc_private)]

extern crate libc;
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/abi/stack-probes-lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// ignore-sgx no processes
// ignore-musl FIXME #31506
// ignore-pretty
// ignore-fuchsia no exception handler registered for segfault
// compile-flags: -C lto
// no-prefer-dynamic

Expand Down
1 change: 1 addition & 0 deletions src/test/ui/abi/stack-probes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
// ignore-wasm
// ignore-emscripten no processes
// ignore-sgx no processes
// ignore-fuchsia no exception handler registered for segfault

use std::env;
use std::mem::MaybeUninit;
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/async-await/async-fn-size-moved-locals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// See issue #59123 for a full explanation.

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

// edition:2018
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/async-await/async-fn-size-uninit-locals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// being reflected in the size.

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

// edition:2018
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/command/command-exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// ignore-pretty issue #37199
// ignore-emscripten no processes
// ignore-sgx no processes
// ignore-fuchsia no execvp syscall provided

#![feature(process_exec)]

Expand Down
Loading

0 comments on commit 626b02a

Please sign in to comment.