Commit e641393
committed
[
Currently the lint faces a severe limitation: since it only catches single-line block, running rustfmt beforehand will remove all occurences of it, because it breaks them into multiline blocks.
We do not check match `Arm` for two reasons:
- In case it does not use commas to separate arms, removing the block would result in a compilation error
Example:
```
match expr {
pat => {()}
_ => println!("foo")
}
```
- Do not lint multiline match arms used for formatting reasons
```
match expr {
pat => {
somewhat_long_expression
}
// ...
}
```
Delete `unused-braces-lint` test
The modified lint correctly provide a span in its suggestion.
```shell
error: unnecessary braces around block return value
--> /rust/src/test/rustdoc-ui/unused-braces-lint.rs:9:5
|
LL | / {
LL | | {
| |________^
LL | use std;
LL | }
| __________^
LL | | }
| |_____^
|
note: the lint level is defined here
--> /rust/src/test/rustdoc-ui/unused-braces-lint.rs:6:9
|
LL | #![deny(unused_braces)]
| ^^^^^^^^^^^^^
help: remove these braces
|
LL ~ {
LL | use std;
LL ~ }
|
```
It is unclear to which extend #70814 is still an issue, as the inital MCVE does not trigger the lint on stable either,[rust playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=b6ff31a449c0b73a08daac8ee43b1fa6)
Fix code with expanded `unused_braces` lint
Also allow `unused_braces` on tests
Mute `unused_braces` on `match_ast!`unused_braces] Lint multiline blocks as long as not in arms1 parent 7919ef0 commit e641393
File tree
32 files changed
+193
-198
lines changed- compiler
- rustc_codegen_cranelift/src
- intrinsics
- rustc_codegen_llvm/src/debuginfo
- rustc_codegen_ssa/src/mir
- rustc_expand/src
- rustc_lint/src
- rustc_middle/src/ty
- rustc_mir_build/src/thir/pattern
- rustc_save_analysis/src
- rustc_span/src
- rustc_trait_selection/src/traits/select
- rustc_ty_utils/src
- library
- core/src
- iter/adapters
- ptr
- std/src
- collections/hash
- io
- test/src
- src
- librustdoc/clean
- tools
- clippy/tests/ui
- rust-analyzer/crates
- ide-completion/src/context
- syntax/src
- tests
- rustdoc-ui
- ui
- drop
- lint
- statics
32 files changed
+193
-198
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | | - | |
56 | | - | |
| 55 | + | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
295 | 295 | | |
296 | 296 | | |
297 | 297 | | |
298 | | - | |
299 | | - | |
300 | | - | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
649 | 649 | | |
650 | 650 | | |
651 | 651 | | |
652 | | - | |
653 | | - | |
654 | | - | |
655 | | - | |
656 | | - | |
657 | | - | |
658 | | - | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
659 | 657 | | |
660 | 658 | | |
661 | 659 | | |
662 | 660 | | |
663 | 661 | | |
664 | 662 | | |
665 | | - | |
666 | | - | |
667 | | - | |
668 | | - | |
669 | | - | |
670 | | - | |
671 | | - | |
672 | | - | |
673 | | - | |
674 | | - | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
675 | 668 | | |
676 | 669 | | |
677 | 670 | | |
678 | 671 | | |
679 | 672 | | |
680 | 673 | | |
681 | | - | |
682 | | - | |
683 | | - | |
684 | | - | |
685 | | - | |
686 | | - | |
687 | | - | |
688 | | - | |
689 | | - | |
690 | | - | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
691 | 682 | | |
692 | 683 | | |
693 | 684 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
465 | 465 | | |
466 | 466 | | |
467 | 467 | | |
468 | | - | |
469 | | - | |
470 | | - | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
477 | 476 | | |
478 | 477 | | |
479 | 478 | | |
480 | | - | |
481 | | - | |
482 | | - | |
483 | | - | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
484 | 483 | | |
485 | | - | |
486 | | - | |
487 | | - | |
488 | | - | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
489 | 487 | | |
490 | 488 | | |
491 | 489 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
678 | 678 | | |
679 | 679 | | |
680 | 680 | | |
681 | | - | |
682 | | - | |
683 | | - | |
684 | | - | |
685 | | - | |
686 | | - | |
687 | | - | |
688 | | - | |
689 | | - | |
690 | | - | |
691 | | - | |
692 | | - | |
693 | | - | |
694 | | - | |
695 | | - | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
696 | 692 | | |
697 | 693 | | |
698 | 694 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
147 | | - | |
148 | | - | |
| 147 | + | |
| 148 | + | |
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
156 | | - | |
157 | | - | |
| 156 | + | |
| 157 | + | |
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1199 | 1199 | | |
1200 | 1200 | | |
1201 | 1201 | | |
1202 | | - | |
1203 | | - | |
1204 | | - | |
1205 | | - | |
1206 | | - | |
1207 | | - | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
1208 | 1206 | | |
1209 | 1207 | | |
1210 | 1208 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1116 | 1116 | | |
1117 | 1117 | | |
1118 | 1118 | | |
1119 | | - | |
1120 | | - | |
1121 | | - | |
1122 | | - | |
1123 | | - | |
1124 | | - | |
1125 | | - | |
1126 | | - | |
1127 | | - | |
1128 | 1119 | | |
1129 | 1120 | | |
1130 | 1121 | | |
| |||
1133 | 1124 | | |
1134 | 1125 | | |
1135 | 1126 | | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
1136 | 1145 | | |
1137 | 1146 | | |
1138 | 1147 | | |
1139 | 1148 | | |
1140 | 1149 | | |
1141 | 1150 | | |
1142 | 1151 | | |
1143 | | - | |
1144 | 1152 | | |
1145 | 1153 | | |
1146 | 1154 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
488 | 488 | | |
489 | 489 | | |
490 | 490 | | |
491 | | - | |
| 491 | + | |
492 | 492 | | |
493 | | - | |
| 493 | + | |
494 | 494 | | |
495 | 495 | | |
496 | 496 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
964 | 964 | | |
965 | 965 | | |
966 | 966 | | |
967 | | - | |
968 | | - | |
969 | | - | |
970 | | - | |
971 | | - | |
972 | | - | |
973 | | - | |
974 | | - | |
975 | | - | |
976 | | - | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
977 | 976 | | |
978 | | - | |
979 | | - | |
980 | | - | |
981 | | - | |
982 | | - | |
983 | | - | |
984 | | - | |
985 | | - | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
986 | 985 | | |
987 | | - | |
| 986 | + | |
988 | 987 | | |
989 | | - | |
990 | | - | |
991 | | - | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
992 | 991 | | |
993 | | - | |
994 | | - | |
995 | | - | |
| 992 | + | |
| 993 | + | |
996 | 994 | | |
997 | 995 | | |
998 | 996 | | |
| |||
0 commit comments