Skip to content

Commit 30347d8

Browse files
committed
Tweak display of multiline notes
``` --> test.rs:3:3 | 3 | a | ^ | = note: foo | bar = note: foo bar ```
1 parent 4b0ab36 commit 30347d8

File tree

180 files changed

+664
-643
lines changed

Some content is hidden

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

180 files changed

+664
-643
lines changed

compiler/rustc_errors/src/emitter.rs

+23-2
Original file line numberDiff line numberDiff line change
@@ -1316,7 +1316,7 @@ impl HumanEmitter {
13161316
padding: usize,
13171317
label: &str,
13181318
override_style: Option<Style>,
1319-
) {
1319+
) -> usize {
13201320
// The extra 5 ` ` is padding that's always needed to align to the `note: `:
13211321
//
13221322
// error: message
@@ -1380,6 +1380,7 @@ impl HumanEmitter {
13801380
buffer.append(line_number, text, style_or_override(*style, override_style));
13811381
}
13821382
}
1383+
line_number
13831384
}
13841385

13851386
#[instrument(level = "trace", skip(self, args), ret)]
@@ -1408,7 +1409,27 @@ impl HumanEmitter {
14081409
buffer.append(0, level.to_str(), Style::MainHeaderMsg);
14091410
buffer.append(0, ": ", Style::NoStyle);
14101411
}
1411-
self.msgs_to_buffer(&mut buffer, msgs, args, max_line_num_len, "note", None);
1412+
let printed_lines = self.msgs_to_buffer(&mut buffer, msgs, args, max_line_num_len, "note", None);
1413+
if is_cont {
1414+
// There's another note after this one, associated to the subwindow above.
1415+
// We write additional vertical lines to join them:
1416+
// ╭▸ test.rs:3:3
1417+
// │
1418+
// 3 │ code
1419+
// │ ━━━━
1420+
// │
1421+
// ├ note: foo
1422+
// │ bar
1423+
// ╰ note: foo
1424+
// bar
1425+
for i in 1..=printed_lines {
1426+
self.draw_col_separator_no_space(
1427+
&mut buffer,
1428+
i,
1429+
max_line_num_len + 1,
1430+
);
1431+
}
1432+
}
14121433
} else {
14131434
let mut label_width = 0;
14141435
// The failure note level itself does not provide any useful diagnostic information

compiler/rustc_parse/src/parser/tests.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1692,7 +1692,7 @@ error: foo
16921692
| ^^^^^^^^^^^^^ `a` is a good letter
16931693
|
16941694
= note: foo
1695-
bar
1695+
| bar
16961696
= note: foo
16971697
bar
16981698
@@ -1705,7 +1705,7 @@ error: foo
17051705
│ ━━━━━━━━━━━━━ `a` is a good letter
17061706
17071707
├ note: foo
1708-
bar
1708+
bar
17091709
╰ note: foo
17101710
bar
17111711

src/tools/clippy/tests/ui/builtin_type_shadow.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ LL | 42
1818
| ^^ expected type parameter `u32`, found integer
1919
|
2020
= note: expected type parameter `u32`
21-
found type `{integer}`
21+
| found type `{integer}`
2222
= note: the caller chooses a type for `u32` which can be different from `i32`
2323

2424
error: aborting due to 2 previous errors

src/tools/clippy/tests/ui/from_over_into_unfixable.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ LL | impl Into<u8> for ContainsVal {
2323
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2424
|
2525
= help: `impl From<Local> for Foreign` is allowed by the orphan rules, for more information see
26-
https://doc.rust-lang.org/reference/items/implementations.html#trait-implementation-coherence
26+
| https://doc.rust-lang.org/reference/items/implementations.html#trait-implementation-coherence
2727
= help: replace the `Into` implementation with `From<ContainsVal>`
2828

2929
error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true

src/tools/clippy/tests/ui/needless_continue.stderr

+25-25
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,31 @@ LL | | }
99
| |_________^
1010
|
1111
= help: consider dropping the `else` clause and merging the code that follows (in the loop) with the `if` block
12-
if i % 2 == 0 && i % 3 == 0 {
13-
println!("{}", i);
14-
println!("{}", i + 1);
15-
if i % 5 == 0 {
16-
println!("{}", i + 2);
17-
}
18-
let i = 0;
19-
println!("bar {} ", i);
20-
// merged code follows:
21-
println!("bleh");
22-
{
23-
println!("blah");
24-
}
25-
if !(!(i == 2) || !(i == 5)) {
26-
println!("lama");
27-
}
28-
if (zero!(i % 2) || nonzero!(i % 5)) && i % 3 != 0 {
29-
30-
continue;
31-
} else {
32-
println!("Blabber");
33-
println!("Jabber");
34-
}
35-
println!("bleh");
36-
}
12+
| if i % 2 == 0 && i % 3 == 0 {
13+
| println!("{}", i);
14+
| println!("{}", i + 1);
15+
| if i % 5 == 0 {
16+
| println!("{}", i + 2);
17+
| }
18+
| let i = 0;
19+
| println!("bar {} ", i);
20+
| // merged code follows:
21+
| println!("bleh");
22+
| {
23+
| println!("blah");
24+
| }
25+
| if !(!(i == 2) || !(i == 5)) {
26+
| println!("lama");
27+
| }
28+
| if (zero!(i % 2) || nonzero!(i % 5)) && i % 3 != 0 {
29+
|
30+
| continue;
31+
| } else {
32+
| println!("Blabber");
33+
| println!("Jabber");
34+
| }
35+
| println!("bleh");
36+
| }
3737
= note: `-D clippy::needless-continue` implied by `-D warnings`
3838
= help: to override `-D warnings` add `#[allow(clippy::needless_continue)]`
3939

src/tools/clippy/tests/ui/permissions_set_readonly_false.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | permissions.set_readonly(false);
66
|
77
= note: on Unix platforms this results in the file being world writable
88
= help: you can set the desired permissions using `PermissionsExt`. For more information, see
9-
https://doc.rust-lang.org/std/os/unix/fs/trait.PermissionsExt.html
9+
| https://doc.rust-lang.org/std/os/unix/fs/trait.PermissionsExt.html
1010
= note: `-D clippy::permissions-set-readonly-false` implied by `-D warnings`
1111
= help: to override `-D warnings` add `#[allow(clippy::permissions_set_readonly_false)]`
1212

tests/rustdoc-ui/intra-doc/warning.stderr

+15-15
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ LL | #[doc = "Foo\nbar [BarD] bar\nbaz"]
7575
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
7676
|
7777
= note: the link appears in this line:
78-
79-
bar [BarD] bar
80-
^^^^
78+
|
79+
| bar [BarD] bar
80+
| ^^^^
8181
= note: no item named `BarD` in scope
8282
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
8383

@@ -88,9 +88,9 @@ LL | f!("Foo\nbar [BarF] bar\nbaz");
8888
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
8989
|
9090
= note: the link appears in this line:
91-
92-
bar [BarF] bar
93-
^^^^
91+
|
92+
| bar [BarF] bar
93+
| ^^^^
9494
= note: no item named `BarF` in scope
9595
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
9696
= note: this warning originates in the macro `f` (in Nightly builds, run with -Z macro-backtrace for more info)
@@ -118,9 +118,9 @@ LL | #[doc = "single line [error]"]
118118
| ^^^^^^^^^^^^^^^^^^^^^
119119
|
120120
= note: the link appears in this line:
121-
122-
single line [error]
123-
^^^^^
121+
|
122+
| single line [error]
123+
| ^^^^^
124124
= note: no item named `error` in scope
125125
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
126126

@@ -131,9 +131,9 @@ LL | #[doc = "single line with \"escaping\" [error]"]
131131
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
132132
|
133133
= note: the link appears in this line:
134-
135-
single line with "escaping" [error]
136-
^^^^^
134+
|
135+
| single line with "escaping" [error]
136+
| ^^^^^
137137
= note: no item named `error` in scope
138138
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
139139

@@ -146,9 +146,9 @@ LL | | /// [error]
146146
| |___________^
147147
|
148148
= note: the link appears in this line:
149-
150-
[error]
151-
^^^^^
149+
|
150+
| [error]
151+
| ^^^^^
152152
= note: no item named `error` in scope
153153
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
154154

tests/rustdoc-ui/macro-docs.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ LL | m!();
88
| ---- in this macro invocation
99
|
1010
= note: the link appears in this line:
11-
12-
[`long_cat`] is really long
13-
^^^^^^^^^^
11+
|
12+
| [`long_cat`] is really long
13+
| ^^^^^^^^^^
1414
= note: no item named `long_cat` in scope
1515
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
1616
= note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default

tests/rustdoc-ui/unescaped_backticks.stderr

+16-16
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,8 @@ LL | | /// level changes.
280280
| |______________________^
281281
|
282282
= help: the opening backtick of a previous inline code may be missing
283-
change: The Subscriber` may be accessed by calling [`WeakDispatch::upgrade`],
284-
to this: The `Subscriber` may be accessed by calling [`WeakDispatch::upgrade`],
283+
| change: The Subscriber` may be accessed by calling [`WeakDispatch::upgrade`],
284+
| to this: The `Subscriber` may be accessed by calling [`WeakDispatch::upgrade`],
285285
= help: if you meant to use a literal backtick, escape it
286286
change: `None`. Otherwise, it will return `Some(Dispatch)`.
287287
to this: `None`. Otherwise, it will return `Some(Dispatch)\`.
@@ -316,8 +316,8 @@ LL | | /// level changes.
316316
| |______________________^
317317
|
318318
= help: a previous inline code might be longer than expected
319-
change: Called before the filtered [`Layer]'s [`on_event`], to determine if
320-
to this: Called before the filtered [`Layer`]'s [`on_event`], to determine if
319+
| change: Called before the filtered [`Layer]'s [`on_event`], to determine if
320+
| to this: Called before the filtered [`Layer`]'s [`on_event`], to determine if
321321
= help: if you meant to use a literal backtick, escape it
322322
change: `on_event` should be called.
323323
to this: `on_event\` should be called.
@@ -335,8 +335,8 @@ LL | | /// level changes.
335335
| |______________________^
336336
|
337337
= help: a previous inline code might be longer than expected
338-
change: Therefore, if the `Filter will change the value returned by this
339-
to this: Therefore, if the `Filter` will change the value returned by this
338+
| change: Therefore, if the `Filter will change the value returned by this
339+
| to this: Therefore, if the `Filter` will change the value returned by this
340340
= help: if you meant to use a literal backtick, escape it
341341
change: [`rebuild_interest_cache`][rebuild] is called after the value of the max
342342
to this: [`rebuild_interest_cache\`][rebuild] is called after the value of the max
@@ -657,8 +657,8 @@ LL | #[doc = concat!("\\", "`")]
657657
| ^^^^^^^^^^^^^^^^^^^^
658658
|
659659
= help: the opening backtick of an inline code may be missing
660-
change: \`
661-
to this: `\`
660+
| change: \`
661+
| to this: `\`
662662
= help: if you meant to use a literal backtick, escape it
663663
change: \`
664664
to this: \\`
@@ -670,8 +670,8 @@ LL | #[doc = "Addition is commutative, which means that add(a, b)` is the same a
670670
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
671671
|
672672
= help: the opening backtick of a previous inline code may be missing
673-
change: Addition is commutative, which means that add(a, b)` is the same as `add(b, a)`.
674-
to this: Addition is commutative, which means that `add(a, b)` is the same as `add(b, a)`.
673+
| change: Addition is commutative, which means that add(a, b)` is the same as `add(b, a)`.
674+
| to this: Addition is commutative, which means that `add(a, b)` is the same as `add(b, a)`.
675675
= help: if you meant to use a literal backtick, escape it
676676
change: Addition is commutative, which means that add(a, b)` is the same as `add(b, a)`.
677677
to this: Addition is commutative, which means that add(a, b)` is the same as `add(b, a)\`.
@@ -683,8 +683,8 @@ LL | #[doc = "Addition is commutative, which means that `add(a, b) is the same a
683683
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
684684
|
685685
= help: a previous inline code might be longer than expected
686-
change: Addition is commutative, which means that `add(a, b) is the same as `add(b, a)`.
687-
to this: Addition is commutative, which means that `add(a, b)` is the same as `add(b, a)`.
686+
| change: Addition is commutative, which means that `add(a, b) is the same as `add(b, a)`.
687+
| to this: Addition is commutative, which means that `add(a, b)` is the same as `add(b, a)`.
688688
= help: if you meant to use a literal backtick, escape it
689689
change: Addition is commutative, which means that `add(a, b) is the same as `add(b, a)`.
690690
to this: Addition is commutative, which means that `add(a, b) is the same as `add(b, a)\`.
@@ -696,8 +696,8 @@ LL | #[doc = "Addition is commutative, which means that `add(a, b)` is the same
696696
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
697697
|
698698
= help: the opening backtick of an inline code may be missing
699-
change: Addition is commutative, which means that `add(a, b)` is the same as add(b, a)`.
700-
to this: Addition is commutative, which means that `add(a, b)` is the same as `add(b, a)`.
699+
| change: Addition is commutative, which means that `add(a, b)` is the same as add(b, a)`.
700+
| to this: Addition is commutative, which means that `add(a, b)` is the same as `add(b, a)`.
701701
= help: if you meant to use a literal backtick, escape it
702702
change: Addition is commutative, which means that `add(a, b)` is the same as add(b, a)`.
703703
to this: Addition is commutative, which means that `add(a, b)` is the same as add(b, a)\`.
@@ -709,8 +709,8 @@ LL | #[doc = "Addition is commutative, which means that `add(a, b)` is the same
709709
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
710710
|
711711
= help: the closing backtick of an inline code may be missing
712-
change: Addition is commutative, which means that `add(a, b)` is the same as `add(b, a).
713-
to this: Addition is commutative, which means that `add(a, b)` is the same as `add(b, a)`.
712+
| change: Addition is commutative, which means that `add(a, b)` is the same as `add(b, a).
713+
| to this: Addition is commutative, which means that `add(a, b)` is the same as `add(b, a)`.
714714
= help: if you meant to use a literal backtick, escape it
715715
change: Addition is commutative, which means that `add(a, b)` is the same as `add(b, a).
716716
to this: Addition is commutative, which means that `add(a, b)` is the same as \`add(b, a).

tests/ui/alloc-error/alloc-error-handler-bad-signature-1.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ LL | | }
3636
| |__- expected `!` because of return type
3737
|
3838
= note: expected type `!`
39-
found unit type `()`
39+
| found unit type `()`
4040
= note: this error originates in the attribute macro `alloc_error_handler` (in Nightly builds, run with -Z macro-backtrace for more info)
4141

4242
error: aborting due to 2 previous errors

tests/ui/alloc-error/alloc-error-handler-bad-signature-2.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ LL | | }
4242
| |__- expected `!` because of return type
4343
|
4444
= note: expected type `!`
45-
found unit type `()`
45+
| found unit type `()`
4646
= note: this error originates in the attribute macro `alloc_error_handler` (in Nightly builds, run with -Z macro-backtrace for more info)
4747

4848
error: aborting due to 2 previous errors

tests/ui/associated-inherent-types/issue-109299-1.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ LL | type X = impl for<T> Fn() -> Lexer<T>::Cursor;
2020
| ^^^^^^ associated item not found in `Lexer<T>`
2121
|
2222
= note: the associated type was found for
23-
- `Lexer<i32>`
23+
| - `Lexer<i32>`
2424
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
2525

2626
error: unconstrained opaque type

tests/ui/associated-inherent-types/issue-109789.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ LL | fn bar(_: Foo<for<'a> fn(&'a ())>::Assoc) {}
1414
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
1515
|
1616
= note: expected struct `Foo<fn(&'static ())>`
17-
found struct `Foo<for<'a> fn(&'a ())>`
17+
| found struct `Foo<for<'a> fn(&'a ())>`
1818
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
1919

2020
error: higher-ranked subtype error

tests/ui/associated-inherent-types/issue-111404-1.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ LL | fn bar(_: fn(Foo<for<'b> fn(Foo<fn(&'b ())>::Assoc)>::Assoc)) {}
1414
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
1515
|
1616
= note: expected struct `Foo<fn(&())>`
17-
found struct `Foo<for<'b> fn(&'b ())>`
17+
| found struct `Foo<for<'b> fn(&'b ())>`
1818
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
1919

