Auto merge of #95748 - Dylan-DPC:rollup-t208j51, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #95352 ([bootstrap] Print the full relative path to failed tests)
 - #95646 (Mention `std::env::var` in `env!`)
 - #95708 (Update documentation for `trim*` and `is_whitespace` to include newlines)
 - #95714 (Add test for issue #83474)
 - #95725 (Message: Chunks cannot have a size of zero.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2022-04-07 05:12:08 +00:00
commit 8cd6080f6c
7 changed files with 45 additions and 22 deletions

View File

@ -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());
///

View File

@ -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<T>`][Option] for more information on this type.
/// [`Option<T>`][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.

View File

@ -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)
}

View File

@ -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:

View File

@ -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`

View File

@ -32,8 +32,17 @@ LL |
LL | struct MyPhantomData<T, U>;
| ------ 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<T, U>;
= 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`.

View File

@ -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(),