From c610b402ae3933c128b63a54fdecf510276e6acc Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 6 Nov 2025 18:34:44 -0800 Subject: [PATCH 1/2] Add test that reproduces misalignment of help under note --- src/tests/ghost-note-help.rs | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/tests/ghost-note-help.rs diff --git a/src/tests/ghost-note-help.rs b/src/tests/ghost-note-help.rs new file mode 100644 index 0000000..dfe967c --- /dev/null +++ b/src/tests/ghost-note-help.rs @@ -0,0 +1,41 @@ +test_normalize! {" +error[E0004]: non-exhaustive patterns: `MyPhantom::__Phantom(_)` not covered + --> src/main.rs:9:11 + | + 9 | match phantom { + | ^^^^^^^ pattern `MyPhantom::__Phantom(_)` not covered + | +note: `MyPhantom` defined here + --> src/main.rs:4:8 + | + 3 | #[phantom] + | ---------- not covered + 4 | struct MyPhantom; + | ^^^^^^^^^ + = note: the matched value is of type `MyPhantom` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +10 ~ MyPhantom => {}, +11 + MyPhantom::__Phantom(_) => todo!() + | +" " +error[E0004]: non-exhaustive patterns: `MyPhantom::__Phantom(_)` not covered + --> src/main.rs:9:11 + | +9 | match phantom { + | ^^^^^^^ pattern `MyPhantom::__Phantom(_)` not covered + | +note: `MyPhantom` defined here + --> src/main.rs:4:8 + | +3 | #[phantom] + | ---------- not covered +4 | struct MyPhantom; + | ^^^^^^^^^ + = note: the matched value is of type `MyPhantom` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +10 ~ MyPhantom => {}, +11 + MyPhantom::__Phantom(_) => todo!() + | +"} From 781a7739862742e8f4d23c6737dbe518c7c3eeb5 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 6 Nov 2025 18:41:20 -0800 Subject: [PATCH 2/2] Normalize indentation of rustc suggestion lines --- src/normalize.rs | 9 +++++++++ src/tests/ghost-note-help.rs | 26 +++++++++++++------------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/normalize.rs b/src/normalize.rs index 699c915..22814c5 100644 --- a/src/normalize.rs +++ b/src/normalize.rs @@ -63,6 +63,7 @@ normalizations! { UnindentMultilineNote, DependencyVersion, HeadingNote, + UnindentSuggestion, // New normalization steps are to be inserted here at the end so that any // snapshots saved before your normalization change remain passing. } @@ -669,6 +670,14 @@ fn indented_line_kind( if spaces > 0 && (rest == "|" || rest.starts_with("| ") + || normalization >= UnindentSuggestion + && digits > 0 + && (rest == "~" + || rest.starts_with("~ ") + || rest == "+" + || rest.starts_with("+ ") + || rest == "-" + || rest.starts_with("- ")) || digits == 0 && (rest.starts_with("--> ") || rest.starts_with("::: ") || rest.starts_with("= "))) { diff --git a/src/tests/ghost-note-help.rs b/src/tests/ghost-note-help.rs index dfe967c..963ab64 100644 --- a/src/tests/ghost-note-help.rs +++ b/src/tests/ghost-note-help.rs @@ -20,21 +20,21 @@ help: ensure that all possible cases are being handled by adding a match arm wit | " " error[E0004]: non-exhaustive patterns: `MyPhantom::__Phantom(_)` not covered - --> src/main.rs:9:11 - | -9 | match phantom { - | ^^^^^^^ pattern `MyPhantom::__Phantom(_)` not covered - | + --> src/main.rs:9:11 + | + 9 | match phantom { + | ^^^^^^^ pattern `MyPhantom::__Phantom(_)` not covered + | note: `MyPhantom` defined here - --> src/main.rs:4:8 - | -3 | #[phantom] - | ---------- not covered -4 | struct MyPhantom; - | ^^^^^^^^^ - = note: the matched value is of type `MyPhantom` + --> src/main.rs:4:8 + | + 3 | #[phantom] + | ---------- not covered + 4 | struct MyPhantom; + | ^^^^^^^^^ + = note: the matched value is of type `MyPhantom` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown - | + | 10 ~ MyPhantom => {}, 11 + MyPhantom::__Phantom(_) => todo!() |