From d0a326044ec21fa22828beaedeb9b23b856ea592 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sat, 26 Mar 2022 22:50:46 -0500 Subject: [PATCH 1/7] Print the full relative path to failed tests Before: ``` failures: [ui] rustdoc-ui/intra-doc/feature-gate-intra-doc-pointers.rs test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 163 filtered out; finished in 0.45s ``` After: ``` failures: [ui] src/test/rustdoc-ui/intra-doc/feature-gate-intra-doc-pointers.rs test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 163 filtered out; finished in 0.45s ``` This allows copy pasting the path or using Ctrl+Click in IDEs to go directly to the file, instead of having to edit the filename first. --- src/tools/compiletest/src/main.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index 503b624114a..8c1f28f1407 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -744,12 +744,10 @@ fn make_test_name( testpaths: &TestPaths, revision: Option<&String>, ) -> test::TestName { - // Convert a complete path to something like - // - // ui/foo/bar/baz.rs - let path = PathBuf::from(config.src_base.file_name().unwrap()) - .join(&testpaths.relative_dir) - .join(&testpaths.file.file_name().unwrap()); + // Print the name of the file, relative to the repository root. + // `src_base` looks like `/path/to/rust/src/test/ui` + let root_directory = config.src_base.parent().unwrap().parent().unwrap().parent().unwrap(); + let path = testpaths.file.strip_prefix(root_directory).unwrap(); let debugger = match config.debugger { Some(d) => format!("-{}", d), None => String::new(), From 9a2d0e53f1559f8c356e5692f95c317e960cbf31 Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Wed, 6 Apr 2022 11:03:36 +1000 Subject: [PATCH 2/7] Update documentation for `trim*` and `is_whitespace` to include newlines --- library/core/src/char/methods.rs | 3 +++ library/core/src/str/mod.rs | 16 ++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/library/core/src/char/methods.rs b/library/core/src/char/methods.rs index 3195205b1b6..6a8df7318cd 100644 --- a/library/core/src/char/methods.rs +++ b/library/core/src/char/methods.rs @@ -804,6 +804,9 @@ pub fn is_uppercase(self) -> bool { /// ``` /// assert!(' '.is_whitespace()); /// + /// // line break + /// assert!('\n'.is_whitespace()); + /// /// // a non-breaking space /// assert!('\u{A0}'.is_whitespace()); /// diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs index 6bfa6a5e015..a1779b78623 100644 --- a/library/core/src/str/mod.rs +++ b/library/core/src/str/mod.rs @@ -1832,14 +1832,14 @@ pub fn rmatch_indices<'a, P>(&'a self, pat: P) -> RMatchIndices<'a, P> /// Returns a string slice with leading and trailing whitespace removed. /// /// 'Whitespace' is defined according to the terms of the Unicode Derived - /// Core Property `White_Space`. + /// Core Property `White_Space`, which includes newlines. /// /// # Examples /// /// Basic usage: /// /// ``` - /// let s = " Hello\tworld\t"; + /// let s = "\n Hello\tworld\t\n"; /// /// assert_eq!("Hello\tworld", s.trim()); /// ``` @@ -1855,7 +1855,7 @@ pub fn trim(&self) -> &str { /// Returns a string slice with leading whitespace removed. /// /// 'Whitespace' is defined according to the terms of the Unicode Derived - /// Core Property `White_Space`. + /// Core Property `White_Space`, which includes newlines. /// /// # Text directionality /// @@ -1869,8 +1869,8 @@ pub fn trim(&self) -> &str { /// Basic usage: /// /// ``` - /// let s = " Hello\tworld\t"; - /// assert_eq!("Hello\tworld\t", s.trim_start()); + /// let s = "\n Hello\tworld\t\n"; + /// assert_eq!("Hello\tworld\t\n", s.trim_start()); /// ``` /// /// Directionality: @@ -1894,7 +1894,7 @@ pub fn trim_start(&self) -> &str { /// Returns a string slice with trailing whitespace removed. /// /// 'Whitespace' is defined according to the terms of the Unicode Derived - /// Core Property `White_Space`. + /// Core Property `White_Space`, which includes newlines. /// /// # Text directionality /// @@ -1908,8 +1908,8 @@ pub fn trim_start(&self) -> &str { /// Basic usage: /// /// ``` - /// let s = " Hello\tworld\t"; - /// assert_eq!(" Hello\tworld", s.trim_end()); + /// let s = "\n Hello\tworld\t\n"; + /// assert_eq!("\n Hello\tworld", s.trim_end()); /// ``` /// /// Directionality: From 594a2fcc3f405e2c3ee643a1b79defbf5ccb1d1c Mon Sep 17 00:00:00 2001 From: kangarooCoder Date: Tue, 5 Apr 2022 21:45:07 -0500 Subject: [PATCH 3/7] Add test for issue rust-lang/rust#83474 --- .../ui/lang-items/lang-item-generic-requirements.rs | 11 +++++++++-- .../lang-item-generic-requirements.stderr | 13 +++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/test/ui/lang-items/lang-item-generic-requirements.rs b/src/test/ui/lang-items/lang-item-generic-requirements.rs index c0b958f2bf2..fbb56e528c0 100644 --- a/src/test/ui/lang-items/lang-item-generic-requirements.rs +++ b/src/test/ui/lang-items/lang-item-generic-requirements.rs @@ -1,5 +1,5 @@ -// Checks that declaring a lang item with the wrong number -// of generic arguments errors rather than crashing (issue #83893, #87573, part of #9307, #79559). +// Checks that declaring a lang item with the wrong number of generic arguments errors rather than +// crashing (issue #83474, #83893, #87573, part of #9307, #79559). #![feature(lang_items, no_core)] #![no_core] @@ -25,6 +25,10 @@ trait MyIndex<'a, T> {} //~^ ERROR parameter `T` is never used //~| ERROR parameter `U` is never used +#[lang = "owned_box"] +//~^ ERROR `owned_box` language item must be applied to a struct with at least 1 generic argument +struct Foo; + // When the `start` lang item is missing generics very odd things can happen, especially when // it comes to cross-crate monomorphization #[lang = "start"] @@ -48,6 +52,9 @@ fn ice() { // Use phantomdata let _ = MyPhantomData::<(), i32>; + + // Use Foo + let _: () = Foo; } // use `start` diff --git a/src/test/ui/lang-items/lang-item-generic-requirements.stderr b/src/test/ui/lang-items/lang-item-generic-requirements.stderr index df5a77850f1..326f5b0d595 100644 --- a/src/test/ui/lang-items/lang-item-generic-requirements.stderr +++ b/src/test/ui/lang-items/lang-item-generic-requirements.stderr @@ -32,8 +32,17 @@ LL | LL | struct MyPhantomData; | ------ this struct has 2 generic arguments +error[E0718]: `owned_box` language item must be applied to a struct with at least 1 generic argument + --> $DIR/lang-item-generic-requirements.rs:28:1 + | +LL | #[lang = "owned_box"] + | ^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | struct Foo; + | - this struct has 0 generic arguments + error[E0718]: `start` language item must be applied to a function with 1 generic argument - --> $DIR/lang-item-generic-requirements.rs:30:1 + --> $DIR/lang-item-generic-requirements.rs:34:1 | LL | #[lang = "start"] | ^^^^^^^^^^^^^^^^^ @@ -59,7 +68,7 @@ LL | struct MyPhantomData; = help: consider removing `U` or referring to it in a field = help: if you intended `U` to be a const parameter, use `const U: usize` instead -error: aborting due to 7 previous errors +error: aborting due to 8 previous errors Some errors have detailed explanations: E0392, E0718. For more information about an error, try `rustc --explain E0392`. From 2b76da86ef940a54bac9aee77f54d0ae39e065f6 Mon Sep 17 00:00:00 2001 From: Marijn Schouten Date: Wed, 6 Apr 2022 09:54:43 +0200 Subject: [PATCH 4/7] Message: Chunks cannot have a size of zero. Add a message to the assertion that chunks cannot have a size of zero. --- library/core/src/slice/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index 17f6373ecbf..4f0f51d1a4f 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -814,7 +814,7 @@ pub fn windows(&self, size: usize) -> Windows<'_, T> { #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn chunks(&self, chunk_size: usize) -> Chunks<'_, T> { - assert_ne!(chunk_size, 0); + assert_ne!(chunk_size, 0, "Chunks cannot have a size of zero!"); Chunks::new(self, chunk_size) } @@ -852,7 +852,7 @@ pub fn chunks(&self, chunk_size: usize) -> Chunks<'_, T> { #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn chunks_mut(&mut self, chunk_size: usize) -> ChunksMut<'_, T> { - assert_ne!(chunk_size, 0); + assert_ne!(chunk_size, 0, "Chunks cannot have a size of zero!"); ChunksMut::new(self, chunk_size) } From 4f08d753758daa8adc21b29b5f0c07393a60e6c0 Mon Sep 17 00:00:00 2001 From: Martin Geisler Date: Mon, 4 Apr 2022 16:22:02 +0200 Subject: [PATCH 5/7] Mention `std::env::var` in `env!` When searching for how to read an environment variable, I first encountered the `env!` macro. It would have been useful to me if the documentation had included a link to `std::env::var`, which is what I was actually looking for. --- library/core/src/macros/mod.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs index 74c94680e47..83f33ca007a 100644 --- a/library/core/src/macros/mod.rs +++ b/library/core/src/macros/mod.rs @@ -909,7 +909,10 @@ macro_rules! format_args_nl { /// Inspects an environment variable at compile time. /// /// This macro will expand to the value of the named environment variable at - /// compile time, yielding an expression of type `&'static str`. + /// compile time, yielding an expression of type `&'static str`. Use + /// [`std::env::var`] instead if you want to read the value at runtime. + /// + /// [`std::env::var`]: ../std/env/fn.var.html /// /// If the environment variable is not defined, then a compilation error /// will be emitted. To not emit a compile error, use the [`option_env!`] @@ -950,7 +953,10 @@ macro_rules! env { /// expand into an expression of type `Option<&'static str>` whose value is /// `Some` of the value of the environment variable. If the environment /// variable is not present, then this will expand to `None`. See - /// [`Option`][Option] for more information on this type. + /// [`Option`][Option] for more information on this type. Use + /// [`std::env::var`] instead if you want to read the value at runtime. + /// + /// [`std::env::var`]: ../std/env/fn.var.html /// /// A compile time error is never emitted when using this macro regardless /// of whether the environment variable is present or not. From 7660b2fd748f3b2fa6ddb230d94ff628a0d238dd Mon Sep 17 00:00:00 2001 From: Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> Date: Thu, 7 Apr 2022 04:44:11 +0200 Subject: [PATCH 6/7] remove exclamation mark Co-authored-by: Janusz Marcinkiewicz --- library/core/src/slice/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index 4f0f51d1a4f..376ab41248d 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -814,7 +814,7 @@ pub fn windows(&self, size: usize) -> Windows<'_, T> { #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn chunks(&self, chunk_size: usize) -> Chunks<'_, T> { - assert_ne!(chunk_size, 0, "Chunks cannot have a size of zero!"); + assert_ne!(chunk_size, 0, "chunks cannot have a size of zero"); Chunks::new(self, chunk_size) } From c331a9293a8a22f5111bdcdaf50b3dd5ac0838ce Mon Sep 17 00:00:00 2001 From: Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> Date: Thu, 7 Apr 2022 04:44:30 +0200 Subject: [PATCH 7/7] Update library/core/src/slice/mod.rs Co-authored-by: Janusz Marcinkiewicz --- library/core/src/slice/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index 376ab41248d..78fad46e793 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -852,7 +852,7 @@ pub fn chunks(&self, chunk_size: usize) -> Chunks<'_, T> { #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn chunks_mut(&mut self, chunk_size: usize) -> ChunksMut<'_, T> { - assert_ne!(chunk_size, 0, "Chunks cannot have a size of zero!"); + assert_ne!(chunk_size, 0, "chunks cannot have a size of zero"); ChunksMut::new(self, chunk_size) }