diff options
| author | bors <bors@rust-lang.org> | 2023-09-26 13:38:28 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-09-26 13:38:28 +0000 |
| commit | 1f2bacf677c585761e05e41ebab6ebf3af4216f5 (patch) | |
| tree | ef48e08f82990bd6bbbf7d2c2b7faed56bc37bfc /tests | |
| parent | 8bf0dec101dc458a411401a826994006abd2f022 (diff) | |
| parent | a1d6fc43403fadc5564af50d6212d45d9aace84d (diff) | |
| download | rust-1f2bacf677c585761e05e41ebab6ebf3af4216f5.tar.gz rust-1f2bacf677c585761e05e41ebab6ebf3af4216f5.zip | |
Auto merge of #115893 - RalfJung:match-require-partial-eq, r=oli-obk
lint towards rejecting consts in patterns that do not implement PartialEq I think we definitely don't want to allow such consts, so even while the general plan around structural matching is up in the air, we can start the process of getting non-PartialEq matches out of the ecosystem.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/consts/const_in_pattern/issue-65466.rs | 3 | ||||
| -rw-r--r-- | tests/ui/consts/const_in_pattern/issue-65466.stderr | 23 | ||||
| -rw-r--r-- | tests/ui/match/issue-72896-non-partial-eq-const.rs (renamed from tests/ui/match/issue-72896.rs) | 3 | ||||
| -rw-r--r-- | tests/ui/match/issue-72896-non-partial-eq-const.stderr | 23 |
4 files changed, 50 insertions, 2 deletions
diff --git a/tests/ui/consts/const_in_pattern/issue-65466.rs b/tests/ui/consts/const_in_pattern/issue-65466.rs index 2b421f4c705..d45c32e170a 100644 --- a/tests/ui/consts/const_in_pattern/issue-65466.rs +++ b/tests/ui/consts/const_in_pattern/issue-65466.rs @@ -15,7 +15,8 @@ const C: &[O<B>] = &[O::None]; fn main() { let x = O::None; match &[x][..] { - C => (), + C => (), //~WARN: the type must implement `PartialEq` + //~| previously accepted _ => (), } } diff --git a/tests/ui/consts/const_in_pattern/issue-65466.stderr b/tests/ui/consts/const_in_pattern/issue-65466.stderr new file mode 100644 index 00000000000..9c80cb3a849 --- /dev/null +++ b/tests/ui/consts/const_in_pattern/issue-65466.stderr @@ -0,0 +1,23 @@ +warning: to use a constant of type `&[O<B>]` in a pattern, the type must implement `PartialEq` + --> $DIR/issue-65466.rs:18:9 + | +LL | C => (), + | ^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #116122 <https://github.com/rust-lang/rust/issues/116122> + = note: `#[warn(const_patterns_without_partial_eq)]` on by default + +warning: 1 warning emitted + +Future incompatibility report: Future breakage diagnostic: +warning: to use a constant of type `&[O<B>]` in a pattern, the type must implement `PartialEq` + --> $DIR/issue-65466.rs:18:9 + | +LL | C => (), + | ^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #116122 <https://github.com/rust-lang/rust/issues/116122> + = note: `#[warn(const_patterns_without_partial_eq)]` on by default + diff --git a/tests/ui/match/issue-72896.rs b/tests/ui/match/issue-72896-non-partial-eq-const.rs index 3a8b8203731..a3095f0be83 100644 --- a/tests/ui/match/issue-72896.rs +++ b/tests/ui/match/issue-72896-non-partial-eq-const.rs @@ -17,7 +17,8 @@ const CONST_SET: EnumSet<Enum8> = EnumSet { __enumset_underlying: 3 }; fn main() { match CONST_SET { - CONST_SET => { /* ok */ } + CONST_SET => { /* ok */ } //~WARN: must implement `PartialEq` + //~| previously accepted _ => panic!("match fell through?"), } } diff --git a/tests/ui/match/issue-72896-non-partial-eq-const.stderr b/tests/ui/match/issue-72896-non-partial-eq-const.stderr new file mode 100644 index 00000000000..a7fc0cfc054 --- /dev/null +++ b/tests/ui/match/issue-72896-non-partial-eq-const.stderr @@ -0,0 +1,23 @@ +warning: to use a constant of type `EnumSet<Enum8>` in a pattern, the type must implement `PartialEq` + --> $DIR/issue-72896-non-partial-eq-const.rs:20:9 + | +LL | CONST_SET => { /* ok */ } + | ^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #116122 <https://github.com/rust-lang/rust/issues/116122> + = note: `#[warn(const_patterns_without_partial_eq)]` on by default + +warning: 1 warning emitted + +Future incompatibility report: Future breakage diagnostic: +warning: to use a constant of type `EnumSet<Enum8>` in a pattern, the type must implement `PartialEq` + --> $DIR/issue-72896-non-partial-eq-const.rs:20:9 + | +LL | CONST_SET => { /* ok */ } + | ^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #116122 <https://github.com/rust-lang/rust/issues/116122> + = note: `#[warn(const_patterns_without_partial_eq)]` on by default + |
