From b8d2f5cde5d2fb332a74c1974cd8e0a2d69f4f8a Mon Sep 17 00:00:00 2001 From: est31 Date: Mon, 19 Sep 2022 22:33:09 +0200 Subject: [PATCH 01/16] Don't crate-locally reexport walk functions in tidy --- src/tools/tidy/src/bins.rs | 5 +++-- src/tools/tidy/src/debug_artifacts.rs | 3 ++- src/tools/tidy/src/edition.rs | 5 +++-- src/tools/tidy/src/error_codes_check.rs | 3 ++- src/tools/tidy/src/errors.rs | 5 +++-- src/tools/tidy/src/features.rs | 9 +++++---- src/tools/tidy/src/lib.rs | 2 -- src/tools/tidy/src/pal.rs | 3 ++- src/tools/tidy/src/style.rs | 5 +++-- src/tools/tidy/src/target_specific_tests.rs | 2 +- src/tools/tidy/src/ui_tests.rs | 2 +- src/tools/tidy/src/unit_tests.rs | 5 +++-- 12 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/tools/tidy/src/bins.rs b/src/tools/tidy/src/bins.rs index 30903f56d93b0..b898f20a5d018 100644 --- a/src/tools/tidy/src/bins.rs +++ b/src/tools/tidy/src/bins.rs @@ -21,6 +21,7 @@ mod os_impl { #[cfg(unix)] mod os_impl { + use crate::walk::{filter_dirs, walk_no_read}; use std::fs; use std::os::unix::prelude::*; use std::path::Path; @@ -100,10 +101,10 @@ mod os_impl { const ALLOWED: &[&str] = &["configure", "x"]; - crate::walk_no_read( + walk_no_read( path, &mut |path| { - crate::filter_dirs(path) + filter_dirs(path) || path.ends_with("src/etc") // This is a list of directories that we almost certainly // don't need to walk. A future PR will likely want to diff --git a/src/tools/tidy/src/debug_artifacts.rs b/src/tools/tidy/src/debug_artifacts.rs index ab87230f888ca..9880a32ad0c28 100644 --- a/src/tools/tidy/src/debug_artifacts.rs +++ b/src/tools/tidy/src/debug_artifacts.rs @@ -1,5 +1,6 @@ //! Tidy check to prevent creation of unnecessary debug artifacts while running tests. +use crate::walk::{filter_dirs, walk}; use std::path::{Path, PathBuf}; const GRAPHVIZ_POSTFLOW_MSG: &str = "`borrowck_graphviz_postflow` attribute in test"; @@ -7,7 +8,7 @@ const GRAPHVIZ_POSTFLOW_MSG: &str = "`borrowck_graphviz_postflow` attribute in t pub fn check(path: &Path, bad: &mut bool) { let test_dir: PathBuf = path.join("test"); - super::walk(&test_dir, &mut super::filter_dirs, &mut |entry, contents| { + walk(&test_dir, &mut filter_dirs, &mut |entry, contents| { let filename = entry.path(); let is_rust = filename.extension().map_or(false, |ext| ext == "rs"); if !is_rust { diff --git a/src/tools/tidy/src/edition.rs b/src/tools/tidy/src/edition.rs index b0abee459869c..8a7c4460dc7ea 100644 --- a/src/tools/tidy/src/edition.rs +++ b/src/tools/tidy/src/edition.rs @@ -1,5 +1,6 @@ //! Tidy check to ensure that crate `edition` is '2018' or '2021'. +use crate::walk::{filter_dirs, walk}; use std::path::Path; fn is_edition_2021(mut line: &str) -> bool { @@ -8,9 +9,9 @@ fn is_edition_2021(mut line: &str) -> bool { } pub fn check(path: &Path, bad: &mut bool) { - super::walk( + walk( path, - &mut |path| super::filter_dirs(path) || path.ends_with("src/test"), + &mut |path| filter_dirs(path) || path.ends_with("src/test"), &mut |entry, contents| { let file = entry.path(); let filename = file.file_name().unwrap(); diff --git a/src/tools/tidy/src/error_codes_check.rs b/src/tools/tidy/src/error_codes_check.rs index 0a226443e01ca..610e322e12963 100644 --- a/src/tools/tidy/src/error_codes_check.rs +++ b/src/tools/tidy/src/error_codes_check.rs @@ -1,6 +1,7 @@ //! Checks that all error codes have at least one test to prevent having error //! codes that are silently not thrown by the compiler anymore. +use crate::walk::{filter_dirs, walk}; use std::collections::{HashMap, HashSet}; use std::ffi::OsStr; use std::fs::read_to_string; @@ -217,7 +218,7 @@ pub fn check(paths: &[&Path], bad: &mut bool) { println!("Checking which error codes lack tests..."); for path in paths { - super::walk(path, &mut super::filter_dirs, &mut |entry, contents| { + walk(path, &mut filter_dirs, &mut |entry, contents| { let file_name = entry.file_name(); let entry_path = entry.path(); diff --git a/src/tools/tidy/src/errors.rs b/src/tools/tidy/src/errors.rs index dbcc9341a084d..fe5fd72b91a49 100644 --- a/src/tools/tidy/src/errors.rs +++ b/src/tools/tidy/src/errors.rs @@ -3,14 +3,15 @@ //! This ensures that error codes are used at most once and also prints out some //! statistics about the error codes. +use crate::walk::{filter_dirs, walk}; use std::collections::HashMap; use std::path::Path; pub fn check(path: &Path, bad: &mut bool) { let mut map: HashMap<_, Vec<_>> = HashMap::new(); - super::walk( + walk( path, - &mut |path| super::filter_dirs(path) || path.ends_with("src/test"), + &mut |path| filter_dirs(path) || path.ends_with("src/test"), &mut |entry, contents| { let file = entry.path(); let filename = file.file_name().unwrap().to_string_lossy(); diff --git a/src/tools/tidy/src/features.rs b/src/tools/tidy/src/features.rs index b306a527a7ce1..28a0700a64bfd 100644 --- a/src/tools/tidy/src/features.rs +++ b/src/tools/tidy/src/features.rs @@ -9,6 +9,7 @@ //! * All unstable lang features have tests to ensure they are actually unstable. //! * Language features in a group are sorted by feature name. +use crate::walk::{filter_dirs, walk, walk_many}; use std::collections::HashMap; use std::fmt; use std::fs; @@ -92,14 +93,14 @@ pub fn check( let lib_features = get_and_check_lib_features(lib_path, bad, &features); assert!(!lib_features.is_empty()); - super::walk_many( + walk_many( &[ &src_path.join("test/ui"), &src_path.join("test/ui-fulldeps"), &src_path.join("test/rustdoc-ui"), &src_path.join("test/rustdoc"), ], - &mut |path| super::filter_dirs(path), + &mut filter_dirs, &mut |entry, contents| { let file = entry.path(); let filename = file.file_name().unwrap().to_string_lossy(); @@ -466,9 +467,9 @@ fn map_lib_features( base_src_path: &Path, mf: &mut dyn FnMut(Result<(&str, Feature), &str>, &Path, usize), ) { - super::walk( + walk( base_src_path, - &mut |path| super::filter_dirs(path) || path.ends_with("src/test"), + &mut |path| filter_dirs(path) || path.ends_with("src/test"), &mut |entry, contents| { let file = entry.path(); let filename = file.file_name().unwrap().to_string_lossy(); diff --git a/src/tools/tidy/src/lib.rs b/src/tools/tidy/src/lib.rs index 12d3bdcd76f82..e82cca402e2d8 100644 --- a/src/tools/tidy/src/lib.rs +++ b/src/tools/tidy/src/lib.rs @@ -3,8 +3,6 @@ //! This library contains the tidy lints and exposes it //! to be used by tools. -use walk::{filter_dirs, walk, walk_many, walk_no_read}; - /// A helper macro to `unwrap` a result except also print out details like: /// /// * The expression that failed diff --git a/src/tools/tidy/src/pal.rs b/src/tools/tidy/src/pal.rs index 4d86fe8be4e01..f4592fdcff9dc 100644 --- a/src/tools/tidy/src/pal.rs +++ b/src/tools/tidy/src/pal.rs @@ -30,6 +30,7 @@ //! platform-specific cfgs are allowed. Not sure yet how to deal with //! this in the long term. +use crate::walk::{filter_dirs, walk}; use std::iter::Iterator; use std::path::Path; @@ -67,7 +68,7 @@ pub fn check(path: &Path, bad: &mut bool) { // Sanity check that the complex parsing here works. let mut saw_target_arch = false; let mut saw_cfg_bang = false; - super::walk(path, &mut super::filter_dirs, &mut |entry, contents| { + walk(path, &mut filter_dirs, &mut |entry, contents| { let file = entry.path(); let filestr = file.to_string_lossy().replace("\\", "/"); if !filestr.ends_with(".rs") { diff --git a/src/tools/tidy/src/style.rs b/src/tools/tidy/src/style.rs index dee58ff2fb510..541380cebde8d 100644 --- a/src/tools/tidy/src/style.rs +++ b/src/tools/tidy/src/style.rs @@ -16,6 +16,7 @@ //! A number of these checks can be opted-out of with various directives of the form: //! `// ignore-tidy-CHECK-NAME`. +use crate::walk::{filter_dirs, walk}; use regex::Regex; use std::path::Path; @@ -218,13 +219,13 @@ fn is_unexplained_ignore(extension: &str, line: &str) -> bool { pub fn check(path: &Path, bad: &mut bool) { fn skip(path: &Path) -> bool { - super::filter_dirs(path) || skip_markdown_path(path) + filter_dirs(path) || skip_markdown_path(path) } let problematic_consts_strings: Vec = (PROBLEMATIC_CONSTS.iter().map(u32::to_string)) .chain(PROBLEMATIC_CONSTS.iter().map(|v| format!("{:x}", v))) .chain(PROBLEMATIC_CONSTS.iter().map(|v| format!("{:X}", v))) .collect(); - super::walk(path, &mut skip, &mut |entry, contents| { + walk(path, &mut skip, &mut |entry, contents| { let file = entry.path(); let filename = file.file_name().unwrap().to_string_lossy(); let extensions = [".rs", ".py", ".js", ".sh", ".c", ".cpp", ".h", ".md", ".css", ".ftl"]; diff --git a/src/tools/tidy/src/target_specific_tests.rs b/src/tools/tidy/src/target_specific_tests.rs index 723684bfa4cda..8ba25705666a9 100644 --- a/src/tools/tidy/src/target_specific_tests.rs +++ b/src/tools/tidy/src/target_specific_tests.rs @@ -36,7 +36,7 @@ struct RevisionInfo<'a> { pub fn check(path: &Path, bad: &mut bool) { let tests = path.join("test"); - super::walk( + crate::walk::walk( &tests, &mut |path| path.extension().map(|p| p == "rs") == Some(false), &mut |entry, content| { diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index 8ec5c33249333..969d5fec60f37 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -47,7 +47,7 @@ fn check_entries(path: &Path, bad: &mut bool) { pub fn check(path: &Path, bad: &mut bool) { check_entries(&path, bad); for path in &[&path.join("test/ui"), &path.join("test/ui-fulldeps")] { - super::walk_no_read(path, &mut |_| false, &mut |entry| { + crate::walk::walk_no_read(path, &mut |_| false, &mut |entry| { let file_path = entry.path(); if let Some(ext) = file_path.extension() { if ext == "stderr" || ext == "stdout" { diff --git a/src/tools/tidy/src/unit_tests.rs b/src/tools/tidy/src/unit_tests.rs index f675b78651ef9..2c23b6ebc75e2 100644 --- a/src/tools/tidy/src/unit_tests.rs +++ b/src/tools/tidy/src/unit_tests.rs @@ -7,6 +7,7 @@ //! named `tests.rs` or `benches.rs`, or directories named `tests` or `benches` unconfigured //! during normal build. +use crate::walk::{filter_dirs, walk}; use std::path::Path; pub fn check(root_path: &Path, bad: &mut bool) { @@ -20,7 +21,7 @@ pub fn check(root_path: &Path, bad: &mut bool) { let mut skip = |path: &Path| { let file_name = path.file_name().unwrap_or_default(); if path.is_dir() { - super::filter_dirs(path) + filter_dirs(path) || path.ends_with("src/test") || path.ends_with("src/doc") || (file_name == "tests" || file_name == "benches") && !is_core(path) @@ -34,7 +35,7 @@ pub fn check(root_path: &Path, bad: &mut bool) { } }; - super::walk(root_path, &mut skip, &mut |entry, contents| { + walk(root_path, &mut skip, &mut |entry, contents| { let path = entry.path(); let is_core = path.starts_with(core); for (i, line) in contents.lines().enumerate() { From 74e3d9903695236bbff39edcfc1516671c1632a1 Mon Sep 17 00:00:00 2001 From: Andrew Pollack Date: Mon, 19 Sep 2022 21:43:21 +0000 Subject: [PATCH 02/16] Adding needs-unwind to nicer-assert-messages compiler ui tests --- .../ui/macros/rfc-2011-nicer-assert-messages/all-expr-kinds.rs | 1 + .../rfc-2011-nicer-assert-messages/all-not-available-cases.rs | 1 + .../assert-without-captures-does-not-create-unnecessary-code.rs | 1 + 3 files changed, 3 insertions(+) diff --git a/src/test/ui/macros/rfc-2011-nicer-assert-messages/all-expr-kinds.rs b/src/test/ui/macros/rfc-2011-nicer-assert-messages/all-expr-kinds.rs index f538ec643902e..b8b6f0846bb44 100644 --- a/src/test/ui/macros/rfc-2011-nicer-assert-messages/all-expr-kinds.rs +++ b/src/test/ui/macros/rfc-2011-nicer-assert-messages/all-expr-kinds.rs @@ -2,6 +2,7 @@ // ignore-tidy-linelength // only-x86_64 // run-pass +// needs-unwind Asserting on contents of error message #![allow(path_statements, unused_allocation)] #![feature(box_syntax, core_intrinsics, generic_assert, generic_assert_internals)] diff --git a/src/test/ui/macros/rfc-2011-nicer-assert-messages/all-not-available-cases.rs b/src/test/ui/macros/rfc-2011-nicer-assert-messages/all-not-available-cases.rs index 86697c58fbcf1..d46f396ee2970 100644 --- a/src/test/ui/macros/rfc-2011-nicer-assert-messages/all-not-available-cases.rs +++ b/src/test/ui/macros/rfc-2011-nicer-assert-messages/all-not-available-cases.rs @@ -2,6 +2,7 @@ // ignore-tidy-linelength // only-x86_64 // run-pass +// needs-unwind Asserting on contents of error message #![feature(core_intrinsics, generic_assert, generic_assert_internals)] diff --git a/src/test/ui/macros/rfc-2011-nicer-assert-messages/assert-without-captures-does-not-create-unnecessary-code.rs b/src/test/ui/macros/rfc-2011-nicer-assert-messages/assert-without-captures-does-not-create-unnecessary-code.rs index 06c4993ec30d6..1f5a29ab524f2 100644 --- a/src/test/ui/macros/rfc-2011-nicer-assert-messages/assert-without-captures-does-not-create-unnecessary-code.rs +++ b/src/test/ui/macros/rfc-2011-nicer-assert-messages/assert-without-captures-does-not-create-unnecessary-code.rs @@ -1,6 +1,7 @@ // aux-build:common.rs // only-x86_64 // run-pass +// needs-unwind Asserting on contents of error message #![feature(core_intrinsics, generic_assert, generic_assert_internals)] From 5343dc7c99f8c3d64658e4c7011dd871b2033e3d Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 20 Sep 2022 16:46:06 +0200 Subject: [PATCH 03/16] Generate sidebar elements for the "All items" page --- src/librustdoc/html/render/context.rs | 24 +++++--- src/librustdoc/html/render/mod.rs | 88 +++++++++++++++++++++------ 2 files changed, 86 insertions(+), 26 deletions(-) diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs index 62def4a94e8dc..22a6fcd316aa0 100644 --- a/src/librustdoc/html/render/context.rs +++ b/src/librustdoc/html/render/context.rs @@ -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}; @@ -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!("