2020
error: higher-ranked subtype error

tests/ui/associated-type-bounds/do-not-look-at-parent-item-in-suggestion-for-type-param-of-current-assoc-item.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | let _low = self.lows.remove(low.identify()).unwrap();
77
| arguments to this method are incorrect
88
|
99
= note: expected reference `&I`
10-
found associated type `<impl LowT as Identify>::Id`
10+
| found associated type `<impl LowT as Identify>::Id`
1111
= help: consider constraining the associated type `<impl LowT as Identify>::Id` to `&I`
1212
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
1313
note: method defined here

tests/ui/associated-types/defaults-specialization.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ LL | fn make() -> Self::Ty { 0u8 }
6868
| expected `<A2<T> as Tr>::Ty` because of return type
6969
|
7070
= note: expected associated type `<A2<T> as Tr>::Ty`
71-
found type `u8`
71+
| found type `u8`
7272
= help: consider constraining the associated type `<A2<T> as Tr>::Ty` to `u8` or calling a method that returns `<A2<T> as Tr>::Ty`
7373
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
7474

tests/ui/associated-types/impl-trait-return-missing-constraint.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ LL | bar()
1111
| ----- return type was inferred to be `impl Bar` here
1212
|
1313
= note: expected associated type `<impl Bar as Foo>::Item`
14-
found type `i32`
14+
| found type `i32`
1515
= help: consider constraining the associated type `<impl Bar as Foo>::Item` to `i32` or calling a method that returns `<impl Bar as Foo>::Item`
1616
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
1717
help: consider constraining the associated type `<impl Bar as Foo>::Item` to `i32`

0 commit comments

Comments
 (0)