Skip to content

Commit 2e9b294

Browse files
authored
Rollup merge of #143286 - Muscraft:track-diagnostics-note, r=WaffleLapkin
Make -Ztrack-diagnostics emit like a note [#t-compiler/diagnostics > Rendering -Ztrack-diagnostics like a note](https://rust-lang.zulipchat.com/#narrow/channel/147480-t-compiler.2Fdiagnostics/topic/Rendering.20-Ztrack-diagnostics.20like.20a.20note/with/526608647) As discussed on the Zulip thread above, I want to make `-Ztrack-diagnostics` emit like a `note`. This is because I find its current output jarring, and the fact that it gets rendered completely left-aligned, [even in the middle of a snippet](https://github.com/rust-lang/rust/blob/86e05cd300fac9e83e812c4d46582b48db780d8f/tests/ui/track-diagnostics/track6.stderr), seems like something that should be changed. Turning it into a `note` seems like the best choice, as it would align it with the rest of the output, and `note` is already used for somewhat similar things, like seeing why a lint was fired. --- Note: turning `-Ztrack-diagnostics` into a `note` will also make `annotate-snippets` API a bit cleaner
2 parents a4f9d7a + 7060377 commit 2e9b294

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

tests/ui/track-diagnostics-clippy.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ error: casting to the same type is unnecessary (`u32` -> `u32`)
33
|
44
LL | let b = a as u32;
55
| ^^^^^^^^ help: try: `a`
6-
-Ztrack-diagnostics: created at src/tools/clippy/clippy_lints/src/casts/unnecessary_cast.rs:LL:CC
76
|
7+
= note: -Ztrack-diagnostics: created at src/tools/clippy/clippy_lints/src/casts/unnecessary_cast.rs:LL:CC
88
= note: `-D clippy::unnecessary-cast` implied by `-D warnings`
99
= help: to override `-D warnings` add `#[allow(clippy::unnecessary_cast)]`
1010

@@ -15,8 +15,8 @@ LL | let d = 42;
1515
| ----------- unnecessary `let` binding
1616
LL | d
1717
| ^
18-
-Ztrack-diagnostics: created at src/tools/clippy/clippy_lints/src/returns.rs:LL:CC
1918
|
19+
= note: -Ztrack-diagnostics: created at src/tools/clippy/clippy_lints/src/returns.rs:LL:CC
2020
= note: `-D clippy::let-and-return` implied by `-D warnings`
2121
= help: to override `-D warnings` add `#[allow(clippy::let_and_return)]`
2222
help: return the expression directly

tests/ui/track-diagnostics.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ struct A;
88
struct B;
99
const S: A = B;
1010
//~^ ERROR: mismatched types
11+
//~| NOTE: created at
1112

1213
fn main() {}

tests/ui/track-diagnostics.stderr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ error[E0308]: mismatched types
33
|
44
LL | const S: A = B;
55
| ^ expected `A`, found `B`
6-
-Ztrack-diagnostics: created at compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs:LL:CC
6+
|
7+
= note: -Ztrack-diagnostics: created at compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs:LL:CC
78

89
error: aborting due to 1 previous error
910

0 commit comments

Comments
 (0)