diff options
| author | Nadrieril <nadrieril+git@gmail.com> | 2024-03-03 02:22:37 +0100 | 
|---|---|---|
| committer | Nadrieril <nadrieril+git@gmail.com> | 2024-06-16 18:23:48 +0200 | 
| commit | 6b84d7566eaeefe521fdba12c65a9e0b137e34a6 (patch) | |
| tree | 05334d82ef5861ddb2b4b2bd8384d7570f6f4024 /tests/mir-opt/or_pattern.rs | |
| parent | 5639c21fb38d26a72420fe627be25d4f6dfc1f3b (diff) | |
| download | rust-6b84d7566eaeefe521fdba12c65a9e0b137e34a6.tar.gz rust-6b84d7566eaeefe521fdba12c65a9e0b137e34a6.zip  | |
Add tests
Diffstat (limited to 'tests/mir-opt/or_pattern.rs')
| -rw-r--r-- | tests/mir-opt/or_pattern.rs | 24 | 
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/mir-opt/or_pattern.rs b/tests/mir-opt/or_pattern.rs new file mode 100644 index 00000000000..0ad0ce8ead1 --- /dev/null +++ b/tests/mir-opt/or_pattern.rs @@ -0,0 +1,24 @@ +// skip-filecheck + +// EMIT_MIR or_pattern.shortcut_second_or.SimplifyCfg-initial.after.mir +fn shortcut_second_or() { + // Check that after matching `0`, failing to match `2 | 3` skips trying to match `(1, 2 | 3)`. + match ((0, 0), 0) { + (x @ (0, _) | x @ (_, 1), y @ 2 | y @ 3) => {} + _ => {} + } +} + +// EMIT_MIR or_pattern.single_switchint.SimplifyCfg-initial.after.mir +fn single_switchint() { + // Check how many `SwitchInt`s we do. In theory a single one is necessary. + match (1, true) { + (1, true) => 1, + (2, false) => 2, + (1 | 2, true | false) => 3, + (3 | 4, true | false) => 4, + _ => 5, + }; +} + +fn main() {}  | 
