Skip to content

Commit 0cb9899

Browse files
committed
Auto merge of rust-lang#97892 - klensy:fix-spaces, r=oli-obk
diagnostics: remove trailing spaces Remove few occurrences of trailing spaces and drive by fix of needless alloc of const string.
2 parents 43c47db + 6fc412f commit 0cb9899

File tree

275 files changed

+737
-733
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

275 files changed

+737
-733
lines changed

compiler/rustc_errors/src/emitter.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -771,8 +771,12 @@ impl EmitterWriter {
771771
self
772772
}
773773

774-
fn maybe_anonymized(&self, line_num: usize) -> String {
775-
if self.ui_testing { ANONYMIZED_LINE_NUM.to_string() } else { line_num.to_string() }
774+
fn maybe_anonymized(&self, line_num: usize) -> Cow<'static, str> {
775+
if self.ui_testing {
776+
Cow::Borrowed(ANONYMIZED_LINE_NUM)
777+
} else {
778+
Cow::Owned(line_num.to_string())
779+
}
776780
}
777781

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

822-
draw_col_separator(buffer, line_offset, width_offset - 2);
826+
draw_col_separator_no_space(buffer, line_offset, width_offset - 2);
823827
}
824828

825829
fn render_source_line(
@@ -1929,7 +1933,7 @@ impl EmitterWriter {
19291933
// Only show an underline in the suggestions if the suggestion is not the
19301934
// entirety of the code being shown and the displayed code is not multiline.
19311935
if let DisplaySuggestion::Diff | DisplaySuggestion::Underline = show_code_change {
1932-
draw_col_separator(&mut buffer, row_num, max_line_num_len + 1);
1936+
draw_col_separator_no_space(&mut buffer, row_num, max_line_num_len + 1);
19331937
for part in parts {
19341938
let span_start_pos = sm.lookup_char_pos(part.span.lo()).col_display;
19351939
let span_end_pos = sm.lookup_char_pos(part.span.hi()).col_display;

src/test/rustdoc-ui/intra-doc/disambiguator-mismatch.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ help: to link to the macro, add an exclamation mark
6868
|
6969
LL - /// Link to [derive@m]
7070
LL + /// Link to [m!]
71-
|
71+
|
7272

7373
error: unresolved link to `m`
7474
--> $DIR/disambiguator-mismatch.rs:46:14
@@ -124,7 +124,7 @@ help: to link to the constant, prefix with `const@`
124124
|
125125
LL - /// Link to [c()]
126126
LL + /// Link to [const@c]
127-
|
127+
|
128128

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

141141
error: unresolved link to `std`
142142
--> $DIR/disambiguator-mismatch.rs:77:14

src/test/rustdoc-ui/intra-doc/errors.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ help: to link to the associated function, add parentheses
9898
|
9999
LL - /// [type@Vec::into_iter]
100100
LL + /// [Vec::into_iter()]
101-
|
101+
|
102102

103103
error: unresolved link to `S`
104104
--> $DIR/errors.rs:68:6
@@ -110,7 +110,7 @@ help: to link to the struct, prefix with `struct@`
110110
|
111111
LL - /// [S!]
112112
LL + /// [struct@S]
113-
|
113+
|
114114

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

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

139139
error: unresolved link to `T::h`
140140
--> $DIR/errors.rs:91:6

src/test/rustdoc-ui/test-compile-fail1.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ error[E0428]: the name `f` is defined multiple times
33
|
44
6 | pub fn f() {}
55
| ---------- previous definition of the value `f` here
6-
7 |
6+
7 |
77
8 | pub fn f() {}
88
| ^^^^^^^^^^ `f` redefined here
99
|

src/test/ui/argument-suggestions/issue-97484.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ help: consider removing the ``
1616
|
1717
LL - foo(&&A, B, C, D, E, F, G);
1818
LL + foo(&&A, B, C, D, E, F, G);
19-
|
19+
|
2020
help: remove the extra arguments
2121
|
2222
LL | foo(&&A, D, {&E}, G);

src/test/ui/asm/type-check-1.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ help: consider removing the borrow
5858
|
5959
LL - asm!("{}", const &0);
6060
LL + asm!("{}", const 0);
61-
|
61+
|
6262

6363
error: invalid asm output
6464
--> $DIR/type-check-1.rs:15:29

src/test/ui/associated-type-bounds/type-alias.stderr

+12-12
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ help: the clause will not be checked when the type alias is used, and should be
99
|
1010
LL - type _TaWhere1<T> where T: Iterator<Item: Copy> = T;
1111
LL + type _TaWhere1<T> = T;
12-
|
12+
|
1313

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

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

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

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

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

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

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

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

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

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

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

146146
warning: 12 warnings emitted
147147

src/test/ui/associated-types/defaults-specialization.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ error[E0053]: method `make` has an incompatible type for trait
3030
|
3131
LL | default type Ty = bool;
3232
| ----------------------- expected this associated type
33-
LL |
33+
LL |
3434
LL | fn make() -> bool { true }
3535
| ^^^^
3636
| |
@@ -50,7 +50,7 @@ error[E0308]: mismatched types
5050
|
5151
LL | type Ty = u8;
5252
| ------------- associated type defaults can't be assumed inside the trait defining them
53-
LL |
53+
LL |
5454
LL | fn make() -> Self::Ty {
5555
| -------- expected `<Self as Tr>::Ty` because of return type
5656
LL | 0u8
@@ -77,7 +77,7 @@ error[E0308]: mismatched types
7777
|
7878
LL | default type Ty = bool;
7979
| ----------------------- expected this associated type
80-
LL |
80+
LL |
8181
LL | fn make() -> Self::Ty { true }
8282
| -------- ^^^^ expected associated type, found `bool`
8383
| |

src/test/ui/associated-types/issue-22560.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | / trait Sub<Rhs=Self> {
55
LL | | type Output;
66
LL | | }
77
| |_- type parameter `Rhs` must be specified for this
8-
LL |
8+
LL |
99
LL | type Test = dyn Add + Sub;
1010
| ^^^ help: set the type parameter to the desired type: `Sub<Rhs>`
1111
|

src/test/ui/associated-types/issue-36499.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ help: try removing the `+`
88
|
99
LL - 2 + +2;
1010
LL + 2 + 2;
11-
|
11+
|
1212

1313
error: aborting due to previous error
1414

src/test/ui/async-await/issue-67765-async-diagnostic.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ error[E0515]: cannot return value referencing local variable `s`
33
|
44
LL | let b = &s[..];
55
| - `s` is borrowed here
6-
LL |
6+
LL |
77
LL | Err(b)?;
88
| ^^^^^^^ returns a value referencing data owned by the current function
99

src/test/ui/async-await/issue-70594.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ help: remove the `.await`
3131
|
3232
LL - [1; ().await];
3333
LL + [1; ()];
34-
|
34+
|
3535

3636
error: aborting due to 4 previous errors
3737

src/test/ui/async-await/issues/issue-54752-async-block.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ help: remove these parentheses
99
|
1010
LL - fn main() { let _a = (async { }); }
1111
LL + fn main() { let _a = async { }; }
12-
|
12+
|
1313

1414
warning: 1 warning emitted
1515

src/test/ui/async-await/issues/issue-62009-1.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ help: remove the `.await`
3737
|
3838
LL - (|_| 2333).await;
3939
LL + (|_| 2333);
40-
|
40+
|
4141

4242
error: aborting due to 4 previous errors
4343

src/test/ui/async-await/unnecessary-await.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ help: remove the `.await`
1313
|
1414
LL - boo().await;
1515
LL + boo();
16-
|
16+
|
1717
help: alternatively, consider making `fn boo` asynchronous
1818
|
1919
LL | async fn boo() {}

src/test/ui/blind/blind-item-item-shadow.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ error[E0255]: the name `foo` is defined multiple times
33
|
44
LL | mod foo { pub mod foo { } }
55
| ------- previous definition of the module `foo` here
6-
LL |
6+
LL |
77
LL | use foo::foo;
88
| ^^^^^^^^ `foo` reimported here
99
|

src/test/ui/block-result/issue-5500.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ help: consider removing the borrow
1212
|
1313
LL - &panic!()
1414
LL + panic!()
15-
|
15+
|
1616

1717
error: aborting due to previous error
1818

src/test/ui/borrowck/borrow-raw-address-of-borrowed.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immuta
33
|
44
LL | let y = &x;
55
| -- immutable borrow occurs here
6-
LL |
6+
LL |
77
LL | let q = &raw mut x;
88
| ^^^^^^^^^^ mutable borrow occurs here
9-
LL |
9+
LL |
1010
LL | drop(y);
1111
| - immutable borrow later used here
1212

@@ -15,7 +15,7 @@ error[E0502]: cannot borrow `x` as immutable because it is also borrowed as muta
1515
|
1616
LL | let y = &mut x;
1717
| ------ mutable borrow occurs here
18-
LL |
18+
LL |
1919
LL | let p = &raw const x;
2020
| ^^^^^^^^^^^^ immutable borrow occurs here
2121
...
@@ -30,7 +30,7 @@ LL | let y = &mut x;
3030
...
3131
LL | let q = &raw mut x;
3232
| ^^^^^^^^^^ second mutable borrow occurs here
33-
LL |
33+
LL |
3434
LL | drop(y);
3535
| - first borrow later used here
3636

src/test/ui/borrowck/borrow-raw-address-of-deref-mutability.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
33
|
44
LL | let x = &0;
55
| -- help: consider changing this to be a mutable reference: `&mut 0`
6-
LL |
6+
LL |
77
LL | let q = &raw mut *x;
88
| ^^^^^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable
99

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

src/test/ui/borrowck/borrow-tuple-fields.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | let r = &x.0;
55
| ---- borrow of `x.0` occurs here
66
LL | let y = x;
77
| ^ move out of `x` occurs here
8-
LL |
8+
LL |
99
LL | r.use_ref();
1010
| ----------- borrow later used here
1111

0 commit comments

Comments
 (0)