Crate {}

", 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, "

Crate {}

", crate_name) + }; + + let mut items = Buffer::html(); + sidebar_module_like(&mut items, all.item_sections()); + if !items.is_empty() { + sidebar.push_str("
"); + sidebar.push_buffer(items); + sidebar.push_str("
"); + } + let v = layout::render( &shared.layout, &page, - sidebar, + sidebar.into_inner(), |buf: &mut Buffer| all.print(buf), &shared.style_files, ); diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index ced0ebdbb864a..fbe905fb0336e 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -290,9 +290,56 @@ impl AllTypes { }; } } -} -impl AllTypes { + fn item_sections(&self) -> FxHashSet { + 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, title: &str) { if !e.is_empty() { @@ -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, @@ -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) { 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, "
  • {}
  • ", sec.id(), sec.name()); } @@ -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); From 4a3109e8b7a30f18ef8a98308b5e9adadf2e40a9 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 20 Sep 2022 17:10:38 +0200 Subject: [PATCH 04/16] Add test for sidebar elements in the "All types" page --- src/test/rustdoc/sidebar-all-page.rs | 35 ++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/test/rustdoc/sidebar-all-page.rs diff --git a/src/test/rustdoc/sidebar-all-page.rs b/src/test/rustdoc/sidebar-all-page.rs new file mode 100644 index 0000000000000..e74b981de6444 --- /dev/null +++ b/src/test/rustdoc/sidebar-all-page.rs @@ -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 {} From 592ae2073b7498adf3948d53017907bbbb0c00d1 Mon Sep 17 00:00:00 2001 From: Andrew Pollack Date: Tue, 20 Sep 2022 19:46:27 +0000 Subject: [PATCH 05/16] Adding needs-unwind to tests involving changing memory size of Futures/Closures --- src/test/ui/async-await/async-fn-size-moved-locals.rs | 1 + src/test/ui/async-await/async-fn-size-uninit-locals.rs | 1 + src/test/ui/generator/size-moved-locals.rs | 1 + 3 files changed, 3 insertions(+) diff --git a/src/test/ui/async-await/async-fn-size-moved-locals.rs b/src/test/ui/async-await/async-fn-size-moved-locals.rs index 15566256600df..9e3794b0484e7 100644 --- a/src/test/ui/async-await/async-fn-size-moved-locals.rs +++ b/src/test/ui/async-await/async-fn-size-moved-locals.rs @@ -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 diff --git a/src/test/ui/async-await/async-fn-size-uninit-locals.rs b/src/test/ui/async-await/async-fn-size-uninit-locals.rs index 28b3280fed5f6..5461726935457 100644 --- a/src/test/ui/async-await/async-fn-size-uninit-locals.rs +++ b/src/test/ui/async-await/async-fn-size-uninit-locals.rs @@ -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 diff --git a/src/test/ui/generator/size-moved-locals.rs b/src/test/ui/generator/size-moved-locals.rs index 3c756a86fc5a5..601a314182876 100644 --- a/src/test/ui/generator/size-moved-locals.rs +++ b/src/test/ui/generator/size-moved-locals.rs @@ -12,6 +12,7 @@ // edition:2018 // ignore-wasm32 issue #62807 // ignore-asmjs issue #62807 +// needs-unwind Size of Closures change on panic=abort #![feature(generators, generator_trait)] From 27a420f251d8efe5674176cda77032a859eddfb5 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 20 Sep 2022 23:23:03 +0200 Subject: [PATCH 06/16] Unify generation of section on "All items" page with all other pages --- src/librustdoc/html/render/mod.rs | 36 +++++++++++++++---------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index fbe905fb0336e..7e5e4df43d291 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -341,15 +341,15 @@ impl AllTypes { } fn print(self, f: &mut Buffer) { - fn print_entries(f: &mut Buffer, e: &FxHashSet, title: &str) { + fn print_entries(f: &mut Buffer, e: &FxHashSet, kind: ItemSection) { if !e.is_empty() { let mut e: Vec<&ItemEntry> = e.iter().collect(); e.sort(); write!( f, - "

    {}

      ", - title.replace(' ', "-"), // IDs cannot contain whitespaces. - title + "

      {title}

        ", + id = kind.id(), + title = kind.name(), ); for s in e.iter() { @@ -367,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); } } From ad52e325c650556ca9d7476fb0d0e23e45d2b9ae Mon Sep 17 00:00:00 2001 From: Andrew Pollack Date: Tue, 20 Sep 2022 21:37:08 +0000 Subject: [PATCH 07/16] Adding ignore fuchsia tests for execvp --- src/test/ui/command/command-exec.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/ui/command/command-exec.rs b/src/test/ui/command/command-exec.rs index 0af87214f9523..032dad1840d47 100644 --- a/src/test/ui/command/command-exec.rs +++ b/src/test/ui/command/command-exec.rs @@ -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)] From 84fb168d7f0f143fc9d666cc6de757c3d0949ced Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sat, 17 Sep 2022 18:13:59 -0400 Subject: [PATCH 08/16] Avoid panicking on missing fallback This just prints a message but continues on if a fallback is missing, which can happen when we're building a partial set of builders and producing a dev-static build from it (e.g., when no Apple builder runs at all). Probably the more extensive fix is to allow the build-manifest invoker to specify the expected set of targets & hosts, but that's a far more extensive change. The main risk from this is that we accidentally start falling back to linux docs across all platforms without noticing. I'm not sure that we can do much about that though at this time. --- src/tools/build-manifest/src/main.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 1a6760d8c68b9..bf07cd75cab56 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -543,8 +543,18 @@ impl Builder { for (substr, fallback_target) in fallback { if target_name.contains(substr) { let t = Target::from_compressed_tar(self, &tarball_name!(fallback_target)); - // Fallbacks must always be available. - assert!(t.available); + // Fallbacks should typically be available on 'production' builds + // but may not be available for try builds, which only build one target by + // default. Ideally we'd gate this being a hard error on whether we're in a + // production build or not, but it's not information that's readily available + // here. + if !t.available { + eprintln!( + "{:?} not available for fallback", + tarball_name!(fallback_target) + ); + continue; + } return t; } } From c6c4e0f4384cc2416877b0731452119ae355d22b Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Tue, 20 Sep 2022 16:15:54 -0700 Subject: [PATCH 09/16] rustdoc: remove no-op `.method { font-size: 1rem }` This rule was added in 22dad4b0440b184568956c10f2cbedabf763065a, back when the `method` class was attached to headers instead of DIVs that wrap headers. Old method rendering: https://github.com/rust-lang/rust/blob/a96247bcac385671757034bd928c13097fd2ce76/src/librustdoc/html/render.rs#L2062 Current method rendering: https://github.com/rust-lang/rust/blob/432abd86f231c908f6df3cdd779e83f35084be90/src/librustdoc/html/render/print_item.rs#L721 --- src/librustdoc/html/static/css/rustdoc.css | 1 - 1 file changed, 1 deletion(-) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index e985e6c43ade9..d9e5f77ef0a2b 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -729,7 +729,6 @@ pre, .rustdoc.source .example-wrap { } .content > .methods > .method { - font-size: 1rem; position: relative; } /* Shift "where ..." part of method or fn definition down a line */ From 04e98b9025f8b637fb5e67b0a697e324e6aebc66 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Tue, 20 Sep 2022 16:16:17 -0700 Subject: [PATCH 10/16] rustdoc: remove no-op `.method { position: relative }` This rule was added in 88fe6dfa31a1bee49090dc72c537c5cd7bd632f4 to assist in position the hide/show togges on methods. This is no longer needed, because these toggles are no longer implemented as absolutely positioned links nested inside headers. --- src/librustdoc/html/static/css/rustdoc.css | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index d9e5f77ef0a2b..ec00dabbf4316 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -728,9 +728,6 @@ pre, .rustdoc.source .example-wrap { padding: 0; } -.content > .methods > .method { - position: relative; -} /* Shift "where ..." part of method or fn definition down a line */ .content .method .where, .content .fn .where, From e7467132ef44bbd3be7805bd518b778e79adacd1 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Tue, 20 Sep 2022 17:04:55 -0700 Subject: [PATCH 11/16] Update books --- src/doc/book | 2 +- src/doc/embedded-book | 2 +- src/doc/nomicon | 2 +- src/doc/reference | 2 +- src/doc/rust-by-example | 2 +- src/doc/rustc-dev-guide | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/doc/book b/src/doc/book index 0a5421ceb2383..f1e5ad844d0c6 160000 --- a/src/doc/book +++ b/src/doc/book @@ -1 +1 @@ -Subproject commit 0a5421ceb238357b3634fb75234eba4d1dad643c +Subproject commit f1e5ad844d0c61738006cdef26227beeb136948e diff --git a/src/doc/embedded-book b/src/doc/embedded-book index befe684087431..4ce51cb7441a6 160000 --- a/src/doc/embedded-book +++ b/src/doc/embedded-book @@ -1 +1 @@ -Subproject commit befe6840874311635c417cf731377f07234ee373 +Subproject commit 4ce51cb7441a6f02b5bf9b07b2eb755c21ab7954 diff --git a/src/doc/nomicon b/src/doc/nomicon index d880e6ac2acf1..f53bfa0569292 160000 --- a/src/doc/nomicon +++ b/src/doc/nomicon @@ -1 +1 @@ -Subproject commit d880e6ac2acf133dce640da24b9fb692844f02d4 +Subproject commit f53bfa056929217870a5d2df1366d2e7ba35096d diff --git a/src/doc/reference b/src/doc/reference index f62e93c28323e..a7cdac33ca735 160000 --- a/src/doc/reference +++ b/src/doc/reference @@ -1 +1 @@ -Subproject commit f62e93c28323ed9637d0a205a0c256498674a509 +Subproject commit a7cdac33ca7356ad49d5c2b5e2c5010889b33eee diff --git a/src/doc/rust-by-example b/src/doc/rust-by-example index 03301f8ae55fa..767a6bd9727a5 160000 --- a/src/doc/rust-by-example +++ b/src/doc/rust-by-example @@ -1 +1 @@ -Subproject commit 03301f8ae55fa6f20f7ea152a517598e6db2cdb7 +Subproject commit 767a6bd9727a596d7cfdbaeee475e65b2670ea3a diff --git a/src/doc/rustc-dev-guide b/src/doc/rustc-dev-guide index 04892c1a6fc14..f587d6e7cddea 160000 --- a/src/doc/rustc-dev-guide +++ b/src/doc/rustc-dev-guide @@ -1 +1 @@ -Subproject commit 04892c1a6fc145602ac7367945fda9d4ee83c9fb +Subproject commit f587d6e7cddeaa3cf0a33ec1e368df1a408fa0aa From 324c10e72f18c336433fe2664ebc63119b607ffb Mon Sep 17 00:00:00 2001 From: Andrew Pollack Date: Wed, 21 Sep 2022 00:54:23 +0000 Subject: [PATCH 12/16] Adding needs-unwind for test using panic::catch_unwind --- src/test/ui/issues/issue-87707.rs | 1 + src/test/ui/issues/issue-87707.run.stderr | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/test/ui/issues/issue-87707.rs b/src/test/ui/issues/issue-87707.rs index 26e9e2c8f91cf..c14e52dfe4cf4 100644 --- a/src/test/ui/issues/issue-87707.rs +++ b/src/test/ui/issues/issue-87707.rs @@ -3,6 +3,7 @@ // run-fail // exec-env:RUST_BACKTRACE=0 // check-run-results +// needs-unwind uses catch_unwind use std::sync::Once; use std::panic; diff --git a/src/test/ui/issues/issue-87707.run.stderr b/src/test/ui/issues/issue-87707.run.stderr index e6c9ea0eb53c3..527c78ba89e91 100644 --- a/src/test/ui/issues/issue-87707.run.stderr +++ b/src/test/ui/issues/issue-87707.run.stderr @@ -1,3 +1,3 @@ -thread 'main' panicked at 'Here Once instance is poisoned.', $DIR/issue-87707.rs:13:24 +thread 'main' panicked at 'Here Once instance is poisoned.', $DIR/issue-87707.rs:14:24 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace -thread 'main' panicked at 'Once instance has previously been poisoned', $DIR/issue-87707.rs:15:7 +thread 'main' panicked at 'Once instance has previously been poisoned', $DIR/issue-87707.rs:16:7 From 150623eb6c0084042623f521c052694bd6718e2d Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 21 Sep 2022 16:08:29 +0200 Subject: [PATCH 13/16] Prevent usage of `.stab` elements to create scrollable areas in doc blocks --- src/librustdoc/html/static/css/rustdoc.css | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index b4f5bf933a6e3..0a95c81aa72cc 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -1102,6 +1102,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: From efbde853af6733e57dad7877c2c98401a9a704ed Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 21 Sep 2022 16:20:15 +0200 Subject: [PATCH 14/16] Add doc aliases on Sized trait --- library/core/src/marker.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/library/core/src/marker.rs b/library/core/src/marker.rs index b8239ed88acca..40a7b69619305 100644 --- a/library/core/src/marker.rs +++ b/library/core/src/marker.rs @@ -81,6 +81,7 @@ impl !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( From 6069f71e6c6d40bf72a7751450d91fa9b91ba6fa Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 21 Sep 2022 16:08:54 +0200 Subject: [PATCH 15/16] Add GUI test for `.stab` elements in docblocks --- .../rustdoc-gui/check-stab-in-docblock.goml | 21 +++++++++++++++++++ src/test/rustdoc-gui/src/test_docs/lib.rs | 18 ++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 src/test/rustdoc-gui/check-stab-in-docblock.goml diff --git a/src/test/rustdoc-gui/check-stab-in-docblock.goml b/src/test/rustdoc-gui/check-stab-in-docblock.goml new file mode 100644 index 0000000000000..7f965ada594d8 --- /dev/null +++ b/src/test/rustdoc-gui/check-stab-in-docblock.goml @@ -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"}, +) diff --git a/src/test/rustdoc-gui/src/test_docs/lib.rs b/src/test/rustdoc-gui/src/test_docs/lib.rs index 4eedf7f15c3d4..f4c2dadea6d0d 100644 --- a/src/test/rustdoc-gui/src/test_docs/lib.rs +++ b/src/test/rustdoc-gui/src/test_docs/lib.rs @@ -6,6 +6,24 @@ #![feature(rustdoc_internals)] #![feature(doc_cfg)] +/*! +Enable the feature some-feature to enjoy +this crate even more! +Enable the feature some-feature to enjoy +this crate even more! +Enable the feature some-feature to enjoy +this crate even more! + +Also, stop using `bar` as it's deprecated. +Also, stop using `bar` as it's deprecated. +Also, stop using `bar` as it's deprecated. + +Finally, you can use `quz` only on Unix or x86-64 +. +Finally, you can use `quz` only on Unix or x86-64 +. +*/ + use std::convert::AsRef; use std::fmt; From 6c29716d0a871adc3c314e462c5435df62a6f1eb Mon Sep 17 00:00:00 2001 From: Andrew Pollack Date: Mon, 19 Sep 2022 21:02:42 +0000 Subject: [PATCH 16/16] Adding ignore fuchsia tests for signal cases --- src/test/ui/abi/segfault-no-out-of-stack.rs | 1 + src/test/ui/abi/stack-probes-lto.rs | 1 + src/test/ui/abi/stack-probes.rs | 1 + src/test/ui/process/signal-exit-status.rs | 1 + src/test/ui/runtime/out-of-stack.rs | 1 + 5 files changed, 5 insertions(+) diff --git a/src/test/ui/abi/segfault-no-out-of-stack.rs b/src/test/ui/abi/segfault-no-out-of-stack.rs index ad4faf95a0f95..ab2b308948509 100644 --- a/src/test/ui/abi/segfault-no-out-of-stack.rs +++ b/src/test/ui/abi/segfault-no-out-of-stack.rs @@ -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; diff --git a/src/test/ui/abi/stack-probes-lto.rs b/src/test/ui/abi/stack-probes-lto.rs index 90df1f3f53e80..74b5e843f7742 100644 --- a/src/test/ui/abi/stack-probes-lto.rs +++ b/src/test/ui/abi/stack-probes-lto.rs @@ -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 diff --git a/src/test/ui/abi/stack-probes.rs b/src/test/ui/abi/stack-probes.rs index e998dd0f83ebc..b497af7abad50 100644 --- a/src/test/ui/abi/stack-probes.rs +++ b/src/test/ui/abi/stack-probes.rs @@ -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; diff --git a/src/test/ui/process/signal-exit-status.rs b/src/test/ui/process/signal-exit-status.rs index 0963dcc80f6bf..9519ed7b4c7b1 100644 --- a/src/test/ui/process/signal-exit-status.rs +++ b/src/test/ui/process/signal-exit-status.rs @@ -2,6 +2,7 @@ // ignore-emscripten no processes // ignore-sgx no processes // ignore-windows +// ignore-fuchsia code returned as ZX_TASK_RETCODE_EXCEPTION_KILL, FIXME (#58590) use std::env; use std::process::Command; diff --git a/src/test/ui/runtime/out-of-stack.rs b/src/test/ui/runtime/out-of-stack.rs index 73c31cd9721f6..6873abc49b244 100644 --- a/src/test/ui/runtime/out-of-stack.rs +++ b/src/test/ui/runtime/out-of-stack.rs @@ -5,6 +5,7 @@ // ignore-android: FIXME (#20004) // ignore-emscripten no processes // ignore-sgx no processes +// ignore-fuchsia must translate zircon signal to SIGABRT, FIXME (#58590) #![feature(core_intrinsics)] #![feature(rustc_private)]