Commit a50a89f
authored
Rollup merge of rust-lang#137409 - estebank:match-arm, r=compiler-errors
Tweak comma handling of "missing match arm" suggestion and fix "remove this arm" suggestion, and make suggestion verbose
Better track trailing commas in match arms. Do not suggest adding trailing comma to match arm with block body. Better heuristic for "is this match in one line".
When encountering an unreachable match arm, (correctly) suggest removing the entire arm:
```
error: a never pattern is always unreachable
--> $DIR/ICE-130779-never-arm-no-oatherwise-block.rs:10:20
|
LL | ! if true => {}
| ^^ this will never be executed
|
help: remove the unreachable match arm
|
LL - ! if true => {}
|
```
Noticed in rust-lang#137343 (comment).
r? `@compiler-errors`
The first commit is independent of the second, but to make the second one produce accurate suggestions the span needs to include the trailing comma, hence the grouping of both changes in this PR.File tree
98 files changed
+1993
-848
lines changed- compiler
- rustc_ast_lowering
- src
- rustc_mir_build/src/thir/pattern
- rustc_parse/src/parser
- src/tools/clippy
- clippy_lints/src/loops
- tests/ui
- tests/ui
- asm
- attributes
- closures/2229_closure_analysis
- match
- consts/const_in_pattern
- coverage-attr
- error-codes
- feature-gates
- force-inlining
- half-open-range-patterns
- match
- postfix-match
- or-patterns
- pattern
- bindings-after-at
- rfc-3627-match-ergonomics-2024/experimental
- usefulness
- integer-ranges
- rfcs
- rfc-0000-never_patterns
- rfc-2005-default-binding-mode
- rfc-2294-if-let-guard
- thir-print
- uninhabited
- unsafe
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
98 files changed
+1993
-848
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
136 | | - | |
| 136 | + | |
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
140 | | - | |
| 140 | + | |
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
335 | 335 | | |
336 | 336 | | |
337 | 337 | | |
338 | | - | |
| 338 | + | |
339 | 339 | | |
340 | 340 | | |
341 | 341 | | |
| |||
344 | 344 | | |
345 | 345 | | |
346 | 346 | | |
347 | | - | |
348 | 347 | | |
| 348 | + | |
| 349 | + | |
349 | 350 | | |
350 | 351 | | |
351 | 352 | | |
352 | 353 | | |
353 | 354 | | |
354 | 355 | | |
355 | | - | |
356 | 356 | | |
| 357 | + | |
| 358 | + | |
357 | 359 | | |
358 | 360 | | |
359 | 361 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
676 | 676 | | |
677 | 677 | | |
678 | 678 | | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
679 | 689 | | |
680 | 690 | | |
681 | 691 | | |
| |||
684 | 694 | | |
685 | 695 | | |
686 | 696 | | |
687 | | - | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
688 | 701 | | |
689 | | - | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
690 | 706 | | |
691 | 707 | | |
692 | 708 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
147 | 148 | | |
148 | 149 | | |
149 | 150 | | |
150 | | - | |
| 151 | + | |
151 | 152 | | |
152 | 153 | | |
153 | 154 | | |
| |||
Lines changed: 61 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
543 | 543 | | |
544 | 544 | | |
545 | 545 | | |
| 546 | + | |
546 | 547 | | |
547 | 548 | | |
548 | 549 | | |
| |||
1210 | 1211 | | |
1211 | 1212 | | |
1212 | 1213 | | |
| 1214 | + | |
1213 | 1215 | | |
1214 | 1216 | | |
1215 | 1217 | | |
| |||
1350 | 1352 | | |
1351 | 1353 | | |
1352 | 1354 | | |
1353 | | - | |
| 1355 | + | |
1354 | 1356 | | |
1355 | | - | |
1356 | | - | |
1357 | | - | |
1358 | | - | |
1359 | | - | |
1360 | | - | |
1361 | | - | |
1362 | | - | |
1363 | | - | |
1364 | | - | |
1365 | 1357 | | |
1366 | | - | |
1367 | | - | |
1368 | | - | |
| 1358 | + | |
| 1359 | + | |
1369 | 1360 | | |
1370 | | - | |
| 1361 | + | |
1371 | 1362 | | |
1372 | | - | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
1373 | 1381 | | |
1374 | 1382 | | |
1375 | 1383 | | |
1376 | 1384 | | |
1377 | 1385 | | |
1378 | 1386 | | |
1379 | | - | |
| 1387 | + | |
1380 | 1388 | | |
1381 | 1389 | | |
1382 | 1390 | | |
1383 | 1391 | | |
1384 | | - | |
1385 | | - | |
1386 | | - | |
1387 | | - | |
1388 | | - | |
1389 | | - | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
1390 | 1408 | | |
1391 | 1409 | | |
1392 | 1410 | | |
| |||
1401 | 1419 | | |
1402 | 1420 | | |
1403 | 1421 | | |
1404 | | - | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
1405 | 1441 | | |
1406 | 1442 | | |
1407 | 1443 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3074 | 3074 | | |
3075 | 3075 | | |
3076 | 3076 | | |
| 3077 | + | |
3077 | 3078 | | |
3078 | 3079 | | |
3079 | 3080 | | |
| |||
3143 | 3144 | | |
3144 | 3145 | | |
3145 | 3146 | | |
| 3147 | + | |
3146 | 3148 | | |
3147 | 3149 | | |
3148 | 3150 | | |
| |||
3183 | 3185 | | |
3184 | 3186 | | |
3185 | 3187 | | |
| 3188 | + | |
| 3189 | + | |
| 3190 | + | |
3186 | 3191 | | |
3187 | | - | |
| 3192 | + | |
| 3193 | + | |
3188 | 3194 | | |
3189 | 3195 | | |
3190 | 3196 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
| 60 | + | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
| 88 | + | |
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
| 102 | + | |
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| |||
0 commit comments