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

Increase spacing for suggestions in diagnostics #65773

Merged
merged 2 commits into from
Oct 26, 2019
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
27 changes: 13 additions & 14 deletions src/librustc_errors/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1583,27 +1583,26 @@ impl EmitterWriter {
Ok(())
}

fn emit_messages_default(&mut self,
level: &Level,
message: &[(String, Style)],
code: &Option<DiagnosticId>,
span: &MultiSpan,
children: &[SubDiagnostic],
suggestions: &[CodeSuggestion]) {
fn emit_messages_default(
&mut self,
level: &Level,
message: &[(String, Style)],
code: &Option<DiagnosticId>,
span: &MultiSpan,
children: &[SubDiagnostic],
suggestions: &[CodeSuggestion],
) {
let max_line_num_len = if self.ui_testing {
ANONYMIZED_LINE_NUM.len()
} else {
self.get_max_line_num(span, children).to_string().len()
};

match self.emit_message_default(span,
message,
code,
level,
max_line_num_len,
false) {
match self.emit_message_default(span, message, code, level, max_line_num_len, false) {
Ok(()) => {
if !children.is_empty() {
if !children.is_empty() || suggestions.iter().any(|s| {
s.style != SuggestionStyle::CompletelyHidden
}) {
let mut buffer = StyledBuffer::new();
if !self.short_message {
draw_col_separator_no_space(&mut buffer, 0, max_line_num_len + 1);
Expand Down
4 changes: 4 additions & 0 deletions src/test/rustdoc-ui/intra-links-ambiguity.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ error: `ambiguous` is both a struct and a function
|
LL | /// [ambiguous] is ambiguous.
| ^^^^^^^^^ ambiguous link
|
help: to link to the struct, prefix with the item type
|
LL | /// [struct@ambiguous] is ambiguous.
Expand All @@ -37,6 +38,7 @@ error: `multi_conflict` is a struct, a function, and a macro
|
LL | /// [`multi_conflict`] is a three-way conflict.
| ^^^^^^^^^^^^^^^^ ambiguous link
|
help: to link to the struct, prefix with the item type
|
LL | /// [`struct@multi_conflict`] is a three-way conflict.
Expand All @@ -55,6 +57,7 @@ error: `type_and_value` is both a module and a constant
|
LL | /// Ambiguous [type_and_value].
| ^^^^^^^^^^^^^^ ambiguous link
|
help: to link to the module, prefix with the item type
|
LL | /// Ambiguous [module@type_and_value].
Expand All @@ -69,6 +72,7 @@ error: `foo::bar` is both an enum and a function
|
LL | /// Ambiguous non-implied shortcut link [`foo::bar`].
| ^^^^^^^^^^ ambiguous link
|
help: to link to the enum, prefix with the item type
|
LL | /// Ambiguous non-implied shortcut link [`enum@foo::bar`].
Expand Down
11 changes: 11 additions & 0 deletions src/test/rustdoc-ui/invalid-syntax.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ LL | /// ```
LL | | /// \__________pkt->size___________/ \_result->size_/ \__pkt->size__/
LL | | /// ```
| |_______^
|
help: mark blocks that do not contain Rust code as text
|
LL | /// ```text
Expand All @@ -34,6 +35,7 @@ error: unknown start of token: `
|
3 | | ^^^^^^ did you mean `baz::foobar`?
| ^
|
help: Unicode character '`' (Grave Accent) looks like ''' (Single Quote), but it is not
|
3 | | ^^^^^^ did you mean 'baz::foobar`?
Expand All @@ -44,6 +46,7 @@ error: unknown start of token: `
|
3 | | ^^^^^^ did you mean `baz::foobar`?
| ^
|
help: Unicode character '`' (Grave Accent) looks like ''' (Single Quote), but it is not
|
3 | | ^^^^^^ did you mean `baz::foobar'?
Expand All @@ -59,6 +62,7 @@ LL | | /// LL | use foobar::Baz;
LL | | /// | ^^^^^^ did you mean `baz::foobar`?
LL | | /// ```
| |_______^
|
help: mark blocks that do not contain Rust code as text
|
LL | /// ```text
Expand All @@ -78,6 +82,7 @@ LL | /// ```
LL | | /// \_
LL | | /// ```
| |_______^
|
help: mark blocks that do not contain Rust code as text
|
LL | /// ```text
Expand Down Expand Up @@ -117,6 +122,7 @@ error: unknown start of token: `
|
1 | ```
| ^
|
help: Unicode character '`' (Grave Accent) looks like ''' (Single Quote), but it is not
|
1 | '``
Expand All @@ -127,6 +133,7 @@ error: unknown start of token: `
|
1 | ```
| ^
|
help: Unicode character '`' (Grave Accent) looks like ''' (Single Quote), but it is not
|
1 | `'`
Expand All @@ -137,6 +144,7 @@ error: unknown start of token: `
|
1 | ```
| ^
|
help: Unicode character '`' (Grave Accent) looks like ''' (Single Quote), but it is not
|
1 | ``'
Expand Down Expand Up @@ -196,6 +204,7 @@ LL | | ///
LL | | ///
LL | | /// ```
| |_______^
|
help: mark blocks that do not contain Rust code as text
|
LL | /// ```text
Expand Down Expand Up @@ -236,6 +245,7 @@ error: unknown start of token: `
|
1 | ```
| ^
|
help: Unicode character '`' (Grave Accent) looks like ''' (Single Quote), but it is not
|
1 | '``
Expand Down Expand Up @@ -264,6 +274,7 @@ error: unknown start of token: `
|
3 | | ^^^^^^ did you mean `baz::foobar`?
| ^
|
help: Unicode character '`' (Grave Accent) looks like ''' (Single Quote), but it is not
|
3 | | ^^^^^^ did you mean 'baz::foobar`?
Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/associated-types/associated-types-path-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ error[E0308]: mismatched types
|
LL | f1(2i32, 4i32);
| ^^^^ expected u32, found i32
|
help: change the type of the numeric literal from `i32` to `u32`
|
LL | f1(2i32, 4u32);
Expand Down Expand Up @@ -43,6 +44,7 @@ error[E0308]: mismatched types
|
LL | let _: i32 = f2(2i32);
| ^^^^^^^^ expected i32, found u32
|
help: you can convert an `u32` to `i32` and panic if the converted value wouldn't fit
|
LL | let _: i32 = f2(2i32).try_into().unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ error: expected identifier, found keyword `await`
|
LL | pub mod await {
| ^^^^^ expected identifier, found keyword
|
help: you can escape reserved keywords to use them as identifiers
|
LL | pub mod r#await {
Expand All @@ -13,6 +14,7 @@ error: expected identifier, found keyword `await`
|
LL | pub struct await;
| ^^^^^ expected identifier, found keyword
|
help: you can escape reserved keywords to use them as identifiers
|
LL | pub struct r#await;
Expand All @@ -23,6 +25,7 @@ error: expected identifier, found keyword `await`
|
LL | use self::outer_mod::await::await;
| ^^^^^ expected identifier, found keyword
|
help: you can escape reserved keywords to use them as identifiers
|
LL | use self::outer_mod::r#await::await;
Expand All @@ -33,6 +36,7 @@ error: expected identifier, found keyword `await`
|
LL | use self::outer_mod::await::await;
| ^^^^^ expected identifier, found keyword
|
help: you can escape reserved keywords to use them as identifiers
|
LL | use self::outer_mod::await::r#await;
Expand All @@ -43,6 +47,7 @@ error: expected identifier, found keyword `await`
|
LL | struct Foo { await: () }
| ^^^^^ expected identifier, found keyword
|
help: you can escape reserved keywords to use them as identifiers
|
LL | struct Foo { r#await: () }
Expand All @@ -53,6 +58,7 @@ error: expected identifier, found keyword `await`
|
LL | impl Foo { fn await() {} }
| ^^^^^ expected identifier, found keyword
|
help: you can escape reserved keywords to use them as identifiers
|
LL | impl Foo { fn r#await() {} }
Expand All @@ -63,6 +69,7 @@ error: expected identifier, found keyword `await`
|
LL | macro_rules! await {
| ^^^^^ expected identifier, found keyword
|
help: you can escape reserved keywords to use them as identifiers
|
LL | macro_rules! r#await {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ error: expected identifier, found keyword `await`
|
LL | pub mod await {
| ^^^^^ expected identifier, found keyword
|
help: you can escape reserved keywords to use them as identifiers
|
LL | pub mod r#await {
Expand All @@ -13,6 +14,7 @@ error: expected identifier, found keyword `await`
|
LL | pub struct await;
| ^^^^^ expected identifier, found keyword
|
help: you can escape reserved keywords to use them as identifiers
|
LL | pub struct r#await;
Expand All @@ -23,6 +25,7 @@ error: expected identifier, found keyword `await`
|
LL | use self::outer_mod::await::await;
| ^^^^^ expected identifier, found keyword
|
help: you can escape reserved keywords to use them as identifiers
|
LL | use self::outer_mod::r#await::await;
Expand All @@ -33,6 +36,7 @@ error: expected identifier, found keyword `await`
|
LL | use self::outer_mod::await::await;
| ^^^^^ expected identifier, found keyword
|
help: you can escape reserved keywords to use them as identifiers
|
LL | use self::outer_mod::await::r#await;
Expand All @@ -43,6 +47,7 @@ error: expected identifier, found keyword `await`
|
LL | macro_rules! await { () => {}; }
| ^^^^^ expected identifier, found keyword
|
help: you can escape reserved keywords to use them as identifiers
|
LL | macro_rules! r#await { () => {}; }
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/async-await/no-const-async.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ error: expected identifier, found keyword `async`
|
LL | pub const async fn x() {}
| ^^^^^ expected identifier, found keyword
|
help: you can escape reserved keywords to use them as identifiers
|
LL | pub const r#async fn x() {}
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/bad/bad-crate-name.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ error: crate name using dashes are not valid in `extern crate` statements
|
LL | extern crate krate-name-here;
| ^^^^^^^^^^^^^^^ dash-separated idents are not valid
|
help: if the original crate name uses dashes you need to use underscores in the code
|
LL | extern crate krate_name_here;
Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/borrowck/borrowck-vec-pattern-nesting.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ LL | &mut [_a,
| |
| data moved here
| move occurs because `_a` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait
|
help: consider removing the `&mut`
|
LL | [_a,
Expand Down Expand Up @@ -64,6 +65,7 @@ LL | _b] => {}
| |
| data moved here
| move occurs because `_b` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait
|
help: consider removing the `&mut`
|
LL | [
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/class-missing-self.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ error[E0425]: cannot find function `sleep` in this scope
|
LL | sleep();
| ^^^^^ not found in this scope
|
help: possible candidate is found in another module, you can import it into scope
|
LL | use std::thread::sleep;
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/confuse-field-and-method/issue-18343.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ LL | struct Obj<F> where F: FnMut() -> u32 {
...
LL | o.closure();
| ^^^^^^^ field, not a method
|
help: to call the function stored in `closure`, surround the field access with parentheses
|
LL | (o.closure)();
Expand Down
9 changes: 9 additions & 0 deletions src/test/ui/confuse-field-and-method/issue-2392.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ LL | struct Obj<F> where F: FnOnce() -> u32 {
...
LL | o_closure.closure();
| ^^^^^^^ field, not a method
|
help: to call the function stored in `closure`, surround the field access with parentheses
|
LL | (o_closure.closure)();
Expand All @@ -30,6 +31,7 @@ LL | struct Obj<F> where F: FnOnce() -> u32 {
...
LL | o_func.closure();
| ^^^^^^^ field, not a method
|
help: to call the function stored in `closure`, surround the field access with parentheses
|
LL | (o_func.closure)();
Expand All @@ -43,6 +45,7 @@ LL | struct BoxedObj {
...
LL | boxed_fn.boxed_closure();
| ^^^^^^^^^^^^^ field, not a method
|
help: to call the function stored in `boxed_closure`, surround the field access with parentheses
|
LL | (boxed_fn.boxed_closure)();
Expand All @@ -56,6 +59,7 @@ LL | struct BoxedObj {
...
LL | boxed_closure.boxed_closure();
| ^^^^^^^^^^^^^ field, not a method
|
help: to call the function stored in `boxed_closure`, surround the field access with parentheses
|
LL | (boxed_closure.boxed_closure)();
Expand All @@ -69,6 +73,7 @@ LL | struct Obj<F> where F: FnOnce() -> u32 {
...
LL | w.wrap.closure();
| ^^^^^^^ field, not a method
|
help: to call the function stored in `closure`, surround the field access with parentheses
|
LL | (w.wrap.closure)();
Expand All @@ -93,6 +98,7 @@ LL | struct Obj<F> where F: FnOnce() -> u32 {
...
LL | check_expression().closure();
| ^^^^^^^ field, not a method
|
help: to call the function stored in `closure`, surround the field access with parentheses
|
LL | (check_expression().closure)();
Expand All @@ -106,6 +112,7 @@ LL | struct FuncContainer {
...
LL | (*self.container).f1(1);
| ^^ field, not a method
|
help: to call the function stored in `f1`, surround the field access with parentheses
|
LL | ((*self.container).f1)(1);
Expand All @@ -119,6 +126,7 @@ LL | struct FuncContainer {
...
LL | (*self.container).f2(1);
| ^^ field, not a method
|
help: to call the function stored in `f2`, surround the field access with parentheses
|
LL | ((*self.container).f2)(1);
Expand All @@ -132,6 +140,7 @@ LL | struct FuncContainer {
...
LL | (*self.container).f3(1);
| ^^ field, not a method
|
help: to call the function stored in `f3`, surround the field access with parentheses
|
LL | ((*self.container).f3)(1);
Expand Down
Loading