Skip to content
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

diagnostics: remove trailing spaces #97892

Merged
merged 5 commits into from
Jun 17, 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
12 changes: 8 additions & 4 deletions compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -771,8 +771,12 @@ impl EmitterWriter {
self
}

fn maybe_anonymized(&self, line_num: usize) -> String {
if self.ui_testing { ANONYMIZED_LINE_NUM.to_string() } else { line_num.to_string() }
fn maybe_anonymized(&self, line_num: usize) -> Cow<'static, str> {
if self.ui_testing {
Cow::Borrowed(ANONYMIZED_LINE_NUM)
} else {
Cow::Owned(line_num.to_string())
}
}

fn draw_line(
Expand Down Expand Up @@ -819,7 +823,7 @@ impl EmitterWriter {
}
buffer.puts(line_offset, 0, &self.maybe_anonymized(line_index), Style::LineNumber);

draw_col_separator(buffer, line_offset, width_offset - 2);
draw_col_separator_no_space(buffer, line_offset, width_offset - 2);
}

fn render_source_line(
Expand Down Expand Up @@ -1920,7 +1924,7 @@ impl EmitterWriter {
// Only show an underline in the suggestions if the suggestion is not the
// entirety of the code being shown and the displayed code is not multiline.
if let DisplaySuggestion::Diff | DisplaySuggestion::Underline = show_code_change {
draw_col_separator(&mut buffer, row_num, max_line_num_len + 1);
draw_col_separator_no_space(&mut buffer, row_num, max_line_num_len + 1);
for part in parts {
let span_start_pos = sm.lookup_char_pos(part.span.lo()).col_display;
let span_end_pos = sm.lookup_char_pos(part.span.hi()).col_display;
Expand Down
6 changes: 3 additions & 3 deletions src/test/rustdoc-ui/intra-doc/disambiguator-mismatch.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ help: to link to the macro, add an exclamation mark
|
LL - /// Link to [derive@m]
LL + /// Link to [m!]
|
|

error: unresolved link to `m`
--> $DIR/disambiguator-mismatch.rs:46:14
Expand Down Expand Up @@ -124,7 +124,7 @@ help: to link to the constant, prefix with `const@`
|
LL - /// Link to [c()]
LL + /// Link to [const@c]
|
|

error: incompatible link kind for `f`
--> $DIR/disambiguator-mismatch.rs:72:14
Expand All @@ -136,7 +136,7 @@ help: to link to the function, add parentheses
|
LL - /// Link to [const@f]
LL + /// Link to [f()]
|
|

error: unresolved link to `std`
--> $DIR/disambiguator-mismatch.rs:77:14
Expand Down
8 changes: 4 additions & 4 deletions src/test/rustdoc-ui/intra-doc/errors.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ help: to link to the associated function, add parentheses
|
LL - /// [type@Vec::into_iter]
LL + /// [Vec::into_iter()]
|
|

error: unresolved link to `S`
--> $DIR/errors.rs:68:6
Expand All @@ -110,7 +110,7 @@ help: to link to the struct, prefix with `struct@`
|
LL - /// [S!]
LL + /// [struct@S]
|
|

error: unresolved link to `S::h`
--> $DIR/errors.rs:78:6
Expand All @@ -122,7 +122,7 @@ help: to link to the associated function, add parentheses
|
LL - /// [type@S::h]
LL + /// [S::h()]
|
|

error: unresolved link to `T::g`
--> $DIR/errors.rs:86:6
Expand All @@ -134,7 +134,7 @@ help: to link to the associated function, add parentheses
|
LL - /// [type@T::g]
LL + /// [T::g()]
|
|

error: unresolved link to `T::h`
--> $DIR/errors.rs:91:6
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-ui/test-compile-fail1.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ error[E0428]: the name `f` is defined multiple times
|
6 | pub fn f() {}
| ---------- previous definition of the value `f` here
7 |
7 |
8 | pub fn f() {}
| ^^^^^^^^^^ `f` redefined here
|
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/argument-suggestions/issue-97484.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ help: consider removing the ``
|
LL - foo(&&A, B, C, D, E, F, G);
LL + foo(&&A, B, C, D, E, F, G);
|
|
help: remove the extra arguments
|
LL | foo(&&A, D, {&E}, G);
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/asm/type-check-1.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ help: consider removing the borrow
|
LL - asm!("{}", const &0);
LL + asm!("{}", const 0);
|
|

error: invalid asm output
--> $DIR/type-check-1.rs:15:29
Expand Down
24 changes: 12 additions & 12 deletions src/test/ui/associated-type-bounds/type-alias.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ help: the clause will not be checked when the type alias is used, and should be
|
LL - type _TaWhere1<T> where T: Iterator<Item: Copy> = T;
LL + type _TaWhere1<T> = T;
|
|

warning: where clauses are not enforced in type aliases
--> $DIR/type-alias.rs:6:25
Expand All @@ -21,7 +21,7 @@ help: the clause will not be checked when the type alias is used, and should be
|
LL - type _TaWhere2<T> where T: Iterator<Item: 'static> = T;
LL + type _TaWhere2<T> = T;
|
|

warning: where clauses are not enforced in type aliases
--> $DIR/type-alias.rs:7:25
Expand All @@ -33,7 +33,7 @@ help: the clause will not be checked when the type alias is used, and should be
|
LL - type _TaWhere3<T> where T: Iterator<Item: 'static> = T;
LL + type _TaWhere3<T> = T;
|
|

warning: where clauses are not enforced in type aliases
--> $DIR/type-alias.rs:8:25
Expand All @@ -45,7 +45,7 @@ help: the clause will not be checked when the type alias is used, and should be
|
LL - type _TaWhere4<T> where T: Iterator<Item: 'static + Copy + Send> = T;
LL + type _TaWhere4<T> = T;
|
|

warning: where clauses are not enforced in type aliases
--> $DIR/type-alias.rs:9:25
Expand All @@ -57,7 +57,7 @@ help: the clause will not be checked when the type alias is used, and should be
|
LL - type _TaWhere5<T> where T: Iterator<Item: for<'a> Into<&'a u8>> = T;
LL + type _TaWhere5<T> = T;
|
|

warning: where clauses are not enforced in type aliases
--> $DIR/type-alias.rs:10:25
Expand All @@ -69,7 +69,7 @@ help: the clause will not be checked when the type alias is used, and should be
|
LL - type _TaWhere6<T> where T: Iterator<Item: Iterator<Item: Copy>> = T;
LL + type _TaWhere6<T> = T;
|
|

warning: bounds on generic parameters are not enforced in type aliases
--> $DIR/type-alias.rs:12:20
Expand All @@ -81,7 +81,7 @@ help: the bound will not be checked when the type alias is used, and should be r
|
LL - type _TaInline1<T: Iterator<Item: Copy>> = T;
LL + type _TaInline1<T> = T;
|
|

warning: bounds on generic parameters are not enforced in type aliases
--> $DIR/type-alias.rs:13:20
Expand All @@ -93,7 +93,7 @@ help: the bound will not be checked when the type alias is used, and should be r
|
LL - type _TaInline2<T: Iterator<Item: 'static>> = T;
LL + type _TaInline2<T> = T;
|
|

warning: bounds on generic parameters are not enforced in type aliases
--> $DIR/type-alias.rs:14:20
Expand All @@ -105,7 +105,7 @@ help: the bound will not be checked when the type alias is used, and should be r
|
LL - type _TaInline3<T: Iterator<Item: 'static>> = T;
LL + type _TaInline3<T> = T;
|
|

warning: bounds on generic parameters are not enforced in type aliases
--> $DIR/type-alias.rs:15:20
Expand All @@ -117,7 +117,7 @@ help: the bound will not be checked when the type alias is used, and should be r
|
LL - type _TaInline4<T: Iterator<Item: 'static + Copy + Send>> = T;
LL + type _TaInline4<T> = T;
|
|

warning: bounds on generic parameters are not enforced in type aliases
--> $DIR/type-alias.rs:16:20
Expand All @@ -129,7 +129,7 @@ help: the bound will not be checked when the type alias is used, and should be r
|
LL - type _TaInline5<T: Iterator<Item: for<'a> Into<&'a u8>>> = T;
LL + type _TaInline5<T> = T;
|
|

warning: bounds on generic parameters are not enforced in type aliases
--> $DIR/type-alias.rs:17:20
Expand All @@ -141,7 +141,7 @@ help: the bound will not be checked when the type alias is used, and should be r
|
LL - type _TaInline6<T: Iterator<Item: Iterator<Item: Copy>>> = T;
LL + type _TaInline6<T> = T;
|
|

warning: 12 warnings emitted

6 changes: 3 additions & 3 deletions src/test/ui/associated-types/defaults-specialization.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ error[E0053]: method `make` has an incompatible type for trait
|
LL | default type Ty = bool;
| ----------------------- expected this associated type
LL |
LL |
LL | fn make() -> bool { true }
| ^^^^
| |
Expand All @@ -50,7 +50,7 @@ error[E0308]: mismatched types
|
LL | type Ty = u8;
| ------------- associated type defaults can't be assumed inside the trait defining them
LL |
LL |
LL | fn make() -> Self::Ty {
| -------- expected `<Self as Tr>::Ty` because of return type
LL | 0u8
Expand All @@ -77,7 +77,7 @@ error[E0308]: mismatched types
|
LL | default type Ty = bool;
| ----------------------- expected this associated type
LL |
LL |
LL | fn make() -> Self::Ty { true }
| -------- ^^^^ expected associated type, found `bool`
| |
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/associated-types/issue-22560.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | / trait Sub<Rhs=Self> {
LL | | type Output;
LL | | }
| |_- type parameter `Rhs` must be specified for this
LL |
LL |
LL | type Test = dyn Add + Sub;
| ^^^ help: set the type parameter to the desired type: `Sub<Rhs>`
|
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/associated-types/issue-36499.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ help: try removing the `+`
|
LL - 2 + +2;
LL + 2 + 2;
|
|

error: aborting due to previous error

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ error[E0515]: cannot return value referencing local variable `s`
|
LL | let b = &s[..];
| - `s` is borrowed here
LL |
LL |
LL | Err(b)?;
| ^^^^^^^ returns a value referencing data owned by the current function

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/async-await/issue-70594.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ help: remove the `.await`
|
LL - [1; ().await];
LL + [1; ()];
|
|

error: aborting due to 4 previous errors

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ help: remove these parentheses
|
LL - fn main() { let _a = (async { }); }
LL + fn main() { let _a = async { }; }
|
|

warning: 1 warning emitted

2 changes: 1 addition & 1 deletion src/test/ui/async-await/issues/issue-62009-1.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ help: remove the `.await`
|
LL - (|_| 2333).await;
LL + (|_| 2333);
|
|

error: aborting due to 4 previous errors

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/async-await/unnecessary-await.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ help: remove the `.await`
|
LL - boo().await;
LL + boo();
|
|
help: alternatively, consider making `fn boo` asynchronous
|
LL | async fn boo() {}
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/blind/blind-item-item-shadow.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ error[E0255]: the name `foo` is defined multiple times
|
LL | mod foo { pub mod foo { } }
| ------- previous definition of the module `foo` here
LL |
LL |
LL | use foo::foo;
| ^^^^^^^^ `foo` reimported here
|
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/block-result/issue-5500.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ help: consider removing the borrow
|
LL - &panic!()
LL + panic!()
|
|

error: aborting due to previous error

Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/borrowck/borrow-raw-address-of-borrowed.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immuta
|
LL | let y = &x;
| -- immutable borrow occurs here
LL |
LL |
LL | let q = &raw mut x;
| ^^^^^^^^^^ mutable borrow occurs here
LL |
LL |
LL | drop(y);
| - immutable borrow later used here

Expand All @@ -15,7 +15,7 @@ error[E0502]: cannot borrow `x` as immutable because it is also borrowed as muta
|
LL | let y = &mut x;
| ------ mutable borrow occurs here
LL |
LL |
LL | let p = &raw const x;
| ^^^^^^^^^^^^ immutable borrow occurs here
...
Expand All @@ -30,7 +30,7 @@ LL | let y = &mut x;
...
LL | let q = &raw mut x;
| ^^^^^^^^^^ second mutable borrow occurs here
LL |
LL |
LL | drop(y);
| - first borrow later used here

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
|
LL | let x = &0;
| -- help: consider changing this to be a mutable reference: `&mut 0`
LL |
LL |
LL | let q = &raw mut *x;
| ^^^^^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable

Expand All @@ -12,7 +12,7 @@ error[E0596]: cannot borrow `*x` as mutable, as it is behind a `*const` pointer
|
LL | let x = &0 as *const i32;
| -- help: consider changing this to be a mutable pointer: `&mut 0`
LL |
LL |
LL | let q = &raw mut *x;
| ^^^^^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be borrowed as mutable

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/borrowck/borrow-tuple-fields.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | let r = &x.0;
| ---- borrow of `x.0` occurs here
LL | let y = x;
| ^ move out of `x` occurs here
LL |
LL |
LL | r.use_ref();
| ----------- borrow later used here

Expand Down
Loading