Skip to content

Commit 0baf61b

Browse files
committed
Increase spacing for suggestions in diagnostics
Make the spacing between the code snippet and verbose structured suggestions consistent with note and help messages.
1 parent 4a8c5b2 commit 0baf61b

File tree

227 files changed

+744
-0
lines changed

Some content is hidden

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

227 files changed

+744
-0
lines changed

src/librustc_errors/emitter.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,6 +1629,19 @@ impl EmitterWriter {
16291629
_ => ()
16301630
}
16311631
}
1632+
if children.is_empty() && suggestions.iter().any(|s| {
1633+
s.style != SuggestionStyle::CompletelyHidden
1634+
}) {
1635+
let mut buffer = StyledBuffer::new();
1636+
if !self.short_message {
1637+
draw_col_separator_no_space(&mut buffer, 0, max_line_num_len + 1);
1638+
}
1639+
match emit_to_destination(&buffer.render(), level, &mut self.dst,
1640+
self.short_message) {
1641+
Ok(()) => (),
1642+
Err(e) => panic!("failed to emit error: {}", e)
1643+
}
1644+
}
16321645
for sugg in suggestions {
16331646
if sugg.style == SuggestionStyle::CompletelyHidden {
16341647
// do not display this suggestion, it is meant only for tools

src/test/rustdoc-ui/intra-links-ambiguity.stderr

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ error: `ambiguous` is both a struct and a function
2323
|
2424
LL | /// [ambiguous] is ambiguous.
2525
| ^^^^^^^^^ ambiguous link
26+
|
2627
help: to link to the struct, prefix with the item type
2728
|
2829
LL | /// [struct@ambiguous] is ambiguous.
@@ -37,6 +38,7 @@ error: `multi_conflict` is a struct, a function, and a macro
3738
|
3839
LL | /// [`multi_conflict`] is a three-way conflict.
3940
| ^^^^^^^^^^^^^^^^ ambiguous link
41+
|
4042
help: to link to the struct, prefix with the item type
4143
|
4244
LL | /// [`struct@multi_conflict`] is a three-way conflict.
@@ -55,6 +57,7 @@ error: `type_and_value` is both a module and a constant
5557
|
5658
LL | /// Ambiguous [type_and_value].
5759
| ^^^^^^^^^^^^^^ ambiguous link
60+
|
5861
help: to link to the module, prefix with the item type
5962
|
6063
LL | /// Ambiguous [module@type_and_value].
@@ -69,6 +72,7 @@ error: `foo::bar` is both an enum and a function
6972
|
7073
LL | /// Ambiguous non-implied shortcut link [`foo::bar`].
7174
| ^^^^^^^^^^ ambiguous link
75+
|
7276
help: to link to the enum, prefix with the item type
7377
|
7478
LL | /// Ambiguous non-implied shortcut link [`enum@foo::bar`].

src/test/rustdoc-ui/invalid-syntax.stderr

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ LL | /// ```
2424
LL | | /// \__________pkt->size___________/ \_result->size_/ \__pkt->size__/
2525
LL | | /// ```
2626
| |_______^
27+
|
2728
help: mark blocks that do not contain Rust code as text
2829
|
2930
LL | /// ```text
@@ -34,6 +35,7 @@ error: unknown start of token: `
3435
|
3536
3 | | ^^^^^^ did you mean `baz::foobar`?
3637
| ^
38+
|
3739
help: Unicode character '`' (Grave Accent) looks like ''' (Single Quote), but it is not
3840
|
3941
3 | | ^^^^^^ did you mean 'baz::foobar`?
@@ -44,6 +46,7 @@ error: unknown start of token: `
4446
|
4547
3 | | ^^^^^^ did you mean `baz::foobar`?
4648
| ^
49+
|
4750
help: Unicode character '`' (Grave Accent) looks like ''' (Single Quote), but it is not
4851
|
4952
3 | | ^^^^^^ did you mean `baz::foobar'?
@@ -59,6 +62,7 @@ LL | | /// LL | use foobar::Baz;
5962
LL | | /// | ^^^^^^ did you mean `baz::foobar`?
6063
LL | | /// ```
6164
| |_______^
65+
|
6266
help: mark blocks that do not contain Rust code as text
6367
|
6468
LL | /// ```text
@@ -78,6 +82,7 @@ LL | /// ```
7882
LL | | /// \_
7983
LL | | /// ```
8084
| |_______^
85+
|
8186
help: mark blocks that do not contain Rust code as text
8287
|
8388
LL | /// ```text
@@ -117,6 +122,7 @@ error: unknown start of token: `
117122
|
118123
1 | ```
119124
| ^
125+
|
120126
help: Unicode character '`' (Grave Accent) looks like ''' (Single Quote), but it is not
121127
|
122128
1 | '``
@@ -127,6 +133,7 @@ error: unknown start of token: `
127133
|
128134
1 | ```
129135
| ^
136+
|
130137
help: Unicode character '`' (Grave Accent) looks like ''' (Single Quote), but it is not
131138
|
132139
1 | `'`
@@ -137,6 +144,7 @@ error: unknown start of token: `
137144
|
138145
1 | ```
139146
| ^
147+
|
140148
help: Unicode character '`' (Grave Accent) looks like ''' (Single Quote), but it is not
141149
|
142150
1 | ``'
@@ -196,6 +204,7 @@ LL | | ///
196204
LL | | ///
197205
LL | | /// ```
198206
| |_______^
207+
|
199208
help: mark blocks that do not contain Rust code as text
200209
|
201210
LL | /// ```text
@@ -236,6 +245,7 @@ error: unknown start of token: `
236245
|
237246
1 | ```
238247
| ^
248+
|
239249
help: Unicode character '`' (Grave Accent) looks like ''' (Single Quote), but it is not
240250
|
241251
1 | '``
@@ -264,6 +274,7 @@ error: unknown start of token: `
264274
|
265275
3 | | ^^^^^^ did you mean `baz::foobar`?
266276
| ^
277+
|
267278
help: Unicode character '`' (Grave Accent) looks like ''' (Single Quote), but it is not
268279
|
269280
3 | | ^^^^^^ did you mean 'baz::foobar`?

src/test/ui/associated-types/associated-types-path-2.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ error[E0308]: mismatched types
33
|
44
LL | f1(2i32, 4i32);
55
| ^^^^ expected u32, found i32
6+
|
67
help: change the type of the numeric literal from `i32` to `u32`
78
|
89
LL | f1(2i32, 4u32);
@@ -43,6 +44,7 @@ error[E0308]: mismatched types
4344
|
4445
LL | let _: i32 = f2(2i32);
4546
| ^^^^^^^^ expected i32, found u32
47+
|
4648
help: you can convert an `u32` to `i32` and panic if the converted value wouldn't fit
4749
|
4850
LL | let _: i32 = f2(2i32).try_into().unwrap();

src/test/ui/async-await/await-keyword/2018-edition-error-in-non-macro-position.stderr

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ error: expected identifier, found keyword `await`
33
|
44
LL | pub mod await {
55
| ^^^^^ expected identifier, found keyword
6+
|
67
help: you can escape reserved keywords to use them as identifiers
78
|
89
LL | pub mod r#await {
@@ -13,6 +14,7 @@ error: expected identifier, found keyword `await`
1314
|
1415
LL | pub struct await;
1516
| ^^^^^ expected identifier, found keyword
17+
|
1618
help: you can escape reserved keywords to use them as identifiers
1719
|
1820
LL | pub struct r#await;
@@ -23,6 +25,7 @@ error: expected identifier, found keyword `await`
2325
|
2426
LL | use self::outer_mod::await::await;
2527
| ^^^^^ expected identifier, found keyword
28+
|
2629
help: you can escape reserved keywords to use them as identifiers
2730
|
2831
LL | use self::outer_mod::r#await::await;
@@ -33,6 +36,7 @@ error: expected identifier, found keyword `await`
3336
|
3437
LL | use self::outer_mod::await::await;
3538
| ^^^^^ expected identifier, found keyword
39+
|
3640
help: you can escape reserved keywords to use them as identifiers
3741
|
3842
LL | use self::outer_mod::await::r#await;
@@ -43,6 +47,7 @@ error: expected identifier, found keyword `await`
4347
|
4448
LL | struct Foo { await: () }
4549
| ^^^^^ expected identifier, found keyword
50+
|
4651
help: you can escape reserved keywords to use them as identifiers
4752
|
4853
LL | struct Foo { r#await: () }
@@ -53,6 +58,7 @@ error: expected identifier, found keyword `await`
5358
|
5459
LL | impl Foo { fn await() {} }
5560
| ^^^^^ expected identifier, found keyword
61+
|
5662
help: you can escape reserved keywords to use them as identifiers
5763
|
5864
LL | impl Foo { fn r#await() {} }
@@ -63,6 +69,7 @@ error: expected identifier, found keyword `await`
6369
|
6470
LL | macro_rules! await {
6571
| ^^^^^ expected identifier, found keyword
72+
|
6673
help: you can escape reserved keywords to use them as identifiers
6774
|
6875
LL | macro_rules! r#await {

src/test/ui/async-await/await-keyword/2018-edition-error.stderr

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ error: expected identifier, found keyword `await`
33
|
44
LL | pub mod await {
55
| ^^^^^ expected identifier, found keyword
6+
|
67
help: you can escape reserved keywords to use them as identifiers
78
|
89
LL | pub mod r#await {
@@ -13,6 +14,7 @@ error: expected identifier, found keyword `await`
1314
|
1415
LL | pub struct await;
1516
| ^^^^^ expected identifier, found keyword
17+
|
1618
help: you can escape reserved keywords to use them as identifiers
1719
|
1820
LL | pub struct r#await;
@@ -23,6 +25,7 @@ error: expected identifier, found keyword `await`
2325
|
2426
LL | use self::outer_mod::await::await;
2527
| ^^^^^ expected identifier, found keyword
28+
|
2629
help: you can escape reserved keywords to use them as identifiers
2730
|
2831
LL | use self::outer_mod::r#await::await;
@@ -33,6 +36,7 @@ error: expected identifier, found keyword `await`
3336
|
3437
LL | use self::outer_mod::await::await;
3538
| ^^^^^ expected identifier, found keyword
39+
|
3640
help: you can escape reserved keywords to use them as identifiers
3741
|
3842
LL | use self::outer_mod::await::r#await;
@@ -43,6 +47,7 @@ error: expected identifier, found keyword `await`
4347
|
4448
LL | macro_rules! await { () => {}; }
4549
| ^^^^^ expected identifier, found keyword
50+
|
4651
help: you can escape reserved keywords to use them as identifiers
4752
|
4853
LL | macro_rules! r#await { () => {}; }

src/test/ui/async-await/no-const-async.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ error: expected identifier, found keyword `async`
33
|
44
LL | pub const async fn x() {}
55
| ^^^^^ expected identifier, found keyword
6+
|
67
help: you can escape reserved keywords to use them as identifiers
78
|
89
LL | pub const r#async fn x() {}

src/test/ui/bad/bad-crate-name.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ error: crate name using dashes are not valid in `extern crate` statements
33
|
44
LL | extern crate krate-name-here;
55
| ^^^^^^^^^^^^^^^ dash-separated idents are not valid
6+
|
67
help: if the original crate name uses dashes you need to use underscores in the code
78
|
89
LL | extern crate krate_name_here;

src/test/ui/borrowck/borrowck-vec-pattern-nesting.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ LL | &mut [_a,
3333
| |
3434
| data moved here
3535
| move occurs because `_a` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait
36+
|
3637
help: consider removing the `&mut`
3738
|
3839
LL | [_a,
@@ -64,6 +65,7 @@ LL | _b] => {}
6465
| |
6566
| data moved here
6667
| move occurs because `_b` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait
68+
|
6769
help: consider removing the `&mut`
6870
|
6971
LL | [

src/test/ui/class-missing-self.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ error[E0425]: cannot find function `sleep` in this scope
99
|
1010
LL | sleep();
1111
| ^^^^^ not found in this scope
12+
|
1213
help: possible candidate is found in another module, you can import it into scope
1314
|
1415
LL | use std::thread::sleep;

src/test/ui/confuse-field-and-method/issue-18343.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ LL | struct Obj<F> where F: FnMut() -> u32 {
66
...
77
LL | o.closure();
88
| ^^^^^^^ field, not a method
9+
|
910
help: to call the function stored in `closure`, surround the field access with parentheses
1011
|
1112
LL | (o.closure)();

src/test/ui/confuse-field-and-method/issue-2392.stderr

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ LL | struct Obj<F> where F: FnOnce() -> u32 {
66
...
77
LL | o_closure.closure();
88
| ^^^^^^^ field, not a method
9+
|
910
help: to call the function stored in `closure`, surround the field access with parentheses
1011
|
1112
LL | (o_closure.closure)();
@@ -30,6 +31,7 @@ LL | struct Obj<F> where F: FnOnce() -> u32 {
3031
...
3132
LL | o_func.closure();
3233
| ^^^^^^^ field, not a method
34+
|
3335
help: to call the function stored in `closure`, surround the field access with parentheses
3436
|
3537
LL | (o_func.closure)();
@@ -43,6 +45,7 @@ LL | struct BoxedObj {
4345
...
4446
LL | boxed_fn.boxed_closure();
4547
| ^^^^^^^^^^^^^ field, not a method
48+
|
4649
help: to call the function stored in `boxed_closure`, surround the field access with parentheses
4750
|
4851
LL | (boxed_fn.boxed_closure)();
@@ -56,6 +59,7 @@ LL | struct BoxedObj {
5659
...
5760
LL | boxed_closure.boxed_closure();
5861
| ^^^^^^^^^^^^^ field, not a method
62+
|
5963
help: to call the function stored in `boxed_closure`, surround the field access with parentheses
6064
|
6165
LL | (boxed_closure.boxed_closure)();
@@ -69,6 +73,7 @@ LL | struct Obj<F> where F: FnOnce() -> u32 {
6973
...
7074
LL | w.wrap.closure();
7175
| ^^^^^^^ field, not a method
76+
|
7277
help: to call the function stored in `closure`, surround the field access with parentheses
7378
|
7479
LL | (w.wrap.closure)();
@@ -93,6 +98,7 @@ LL | struct Obj<F> where F: FnOnce() -> u32 {
9398
...
9499
LL | check_expression().closure();
95100
| ^^^^^^^ field, not a method
101+
|
96102
help: to call the function stored in `closure`, surround the field access with parentheses
97103
|
98104
LL | (check_expression().closure)();
@@ -106,6 +112,7 @@ LL | struct FuncContainer {
106112
...
107113
LL | (*self.container).f1(1);
108114
| ^^ field, not a method
115+
|
109116
help: to call the function stored in `f1`, surround the field access with parentheses
110117
|
111118
LL | ((*self.container).f1)(1);
@@ -119,6 +126,7 @@ LL | struct FuncContainer {
119126
...
120127
LL | (*self.container).f2(1);
121128
| ^^ field, not a method
129+
|
122130
help: to call the function stored in `f2`, surround the field access with parentheses
123131
|
124132
LL | ((*self.container).f2)(1);
@@ -132,6 +140,7 @@ LL | struct FuncContainer {
132140
...
133141
LL | (*self.container).f3(1);
134142
| ^^ field, not a method
143+
|
135144
help: to call the function stored in `f3`, surround the field access with parentheses
136145
|
137146
LL | ((*self.container).f3)(1);

src/test/ui/confuse-field-and-method/issue-32128.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ LL | struct Example {
66
...
77
LL | demo.example(1);
88
| ^^^^^^^ field, not a method
9+
|
910
help: to call the function stored in `example`, surround the field access with parentheses
1011
|
1112
LL | (demo.example)(1);

0 commit comments

Comments
 (0)