Commit 2d1ddb5
committed
Auto merge of #116734 - Nadrieril:lint-per-column, r=<try>
Lint `non_exhaustive_omitted_patterns` by columns
This is a rework of the `non_exhaustive_omitted_patterns` lint to make it more consistent. The intent of the lint is to help consumers of `non_exhaustive` enums ensure they stay up-to-date with all upstream variants. This rewrite fixes two cases we didn't handle well before:
First, because of details of exhaustiveness checking, the following wouldn't lint `Enum::C` as missing:
```rust
match Some(x) {
Some(Enum::A) => {}
Some(Enum::B) => {}
_ => {}
}
```
Second, because of the fundamental workings of exhaustiveness checking, the following would treat the `true` and `false` cases separately and thus lint about missing variants:
```rust
match (true, x) {
(true, Enum::A) => {}
(true, Enum::B) => {}
(false, Enum::C) => {}
_ => {}
}
```
Moreover, it would correctly not lint in the case where the pair is flipped, because of asymmetry in how exhaustiveness checking proceeds.
A drawback is that it no longer makes sense to set the lint level per-arm. This will silently break the lint for current users of it (but it's behind a feature gate so that's ok).
The new approach is now independent of the exhaustiveness algorithm; it's a separate pass that looks at patterns column by column. This is another of the motivations for this: I'm glad to move it out of the algorithm, it was akward there.
This PR is almost identical to #111651. cc `@eholk` who reviewed it at the time. Compared to then, I'm more confident this is the right approach.File tree
11 files changed
+540
-369
lines changed- compiler
- rustc_lint_defs/src
- rustc_mir_build/src
- thir/pattern
- tests/ui
- feature-gates
- rfcs/rfc-2008-non-exhaustive
11 files changed
+540
-369
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3953 | 3953 | | |
3954 | 3954 | | |
3955 | 3955 | | |
3956 | | - | |
3957 | | - | |
| 3956 | + | |
| 3957 | + | |
| 3958 | + | |
| 3959 | + | |
| 3960 | + | |
| 3961 | + | |
| 3962 | + | |
3958 | 3963 | | |
3959 | 3964 | | |
3960 | 3965 | | |
| |||
3968 | 3973 | | |
3969 | 3974 | | |
3970 | 3975 | | |
| 3976 | + | |
3971 | 3977 | | |
3972 | 3978 | | |
3973 | | - | |
3974 | 3979 | | |
3975 | 3980 | | |
3976 | 3981 | | |
3977 | 3982 | | |
3978 | 3983 | | |
3979 | 3984 | | |
3980 | 3985 | | |
3981 | | - | |
| 3986 | + | |
3982 | 3987 | | |
3983 | 3988 | | |
3984 | | - | |
3985 | | - | |
| 3989 | + | |
| 3990 | + | |
3986 | 3991 | | |
3987 | 3992 | | |
3988 | 3993 | | |
3989 | 3994 | | |
3990 | 3995 | | |
3991 | 3996 | | |
3992 | | - | |
| 3997 | + | |
3993 | 3998 | | |
3994 | 3999 | | |
3995 | 4000 | | |
| 4001 | + | |
| 4002 | + | |
| 4003 | + | |
| 4004 | + | |
3996 | 4005 | | |
3997 | 4006 | | |
3998 | | - | |
3999 | | - | |
4000 | | - | |
4001 | | - | |
4002 | | - | |
4003 | | - | |
| 4007 | + | |
| 4008 | + | |
| 4009 | + | |
| 4010 | + | |
| 4011 | + | |
4004 | 4012 | | |
4005 | 4013 | | |
4006 | 4014 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
810 | 810 | | |
811 | 811 | | |
812 | 812 | | |
813 | | - | |
| 813 | + | |
814 | 814 | | |
815 | 815 | | |
816 | 816 | | |
| |||
Lines changed: 12 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
272 | | - | |
| 272 | + | |
273 | 273 | | |
274 | 274 | | |
275 | 275 | | |
| |||
431 | 431 | | |
432 | 432 | | |
433 | 433 | | |
434 | | - | |
| 434 | + | |
435 | 435 | | |
436 | 436 | | |
437 | 437 | | |
| |||
622 | 622 | | |
623 | 623 | | |
624 | 624 | | |
625 | | - | |
| 625 | + | |
626 | 626 | | |
627 | 627 | | |
628 | 628 | | |
| |||
661 | 661 | | |
662 | 662 | | |
663 | 663 | | |
664 | | - | |
665 | | - | |
| 664 | + | |
| 665 | + | |
666 | 666 | | |
667 | 667 | | |
668 | 668 | | |
| |||
678 | 678 | | |
679 | 679 | | |
680 | 680 | | |
681 | | - | |
| 681 | + | |
682 | 682 | | |
683 | 683 | | |
684 | 684 | | |
| |||
860 | 860 | | |
861 | 861 | | |
862 | 862 | | |
863 | | - | |
| 863 | + | |
864 | 864 | | |
865 | 865 | | |
866 | | - | |
| 866 | + | |
867 | 867 | | |
868 | 868 | | |
869 | 869 | | |
| |||
880 | 880 | | |
881 | 881 | | |
882 | 882 | | |
883 | | - | |
| 883 | + | |
884 | 884 | | |
885 | 885 | | |
886 | 886 | | |
| |||
891 | 891 | | |
892 | 892 | | |
893 | 893 | | |
894 | | - | |
| 894 | + | |
895 | 895 | | |
896 | 896 | | |
897 | 897 | | |
| |||
922 | 922 | | |
923 | 923 | | |
924 | 924 | | |
925 | | - | |
| 925 | + | |
926 | 926 | | |
927 | 927 | | |
928 | 928 | | |
| |||
0 commit comments