From b7e9b1ad7f986425525461e1d53bbd14e2759de9 Mon Sep 17 00:00:00 2001 From: Smitty Date: Tue, 3 Aug 2021 19:06:12 -0400 Subject: [PATCH 1/9] Add x.py option to --force-rerun compiletest tests --- src/bootstrap/builder/tests.rs | 3 +++ src/bootstrap/flags.rs | 10 ++++++++++ src/bootstrap/test.rs | 4 ++++ src/tools/compiletest/src/common.rs | 3 +++ src/tools/compiletest/src/main.rs | 19 ++++++++++++------- 5 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/bootstrap/builder/tests.rs b/src/bootstrap/builder/tests.rs index e7fb8c0d4d5d2..bb3ea04d4ace9 100644 --- a/src/bootstrap/builder/tests.rs +++ b/src/bootstrap/builder/tests.rs @@ -486,6 +486,7 @@ mod dist { fail_fast: true, doc_tests: DocTests::No, bless: false, + force_rerun: false, compare_mode: None, rustfix_coverage: false, pass: None, @@ -527,6 +528,7 @@ mod dist { fail_fast: true, doc_tests: DocTests::No, bless: false, + force_rerun: false, compare_mode: None, rustfix_coverage: false, pass: None, @@ -583,6 +585,7 @@ mod dist { fail_fast: true, doc_tests: DocTests::Yes, bless: false, + force_rerun: false, compare_mode: None, rustfix_coverage: false, pass: None, diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs index 1b7614b29896f..7b74a909c286e 100644 --- a/src/bootstrap/flags.rs +++ b/src/bootstrap/flags.rs @@ -102,6 +102,7 @@ pub enum Subcommand { paths: Vec, /// Whether to automatically update stderr/stdout files bless: bool, + force_rerun: bool, compare_mode: Option, pass: Option, run: Option, @@ -284,6 +285,7 @@ To learn more about a subcommand, run `./x.py -h`", opts.optflag("", "no-doc", "do not run doc tests"); opts.optflag("", "doc", "only run doc tests"); opts.optflag("", "bless", "update all stderr/stdout files of failing ui tests"); + opts.optflag("", "force-rerun", "rerun tests even if the inputs are unchanged"); opts.optopt( "", "compare-mode", @@ -558,6 +560,7 @@ Arguments: "test" | "t" => Subcommand::Test { paths, bless: matches.opt_present("bless"), + force_rerun: matches.opt_present("force-rerun"), compare_mode: matches.opt_str("compare-mode"), pass: matches.opt_str("pass"), run: matches.opt_str("run"), @@ -726,6 +729,13 @@ impl Subcommand { } } + pub fn force_rerun(&self) -> bool { + match *self { + Subcommand::Test { force_rerun, .. } => force_rerun, + _ => false, + } + } + pub fn rustfix_coverage(&self) -> bool { match *self { Subcommand::Test { rustfix_coverage, .. } => rustfix_coverage, diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 31f18d81c7c0f..9effdb2c959d0 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -1315,6 +1315,10 @@ note: if you're sure you want to do this, please open an issue as to why. In the cmd.arg("--bless"); } + if builder.config.cmd.force_rerun() { + cmd.arg("--force-rerun"); + } + let compare_mode = builder.config.cmd.compare_mode().or_else(|| { if builder.config.test_compare_mode { self.compare_mode } else { None } diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index a5b526be86f3d..99b0a3454e89c 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -362,6 +362,9 @@ pub struct Config { pub nodejs: Option, /// Path to a npm executable. Used for rustdoc GUI tests pub npm: Option, + + /// Whether to rerun tests even if the inputs are unchanged. + pub force_rerun: bool, } impl Config { diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index 46432d5e4f5bc..9e655557fd271 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -144,6 +144,7 @@ pub fn parse_config(args: Vec) -> Config { "enable this to generate a Rustfix coverage file, which is saved in \ `.//rustfix_missing_coverage.txt`", ) + .optflag("", "force-rerun", "rerun tests even if the inputs are unchanged") .optflag("h", "help", "show this message") .reqopt("", "channel", "current Rust channel", "CHANNEL"); @@ -289,6 +290,8 @@ pub fn parse_config(args: Vec) -> Config { llvm_components: matches.opt_str("llvm-components").unwrap(), nodejs: matches.opt_str("nodejs"), npm: matches.opt_str("npm"), + + force_rerun: matches.opt_present("force-rerun"), } } @@ -644,13 +647,15 @@ fn make_test(config: &Config, testpaths: &TestPaths, inputs: &Stamp) -> Vec Date: Thu, 5 Aug 2021 00:00:00 +0000 Subject: [PATCH 2/9] Make vec-shrink-panic test compatible with v0 mangling The v0 mangling includes an instantiating crate in a mangled name, which crates a false positive match for a word `panic`. Rename crate name / test case to avoid the issue. --- src/test/codegen/{vec-shrink-panic.rs => vec-shrink-panik.rs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/test/codegen/{vec-shrink-panic.rs => vec-shrink-panik.rs} (100%) diff --git a/src/test/codegen/vec-shrink-panic.rs b/src/test/codegen/vec-shrink-panik.rs similarity index 100% rename from src/test/codegen/vec-shrink-panic.rs rename to src/test/codegen/vec-shrink-panik.rs From 4235d93434fc139d9a4bd661d3f779f50a901764 Mon Sep 17 00:00:00 2001 From: await Marsha <46257533+m-rsha@users.noreply.github.com> Date: Fri, 6 Aug 2021 18:40:36 -0500 Subject: [PATCH 3/9] Fix typo -- "The" -> "They" I was reading through source code to try to learn more about the language and how to make the most of it when I ran into a small typo, so I figured I'd offer up a fix! I'm pretty new now, but hopefully I can offer up more substantial changes later. :D --- src/tools/linkchecker/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/linkchecker/main.rs b/src/tools/linkchecker/main.rs index 15edd628cdffc..8cbe0a0c2e8e1 100644 --- a/src/tools/linkchecker/main.rs +++ b/src/tools/linkchecker/main.rs @@ -129,7 +129,7 @@ enum FileEntry { /// An HTML file. /// /// This includes the contents of the HTML file, and an optional set of - /// HTML IDs. The IDs are used for checking fragments. The are computed + /// HTML IDs. The IDs are used for checking fragments. They are computed /// as-needed. The source is discarded (replaced with an empty string) /// after the file has been checked, to conserve on memory. HtmlFile { source: Rc, ids: RefCell> }, From 35122393fdf943fbaa8225bbbc177f9f9c38496a Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Fri, 6 Aug 2021 16:43:55 -0700 Subject: [PATCH 4/9] Fix small typo The closing backtick was outside the closing bracket, which is why the intra-doc link wasn't working. --- src/librustdoc/clean/types.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 5c73d3de5b93f..9a36c671bc457 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -1937,7 +1937,7 @@ crate enum Variant { Struct(VariantStruct), } -/// Small wrapper around [`rustc_span::Span]` that adds helper methods +/// Small wrapper around [`rustc_span::Span`] that adds helper methods /// and enforces calling [`rustc_span::Span::source_callsite()`]. #[derive(Copy, Clone, Debug)] crate struct Span(rustc_span::Span); From c32e4ba60abe2e3868da91f6d2bee1d889f36abe Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Sat, 7 Aug 2021 10:14:41 +0200 Subject: [PATCH 5/9] Document that fs::read_dir skips . and .. --- library/std/src/fs.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index e1ad46961c025..2c04481c04ec0 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -2039,6 +2039,8 @@ pub fn remove_dir_all>(path: P) -> io::Result<()> { /// /// The iterator will yield instances of [`io::Result`]`<`[`DirEntry`]`>`. /// New errors may be encountered after an iterator is initially constructed. +/// Entries for the current and parent directories (typically `.` and `..`) are +/// skipped. /// /// # Platform-specific behavior /// From 731cd263fdc5db6dba7a4153af5ea9bee332bf1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20du=20Garreau?= Date: Wed, 31 Mar 2021 17:04:14 +0200 Subject: [PATCH 6/9] Fix a layout miscalculation in alloc::RawVec --- library/alloc/src/raw_vec.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/library/alloc/src/raw_vec.rs b/library/alloc/src/raw_vec.rs index 3caada06f6b58..882dbedf898f2 100644 --- a/library/alloc/src/raw_vec.rs +++ b/library/alloc/src/raw_vec.rs @@ -260,9 +260,7 @@ impl RawVec { // We have an allocated chunk of memory, so we can bypass runtime // checks to get our current layout. unsafe { - let align = mem::align_of::(); - let size = mem::size_of::() * self.cap; - let layout = Layout::from_size_align_unchecked(size, align); + let layout = Layout::array::(self.cap).unwrap_unchecked(); Some((self.ptr.cast().into(), layout)) } } From e7f1c8efd3aab96067e05cc08b8c72b5dde35ac9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20du=20Garreau?= Date: Mon, 2 Aug 2021 11:34:37 +0200 Subject: [PATCH 7/9] Fix `shrink` and `capacity_from_bytes` --- library/alloc/src/raw_vec.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/library/alloc/src/raw_vec.rs b/library/alloc/src/raw_vec.rs index 882dbedf898f2..ecd7d616d3572 100644 --- a/library/alloc/src/raw_vec.rs +++ b/library/alloc/src/raw_vec.rs @@ -402,7 +402,8 @@ impl RawVec { fn capacity_from_bytes(excess: usize) -> usize { debug_assert_ne!(mem::size_of::(), 0); - excess / mem::size_of::() + let size_of_item = Layout::new::().pad_to_align().size(); + excess / size_of_item } fn set_ptr(&mut self, ptr: NonNull<[u8]>) { @@ -466,10 +467,11 @@ impl RawVec { assert!(amount <= self.capacity(), "Tried to shrink to a larger capacity"); let (ptr, layout) = if let Some(mem) = self.current_memory() { mem } else { return Ok(()) }; - let new_size = amount * mem::size_of::(); let ptr = unsafe { - let new_layout = Layout::from_size_align_unchecked(new_size, layout.align()); + // `Layout::array` cannot overflow here because it would have + // owerflown earlier when capacity was larger. + let new_layout = Layout::array::(amount).unwrap_unchecked(); self.alloc .shrink(ptr, layout, new_layout) .map_err(|_| AllocError { layout: new_layout, non_exhaustive: () })? From 03498aa25649a1494b0bdc1fcb335388a0b3a10a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20du=20Garreau?= Date: Sat, 7 Aug 2021 12:36:05 +0200 Subject: [PATCH 8/9] Avoid using `map_err` --- library/alloc/src/raw_vec.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/library/alloc/src/raw_vec.rs b/library/alloc/src/raw_vec.rs index ecd7d616d3572..9d8ea515d41a3 100644 --- a/library/alloc/src/raw_vec.rs +++ b/library/alloc/src/raw_vec.rs @@ -472,9 +472,12 @@ impl RawVec { // `Layout::array` cannot overflow here because it would have // owerflown earlier when capacity was larger. let new_layout = Layout::array::(amount).unwrap_unchecked(); - self.alloc - .shrink(ptr, layout, new_layout) - .map_err(|_| AllocError { layout: new_layout, non_exhaustive: () })? + // We avoid `map_err` here because it bloats the amount of LLVM IR + // generated. + match self.alloc.shrink(ptr, layout, new_layout) { + Ok(ptr) => ptr, + Err(_) => Err(AllocError { layout: new_layout, non_exhaustive: () })?, + } }; self.set_ptr(ptr); Ok(()) From 5c30df59547f9aa72eaa08ba4801ea8c45030e07 Mon Sep 17 00:00:00 2001 From: Frank Steffahn Date: Sat, 7 Aug 2021 13:42:15 +0200 Subject: [PATCH 9/9] Fix intra doc link in hidden doc of Iterator::__iterator_get_unchecked --- library/core/src/iter/traits/iterator.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index c199b068cbb59..6b24d33bebca3 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -3452,7 +3452,7 @@ pub trait Iterator { self.map(f).is_sorted() } - /// See [TrustedRandomAccess] + /// See [TrustedRandomAccess][super::super::TrustedRandomAccess] // The unusual name is to avoid name collisions in method resolution // see #76479. #[inline]