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/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. diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index 17f6373ecbf..78fad46e793 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) } 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: 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`. 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(),