Skip to content

Commit 550b0ad

Browse files
committed
make experimental pattern typing features mutually exclusive
This aims to reduce the complexity needed in the boolean logic for telling which rules we're using to type patterns. If we still want the functionality this removes, we can re-add it later, after some cleanup to pattern typing.
1 parent 1f81f90 commit 550b0ad

File tree

5 files changed

+16
-184
lines changed

5 files changed

+16
-184
lines changed

compiler/rustc_feature/src/unstable.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,8 @@ impl Features {
718718

719719
/// Some features are not allowed to be used together at the same time, if
720720
/// the two are present, produce an error.
721-
///
722-
/// Currently empty, but we will probably need this again in the future,
723-
/// so let's keep it in for now.
724-
pub const INCOMPATIBLE_FEATURES: &[(Symbol, Symbol)] = &[];
721+
pub const INCOMPATIBLE_FEATURES: &[(Symbol, Symbol)] = &[
722+
// Experimental match ergonomics rulesets are incompatible with each other, to simplify the
723+
// boolean logic required to tell which typing rules to use.
724+
(sym::ref_pat_eat_one_layer_2024, sym::ref_pat_eat_one_layer_2024_structural),
725+
];

tests/ui/match/ref_pat_eat_one_layer_2024/ref_pat_eat_one_layer_2021.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
//@ run-pass
22
//@ edition: 2021
3-
//@ revisions: classic structural both
3+
//@ revisions: classic structural
44
#![allow(incomplete_features)]
5-
#![cfg_attr(any(classic, both), feature(ref_pat_eat_one_layer_2024))]
6-
#![cfg_attr(any(structural, both), feature(ref_pat_eat_one_layer_2024_structural))]
5+
#![cfg_attr(classic, feature(ref_pat_eat_one_layer_2024))]
6+
#![cfg_attr(structural, feature(ref_pat_eat_one_layer_2024_structural))]
77

88
pub fn main() {
99
if let &Some(Some(x)) = &Some(&mut Some(0)) {

tests/ui/match/ref_pat_eat_one_layer_2024/ref_pat_eat_one_layer_2024.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
//@ run-pass
22
//@ edition: 2024
3-
//@ revisions: classic structural both
3+
//@ revisions: classic structural
44
#![allow(incomplete_features)]
5-
#![cfg_attr(any(classic, both), feature(ref_pat_eat_one_layer_2024))]
6-
#![cfg_attr(any(structural, both), feature(ref_pat_eat_one_layer_2024_structural))]
5+
#![cfg_attr(classic, feature(ref_pat_eat_one_layer_2024))]
6+
#![cfg_attr(structural, feature(ref_pat_eat_one_layer_2024_structural))]
77

88
pub fn main() {
99
if let Some(Some(&x)) = &Some(&Some(0)) {
@@ -54,11 +54,11 @@ pub fn main() {
5454
if let Some(&Some(x)) = &mut Some(Some(0)) {
5555
let _: u32 = x;
5656
}
57-
#[cfg(any(classic, both))]
57+
#[cfg(classic)]
5858
if let Some(&mut x) = &mut Some(&0) {
5959
let _: &u32 = x;
6060
}
61-
#[cfg(any(structural, both))]
61+
#[cfg(structural)]
6262
if let Some(&mut x) = &Some(&mut 0) {
6363
let _: &u32 = x;
6464
}

tests/ui/match/ref_pat_eat_one_layer_2024/ref_pat_eat_one_layer_2024_fail.both.stderr

Lines changed: 0 additions & 169 deletions
This file was deleted.

tests/ui/match/ref_pat_eat_one_layer_2024/ref_pat_eat_one_layer_2024_fail.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//@ edition: 2024
2-
//@ revisions: classic structural both
2+
//@ revisions: classic structural
33
#![allow(incomplete_features)]
4-
#![cfg_attr(any(classic, both), feature(ref_pat_eat_one_layer_2024))]
5-
#![cfg_attr(any(structural, both), feature(ref_pat_eat_one_layer_2024_structural))]
4+
#![cfg_attr(classic, feature(ref_pat_eat_one_layer_2024))]
5+
#![cfg_attr(structural, feature(ref_pat_eat_one_layer_2024_structural))]
66

77
pub fn main() {
88
if let Some(&mut Some(&_)) = &Some(&Some(0)) {

0 commit comments

Comments
 (0)