File: or_pattern.rs

package info (click to toggle)
rustc 1.87.0%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 925,564 kB
  • sloc: xml: 158,127; python: 36,039; javascript: 19,761; sh: 19,737; cpp: 18,981; ansic: 13,133; asm: 4,376; makefile: 710; perl: 29; lisp: 28; ruby: 19; sql: 11
file content (24 lines) | stat: -rw-r--r-- 675 bytes parent folder | download | duplicates (17)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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() {}