Skip to content
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

Rollup of 12 pull requests #102121

Merged
merged 28 commits into from
Sep 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b8d2f5c
Don't crate-locally reexport walk functions in tidy
est31 Sep 19, 2022
74e3d99
Adding needs-unwind to nicer-assert-messages compiler ui tests
andrewpollack Sep 19, 2022
5343dc7
Generate sidebar elements for the "All items" page
GuillaumeGomez Sep 20, 2022
4a3109e
Add test for sidebar elements in the "All types" page
GuillaumeGomez Sep 20, 2022
592ae20
Adding needs-unwind to tests involving changing memory size of Future…
andrewpollack Sep 20, 2022
27a420f
Unify generation of section on "All items" page with all other pages
GuillaumeGomez Sep 20, 2022
ad52e32
Adding ignore fuchsia tests for execvp
andrewpollack Sep 20, 2022
84fb168
Avoid panicking on missing fallback
Mark-Simulacrum Sep 17, 2022
c6c4e0f
rustdoc: remove no-op `.method { font-size: 1rem }`
notriddle Sep 20, 2022
04e98b9
rustdoc: remove no-op `.method { position: relative }`
notriddle Sep 20, 2022
e746713
Update books
ehuss Sep 21, 2022
324c10e
Adding needs-unwind for test using panic::catch_unwind
andrewpollack Sep 21, 2022
150623e
Prevent usage of `.stab` elements to create scrollable areas in doc b…
GuillaumeGomez Sep 21, 2022
efbde85
Add doc aliases on Sized trait
GuillaumeGomez Sep 21, 2022
6069f71
Add GUI test for `.stab` elements in docblocks
GuillaumeGomez Sep 21, 2022
6c29716
Adding ignore fuchsia tests for signal cases
andrewpollack Sep 19, 2022
b08c8cb
Rollup merge of #101952 - Mark-Simulacrum:missing-fallback, r=ehuss
JohnTitor Sep 22, 2022
614e18b
Rollup merge of #102030 - est31:tidy_walk_no_reexport, r=Mark-Simulacrum
JohnTitor Sep 22, 2022
5542e50
Rollup merge of #102032 - andrewpollack:bad-signal-compiler-tests, r=…
JohnTitor Sep 22, 2022
d8dc60a
Rollup merge of #102033 - andrewpollack:add-unwind-on-pretty, r=tmandry
JohnTitor Sep 22, 2022
9cbae7d
Rollup merge of #102054 - GuillaumeGomez:sidebar-all-page, r=notriddle
JohnTitor Sep 22, 2022
aa176c1
Rollup merge of #102071 - andrewpollack:add-needs-unwind-for-binary-s…
JohnTitor Sep 22, 2022
6d7ee68
Rollup merge of #102073 - andrewpollack:add-execvp-call-ignore, r=tma…
JohnTitor Sep 22, 2022
dc23618
Rollup merge of #102075 - notriddle:notriddle/content-methods-method,…
JohnTitor Sep 22, 2022
6c47d29
Rollup merge of #102079 - ehuss:update-books, r=ehuss
JohnTitor Sep 22, 2022
3c6dbf9
Rollup merge of #102084 - andrewpollack:add-issue-panic-unwind, r=bjorn3
JohnTitor Sep 22, 2022
9aa3180
Rollup merge of #102100 - GuillaumeGomez:stab-in-docblocks, r=notriddle
JohnTitor Sep 22, 2022
15b4788
Rollup merge of #102102 - GuillaumeGomez:doc-aliases-sized-trait, r=t…
JohnTitor Sep 22, 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
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