Skip to content

Rollup of 5 pull requests #95748

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions library/core/src/char/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,9 @@ impl char {
/// ```
/// assert!(' '.is_whitespace());
///
/// // line break
/// assert!('\n'.is_whitespace());
///
/// // a non-breaking space
/// assert!('\u{A0}'.is_whitespace());
///
Expand Down
10 changes: 8 additions & 2 deletions library/core/src/macros/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,10 @@ pub(crate) mod builtin {
/// 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!`]
Expand Down Expand Up @@ -950,7 +953,10 @@ pub(crate) mod builtin {
/// 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.
Expand Down
4 changes: 2 additions & 2 deletions library/core/src/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ impl<T> [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)
}

Expand Down Expand Up @@ -852,7 +852,7 @@ impl<T> [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)
}

Expand Down
16 changes: 8 additions & 8 deletions library/core/src/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1832,14 +1832,14 @@ impl str {
/// 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());
/// ```
Expand All @@ -1855,7 +1855,7 @@ impl 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
///
Expand All @@ -1869,8 +1869,8 @@ impl 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:
Expand All @@ -1894,7 +1894,7 @@ impl 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
///
Expand All @@ -1908,8 +1908,8 @@ impl 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:
Expand Down
11 changes: 9 additions & 2 deletions src/test/ui/lang-items/lang-item-generic-requirements.rs
Original file line number Diff line number Diff line change
@@ -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]
Expand All @@ -25,6 +25,10 @@ struct MyPhantomData<T, U>;
//~^ 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"]
Expand All @@ -48,6 +52,9 @@ fn ice() {

// Use phantomdata
let _ = MyPhantomData::<(), i32>;

// Use Foo
let _: () = Foo;
}

// use `start`
Expand Down
13 changes: 11 additions & 2 deletions src/test/ui/lang-items/lang-item-generic-requirements.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
| ^^^^^^^^^^^^^^^^^
Expand All @@ -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`.
10 changes: 4 additions & 6 deletions src/tools/compiletest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down