Skip to content

Commit b4f6299

Browse files
authored
Merge pull request #319 from dtolnay/suggestion
Normalize indentation of rustc suggestion lines
2 parents f224ff8 + 781a773 commit b4f6299

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

src/normalize.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ normalizations! {
6363
UnindentMultilineNote,
6464
DependencyVersion,
6565
HeadingNote,
66+
UnindentSuggestion,
6667
// New normalization steps are to be inserted here at the end so that any
6768
// snapshots saved before your normalization change remain passing.
6869
}
@@ -669,6 +670,14 @@ fn indented_line_kind(
669670
if spaces > 0
670671
&& (rest == "|"
671672
|| rest.starts_with("| ")
673+
|| normalization >= UnindentSuggestion
674+
&& digits > 0
675+
&& (rest == "~"
676+
|| rest.starts_with("~ ")
677+
|| rest == "+"
678+
|| rest.starts_with("+ ")
679+
|| rest == "-"
680+
|| rest.starts_with("- "))
672681
|| digits == 0
673682
&& (rest.starts_with("--> ") || rest.starts_with("::: ") || rest.starts_with("= ")))
674683
{

src/tests/ghost-note-help.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
test_normalize! {"
2+
error[E0004]: non-exhaustive patterns: `MyPhantom::__Phantom(_)` not covered
3+
--> src/main.rs:9:11
4+
|
5+
9 | match phantom {
6+
| ^^^^^^^ pattern `MyPhantom::__Phantom(_)` not covered
7+
|
8+
note: `MyPhantom<u8>` defined here
9+
--> src/main.rs:4:8
10+
|
11+
3 | #[phantom]
12+
| ---------- not covered
13+
4 | struct MyPhantom<T: ?Sized>;
14+
| ^^^^^^^^^
15+
= note: the matched value is of type `MyPhantom<u8>`
16+
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
17+
|
18+
10 ~ MyPhantom => {},
19+
11 + MyPhantom::__Phantom(_) => todo!()
20+
|
21+
" "
22+
error[E0004]: non-exhaustive patterns: `MyPhantom::__Phantom(_)` not covered
23+
--> src/main.rs:9:11
24+
|
25+
9 | match phantom {
26+
| ^^^^^^^ pattern `MyPhantom::__Phantom(_)` not covered
27+
|
28+
note: `MyPhantom<u8>` defined here
29+
--> src/main.rs:4:8
30+
|
31+
3 | #[phantom]
32+
| ---------- not covered
33+
4 | struct MyPhantom<T: ?Sized>;
34+
| ^^^^^^^^^
35+
= note: the matched value is of type `MyPhantom<u8>`
36+
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
37+
|
38+
10 ~ MyPhantom => {},
39+
11 + MyPhantom::__Phantom(_) => todo!()
40+
|
41+
"}

0 commit comments

Comments
 (0)