Skip to content

Commit

Permalink
Auto merge of rust-lang#86197 - FabianWolff:trailing-whitespace, r=Jo…
Browse files Browse the repository at this point in the history
…hnTitor

Remove unnecessary trailing whitespace from error messages

Some error messages currently contain unnecessary trailing whitespace. There are some legitimate reasons for having trailing whitespace in the output, such as for uniform indentation of possibly-empty input lines, but the whitespace I have addressed here occurs in a line used only for spacing, and I see no reason why that should have trailing whitespace (spacing lines inserted in other places also don't have trailing whitespace).

I have also removed a superfluous call to `buffer.putc()`, which has no effect because the same character is already placed there by `draw_col_separator()`.

Use `git diff --ignore-space-at-eol` to see my changes; otherwise the diff is quite large due to the whitespace removed from expected outputs in `src/test/ui/`.
  • Loading branch information
bors committed Aug 4, 2021
2 parents 49ca3d9 + f8372f8 commit 87d713f
Showing 125 changed files with 247 additions and 244 deletions.
7 changes: 5 additions & 2 deletions compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
@@ -954,7 +954,6 @@ impl EmitterWriter {
// |
for pos in 0..=line_len {
draw_col_separator(buffer, line_offset + pos + 1, width_offset - 2);
buffer.putc(line_offset + pos + 1, width_offset - 2, '|', Style::LineNumber);
}

// Write the horizontal lines for multiline annotations
@@ -1344,7 +1343,11 @@ impl EmitterWriter {
let buffer_msg_line_offset = buffer.num_lines();

// Add spacing line
draw_col_separator(&mut buffer, buffer_msg_line_offset, max_line_num_len + 1);
draw_col_separator_no_space(
&mut buffer,
buffer_msg_line_offset,
max_line_num_len + 1,
);

// Then, the secondary file indicator
buffer.prepend(buffer_msg_line_offset + 1, "::: ", Style::LineNumber);
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ error[E0277]: `<<Self as Case1>::C as Iterator>::Item` cannot be sent between th
|
LL | type C: Clone + Iterator<Item: Send + Iterator<Item: for<'a> Lam<&'a u8, App: Debug>> + Sync>;
| ^^^^ `<<Self as Case1>::C as Iterator>::Item` cannot be sent between threads safely
|
|
::: $SRC_DIR/core/src/marker.rs:LL:COL
|
LL | pub unsafe auto trait Send {
@@ -20,7 +20,7 @@ error[E0277]: `<<Self as Case1>::C as Iterator>::Item` is not an iterator
|
LL | type C: Clone + Iterator<Item: Send + Iterator<Item: for<'a> Lam<&'a u8, App: Debug>> + Sync>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `<<Self as Case1>::C as Iterator>::Item` is not an iterator
|
|
::: $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
|
LL | pub trait Iterator {
@@ -37,7 +37,7 @@ error[E0277]: `<<Self as Case1>::C as Iterator>::Item` cannot be shared between
|
LL | type C: Clone + Iterator<Item: Send + Iterator<Item: for<'a> Lam<&'a u8, App: Debug>> + Sync>;
| ^^^^ `<<Self as Case1>::C as Iterator>::Item` cannot be shared between threads safely
|
|
::: $SRC_DIR/core/src/marker.rs:LL:COL
|
LL | pub unsafe auto trait Sync {
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ error[E0277]: `<<Self as Case1>::A as Iterator>::Item` doesn't implement `Debug`
|
LL | type A: Iterator<Item: Debug>;
| ^^^^^ `<<Self as Case1>::A as Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `Debug`
|
|
::: $SRC_DIR/core/src/fmt/mod.rs:LL:COL
|
LL | pub trait Debug {
@@ -20,7 +20,7 @@ error[E0277]: the trait bound `<<Self as Foo>::Out as Baz>::Assoc: Default` is n
|
LL | pub trait Foo { type Out: Baz<Assoc: Default>; }
| ^^^^^^^ the trait `Default` is not implemented for `<<Self as Foo>::Out as Baz>::Assoc`
|
|
::: $SRC_DIR/core/src/default.rs:LL:COL
|
LL | pub trait Default: Sized {
2 changes: 1 addition & 1 deletion src/test/ui/associated-types/defaults-wf.stderr
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation
|
LL | type Ty = Vec<[u8]>;
| ^^^^^^^^^ doesn't have a size known at compile-time
|
|
::: $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
|
LL | pub struct Vec<T, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global> {
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation
|
LL | trait ArithmeticOps: Add<Output=Self> + Sub<Output=Self> + Mul<Output=Self> + Div<Output=Self> {}
| ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
|
::: $SRC_DIR/core/src/ops/arith.rs:LL:COL
|
LL | pub trait Add<Rhs = Self> {
2 changes: 1 addition & 1 deletion src/test/ui/async-await/generator-desc.stderr
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ LL | fun((async || {})(), (async || {})());
| -- ^^^^^^^^^^^^^^^ expected `async` closure body, found a different `async` closure body
| |
| the expected `async` closure body
|
|
::: $SRC_DIR/core/src/future/mod.rs:LL:COL
|
LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
2 changes: 1 addition & 1 deletion src/test/ui/async-await/issue-72442.stderr
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ error[E0277]: the trait bound `Option<&str>: AsRef<Path>` is not satisfied
|
LL | let mut f = File::open(path.to_str())?;
| ^^^^^^^^^^^^^ the trait `AsRef<Path>` is not implemented for `Option<&str>`
|
|
::: $SRC_DIR/std/src/fs.rs:LL:COL
|
LL | pub fn open<P: AsRef<Path>>(path: P) -> io::Result<File> {
2 changes: 1 addition & 1 deletion src/test/ui/async-await/issues/issue-67893.stderr
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ LL | fn g(_: impl Send) {}
...
LL | g(issue_67893::run())
| ^ `MutexGuard<'_, ()>` cannot be sent between threads safely
|
|
::: $DIR/auxiliary/issue_67893.rs:7:20
|
LL | pub async fn run() {
2 changes: 1 addition & 1 deletion src/test/ui/async-await/pin-needed-to-poll.stderr
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ LL | struct Sleep;
...
LL | self.sleep.poll(cx)
| ^^^^ method not found in `Sleep`
|
|
::: $SRC_DIR/core/src/future/future.rs:LL:COL
|
LL | fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>;
2 changes: 1 addition & 1 deletion src/test/ui/borrowck/move-error-snippets.stderr
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ LL | let a = $c;
| |
| move occurs because `D` has type `A`, which does not implement the `Copy` trait
| help: consider borrowing here: `&$c`
|
|
::: $DIR/move-error-snippets.rs:21:1
|
LL | sss!();
10 changes: 5 additions & 5 deletions src/test/ui/bound-suggestions.stderr
Original file line number Diff line number Diff line change
@@ -75,7 +75,7 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation
|
LL | const SIZE: usize = core::mem::size_of::<Self>();
| ^^^^ doesn't have a size known at compile-time
|
|
::: $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
LL | pub const fn size_of<T>() -> usize {
@@ -91,7 +91,7 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation
|
LL | const SIZE: usize = core::mem::size_of::<Self>();
| ^^^^ doesn't have a size known at compile-time
|
|
::: $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
LL | pub const fn size_of<T>() -> usize {
@@ -107,7 +107,7 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation
|
LL | const SIZE: usize = core::mem::size_of::<Self>();
| ^^^^ doesn't have a size known at compile-time
|
|
::: $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
LL | pub const fn size_of<T>() -> usize {
@@ -123,7 +123,7 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation
|
LL | const SIZE: usize = core::mem::size_of::<Self>();
| ^^^^ doesn't have a size known at compile-time
|
|
::: $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
LL | pub const fn size_of<T>() -> usize {
@@ -139,7 +139,7 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation
|
LL | const SIZE: usize = core::mem::size_of::<Self>();
| ^^^^ doesn't have a size known at compile-time
|
|
::: $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
LL | pub const fn size_of<T>() -> usize {
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ error[E0277]: `T` cannot be sent between threads safely
|
LL | impl <T:Sync+'static> RequiresRequiresShareAndSend for X<T> { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `T` cannot be sent between threads safely
|
|
::: $DIR/auxiliary/trait_superkinds_in_metadata.rs:7:58
|
LL | pub trait RequiresRequiresShareAndSend : RequiresShare + Send { }
2 changes: 1 addition & 1 deletion src/test/ui/c-variadic/issue-86053-1.stderr
Original file line number Diff line number Diff line change
@@ -63,7 +63,7 @@ error[E0412]: cannot find type `F` in this scope
|
LL | self , ... , self , self , ... ) where F : FnOnce ( & 'a & 'b usize ) {
| ^
|
|
::: $SRC_DIR/core/src/ops/function.rs:LL:COL
|
LL | pub trait Fn<Args>: FnMut<Args> {
4 changes: 2 additions & 2 deletions src/test/ui/closures/closure-move-sync.stderr
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ error[E0277]: `std::sync::mpsc::Receiver<()>` cannot be shared between threads s
|
LL | let t = thread::spawn(|| {
| ^^^^^^^^^^^^^ `std::sync::mpsc::Receiver<()>` cannot be shared between threads safely
|
|
::: $SRC_DIR/std/src/thread/mod.rs:LL:COL
|
LL | F: Send + 'static,
@@ -18,7 +18,7 @@ error[E0277]: `Sender<()>` cannot be shared between threads safely
|
LL | thread::spawn(|| tx.send(()).unwrap());
| ^^^^^^^^^^^^^ `Sender<()>` cannot be shared between threads safely
|
|
::: $SRC_DIR/std/src/thread/mod.rs:LL:COL
|
LL | F: Send + 'static,
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ LL | pub const fn is_zst<T: ?Sized>() -> usize {
| - this type parameter needs to be `std::marker::Sized`
LL | if std::mem::size_of::<T>() == 0 {
| ^ doesn't have a size known at compile-time
|
|
::: $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
LL | pub const fn size_of<T>() -> usize {
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ error: unconstrained generic constant
|
LL | let _ = const_evaluatable_lib::test1::<T>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
::: $DIR/auxiliary/const_evaluatable_lib.rs:6:10
|
LL | [u8; std::mem::size_of::<T>() - 1]: Sized,
@@ -16,7 +16,7 @@ error: unconstrained generic constant
|
LL | let _ = const_evaluatable_lib::test1::<T>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
::: $DIR/auxiliary/const_evaluatable_lib.rs:4:27
|
LL | pub fn test1<T>() -> [u8; std::mem::size_of::<T>() - 1]
@@ -29,7 +29,7 @@ error: unconstrained generic constant
|
LL | let _ = const_evaluatable_lib::test1::<T>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
::: $DIR/auxiliary/const_evaluatable_lib.rs:6:10
|
LL | [u8; std::mem::size_of::<T>() - 1]: Sized,
@@ -42,7 +42,7 @@ error: unconstrained generic constant
|
LL | let _ = const_evaluatable_lib::test1::<T>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
::: $DIR/auxiliary/const_evaluatable_lib.rs:4:27
|
LL | pub fn test1<T>() -> [u8; std::mem::size_of::<T>() - 1]
16 changes: 8 additions & 8 deletions src/test/ui/const-ptr/out_of_bounds_read.stderr
Original file line number Diff line number Diff line change
@@ -6,12 +6,12 @@ LL | unsafe { copy_nonoverlapping(src, dst, count) }
| |
| memory access failed: alloc7 has size 4, so pointer to 4 bytes starting at offset 4 is out-of-bounds
| inside `copy_nonoverlapping::<u32>` at $SRC_DIR/core/src/intrinsics.rs:LL:COL
|
|
::: $SRC_DIR/core/src/ptr/mod.rs:LL:COL
|
LL | copy_nonoverlapping(src, tmp.as_mut_ptr(), 1);
| --------------------------------------------- inside `std::ptr::read::<u32>` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
|
|
::: $DIR/out_of_bounds_read.rs:13:33
|
LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) };
@@ -25,17 +25,17 @@ LL | unsafe { copy_nonoverlapping(src, dst, count) }
| |
| memory access failed: alloc7 has size 4, so pointer to 4 bytes starting at offset 4 is out-of-bounds
| inside `copy_nonoverlapping::<u32>` at $SRC_DIR/core/src/intrinsics.rs:LL:COL
|
|
::: $SRC_DIR/core/src/ptr/mod.rs:LL:COL
|
LL | copy_nonoverlapping(src, tmp.as_mut_ptr(), 1);
| --------------------------------------------- inside `std::ptr::read::<u32>` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
|
|
::: $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
LL | unsafe { read(self) }
| ---------- inside `ptr::const_ptr::<impl *const u32>::read` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
|
::: $DIR/out_of_bounds_read.rs:14:39
|
LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() };
@@ -49,17 +49,17 @@ LL | unsafe { copy_nonoverlapping(src, dst, count) }
| |
| memory access failed: alloc7 has size 4, so pointer to 4 bytes starting at offset 4 is out-of-bounds
| inside `copy_nonoverlapping::<u32>` at $SRC_DIR/core/src/intrinsics.rs:LL:COL
|
|
::: $SRC_DIR/core/src/ptr/mod.rs:LL:COL
|
LL | copy_nonoverlapping(src, tmp.as_mut_ptr(), 1);
| --------------------------------------------- inside `std::ptr::read::<u32>` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
|
|
::: $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
|
LL | unsafe { read(self) }
| ---------- inside `ptr::mut_ptr::<impl *mut u32>::read` at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
|
|
::: $DIR/out_of_bounds_read.rs:15:37
|
LL | const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() };
2 changes: 1 addition & 1 deletion src/test/ui/consts/const_unsafe_unreachable_ub.stderr
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ LL | unsafe { intrinsics::unreachable() }
| |
| entering unreachable code
| inside `unreachable_unchecked` at $SRC_DIR/core/src/hint.rs:LL:COL
|
|
::: $DIR/const_unsafe_unreachable_ub.rs:7:18
|
LL | false => std::hint::unreachable_unchecked(),
2 changes: 1 addition & 1 deletion src/test/ui/consts/miri_unleashed/drop.stderr
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ LL | pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
| |
| calling non-const function `<Vec<i32> as Drop>::drop`
| inside `std::ptr::drop_in_place::<Vec<i32>> - shim(Some(Vec<i32>))` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
|
|
::: $DIR/drop.rs:18:1
|
LL | };
2 changes: 1 addition & 1 deletion src/test/ui/consts/offset_from_ub.stderr
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ LL | unsafe { intrinsics::ptr_offset_from(self, origin) }
| |
| 0x2a is not a valid pointer
| inside `ptr::const_ptr::<impl *const u8>::offset_from` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
|
::: $DIR/offset_from_ub.rs:24:14
|
LL | unsafe { (42 as *const u8).offset_from(&5u8) as usize }
Loading

0 comments on commit 87d713f

Please sign in to comment.