Skip to content

Commit 8cd6080

Browse files
committed
Auto merge of rust-lang#95748 - Dylan-DPC:rollup-t208j51, r=Dylan-DPC
Rollup of 5 pull requests Successful merges: - rust-lang#95352 ([bootstrap] Print the full relative path to failed tests) - rust-lang#95646 (Mention `std::env::var` in `env!`) - rust-lang#95708 (Update documentation for `trim*` and `is_whitespace` to include newlines) - rust-lang#95714 (Add test for issue rust-lang#83474) - rust-lang#95725 (Message: Chunks cannot have a size of zero.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 846993e + 939f84a commit 8cd6080

File tree

7 files changed

+45
-22
lines changed

7 files changed

+45
-22
lines changed

library/core/src/char/methods.rs

+3
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,9 @@ impl char {
804804
/// ```
805805
/// assert!(' '.is_whitespace());
806806
///
807+
/// // line break
808+
/// assert!('\n'.is_whitespace());
809+
///
807810
/// // a non-breaking space
808811
/// assert!('\u{A0}'.is_whitespace());
809812
///

library/core/src/macros/mod.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,10 @@ pub(crate) mod builtin {
909909
/// Inspects an environment variable at compile time.
910910
///
911911
/// This macro will expand to the value of the named environment variable at
912-
/// compile time, yielding an expression of type `&'static str`.
912+
/// compile time, yielding an expression of type `&'static str`. Use
913+
/// [`std::env::var`] instead if you want to read the value at runtime.
914+
///
915+
/// [`std::env::var`]: ../std/env/fn.var.html
913916
///
914917
/// If the environment variable is not defined, then a compilation error
915918
/// will be emitted. To not emit a compile error, use the [`option_env!`]
@@ -950,7 +953,10 @@ pub(crate) mod builtin {
950953
/// expand into an expression of type `Option<&'static str>` whose value is
951954
/// `Some` of the value of the environment variable. If the environment
952955
/// variable is not present, then this will expand to `None`. See
953-
/// [`Option<T>`][Option] for more information on this type.
956+
/// [`Option<T>`][Option] for more information on this type. Use
957+
/// [`std::env::var`] instead if you want to read the value at runtime.
958+
///
959+
/// [`std::env::var`]: ../std/env/fn.var.html
954960
///
955961
/// A compile time error is never emitted when using this macro regardless
956962
/// of whether the environment variable is present or not.

library/core/src/slice/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ impl<T> [T] {
814814
#[stable(feature = "rust1", since = "1.0.0")]
815815
#[inline]
816816
pub fn chunks(&self, chunk_size: usize) -> Chunks<'_, T> {
817-
assert_ne!(chunk_size, 0);
817+
assert_ne!(chunk_size, 0, "chunks cannot have a size of zero");
818818
Chunks::new(self, chunk_size)
819819
}
820820

@@ -852,7 +852,7 @@ impl<T> [T] {
852852
#[stable(feature = "rust1", since = "1.0.0")]
853853
#[inline]
854854
pub fn chunks_mut(&mut self, chunk_size: usize) -> ChunksMut<'_, T> {
855-
assert_ne!(chunk_size, 0);
855+
assert_ne!(chunk_size, 0, "chunks cannot have a size of zero");
856856
ChunksMut::new(self, chunk_size)
857857
}
858858

library/core/src/str/mod.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1832,14 +1832,14 @@ impl str {
18321832
/// Returns a string slice with leading and trailing whitespace removed.
18331833
///
18341834
/// 'Whitespace' is defined according to the terms of the Unicode Derived
1835-
/// Core Property `White_Space`.
1835+
/// Core Property `White_Space`, which includes newlines.
18361836
///
18371837
/// # Examples
18381838
///
18391839
/// Basic usage:
18401840
///
18411841
/// ```
1842-
/// let s = " Hello\tworld\t";
1842+
/// let s = "\n Hello\tworld\t\n";
18431843
///
18441844
/// assert_eq!("Hello\tworld", s.trim());
18451845
/// ```
@@ -1855,7 +1855,7 @@ impl str {
18551855
/// Returns a string slice with leading whitespace removed.
18561856
///
18571857
/// 'Whitespace' is defined according to the terms of the Unicode Derived
1858-
/// Core Property `White_Space`.
1858+
/// Core Property `White_Space`, which includes newlines.
18591859
///
18601860
/// # Text directionality
18611861
///
@@ -1869,8 +1869,8 @@ impl str {
18691869
/// Basic usage:
18701870
///
18711871
/// ```
1872-
/// let s = " Hello\tworld\t";
1873-
/// assert_eq!("Hello\tworld\t", s.trim_start());
1872+
/// let s = "\n Hello\tworld\t\n";
1873+
/// assert_eq!("Hello\tworld\t\n", s.trim_start());
18741874
/// ```
18751875
///
18761876
/// Directionality:
@@ -1894,7 +1894,7 @@ impl str {
18941894
/// Returns a string slice with trailing whitespace removed.
18951895
///
18961896
/// 'Whitespace' is defined according to the terms of the Unicode Derived
1897-
/// Core Property `White_Space`.
1897+
/// Core Property `White_Space`, which includes newlines.
18981898
///
18991899
/// # Text directionality
19001900
///
@@ -1908,8 +1908,8 @@ impl str {
19081908
/// Basic usage:
19091909
///
19101910
/// ```
1911-
/// let s = " Hello\tworld\t";
1912-
/// assert_eq!(" Hello\tworld", s.trim_end());
1911+
/// let s = "\n Hello\tworld\t\n";
1912+
/// assert_eq!("\n Hello\tworld", s.trim_end());
19131913
/// ```
19141914
///
19151915
/// Directionality:

src/test/ui/lang-items/lang-item-generic-requirements.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// Checks that declaring a lang item with the wrong number
2-
// of generic arguments errors rather than crashing (issue #83893, #87573, part of #9307, #79559).
1+
// Checks that declaring a lang item with the wrong number of generic arguments errors rather than
2+
// crashing (issue #83474, #83893, #87573, part of #9307, #79559).
33

44
#![feature(lang_items, no_core)]
55
#![no_core]
@@ -25,6 +25,10 @@ struct MyPhantomData<T, U>;
2525
//~^ ERROR parameter `T` is never used
2626
//~| ERROR parameter `U` is never used
2727

28+
#[lang = "owned_box"]
29+
//~^ ERROR `owned_box` language item must be applied to a struct with at least 1 generic argument
30+
struct Foo;
31+
2832
// When the `start` lang item is missing generics very odd things can happen, especially when
2933
// it comes to cross-crate monomorphization
3034
#[lang = "start"]
@@ -48,6 +52,9 @@ fn ice() {
4852

4953
// Use phantomdata
5054
let _ = MyPhantomData::<(), i32>;
55+
56+
// Use Foo
57+
let _: () = Foo;
5158
}
5259

5360
// use `start`

src/test/ui/lang-items/lang-item-generic-requirements.stderr

+11-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,17 @@ LL |
3232
LL | struct MyPhantomData<T, U>;
3333
| ------ this struct has 2 generic arguments
3434

35+
error[E0718]: `owned_box` language item must be applied to a struct with at least 1 generic argument
36+
--> $DIR/lang-item-generic-requirements.rs:28:1
37+
|
38+
LL | #[lang = "owned_box"]
39+
| ^^^^^^^^^^^^^^^^^^^^^
40+
LL |
41+
LL | struct Foo;
42+
| - this struct has 0 generic arguments
43+
3544
error[E0718]: `start` language item must be applied to a function with 1 generic argument
36-
--> $DIR/lang-item-generic-requirements.rs:30:1
45+
--> $DIR/lang-item-generic-requirements.rs:34:1
3746
|
3847
LL | #[lang = "start"]
3948
| ^^^^^^^^^^^^^^^^^
@@ -59,7 +68,7 @@ LL | struct MyPhantomData<T, U>;
5968
= help: consider removing `U` or referring to it in a field
6069
= help: if you intended `U` to be a const parameter, use `const U: usize` instead
6170

62-
error: aborting due to 7 previous errors
71+
error: aborting due to 8 previous errors
6372

6473
Some errors have detailed explanations: E0392, E0718.
6574
For more information about an error, try `rustc --explain E0392`.

src/tools/compiletest/src/main.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -744,12 +744,10 @@ fn make_test_name(
744744
testpaths: &TestPaths,
745745
revision: Option<&String>,
746746
) -> test::TestName {
747-
// Convert a complete path to something like
748-
//
749-
// ui/foo/bar/baz.rs
750-
let path = PathBuf::from(config.src_base.file_name().unwrap())
751-
.join(&testpaths.relative_dir)
752-
.join(&testpaths.file.file_name().unwrap());
747+
// Print the name of the file, relative to the repository root.
748+
// `src_base` looks like `/path/to/rust/src/test/ui`
749+
let root_directory = config.src_base.parent().unwrap().parent().unwrap().parent().unwrap();
750+
let path = testpaths.file.strip_prefix(root_directory).unwrap();
753751
let debugger = match config.debugger {
754752
Some(d) => format!("-{}", d),
755753
None => String::new(),

0 commit comments

Comments
 (0)