File: issue-85222-types-containing-non-exhaustive-types.rs

package info (click to toggle)
rustc-web 1.78.0%2Bdfsg1-2~deb12u3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,245,420 kB
  • sloc: xml: 147,985; javascript: 18,022; sh: 11,083; python: 10,265; ansic: 6,172; cpp: 5,023; asm: 4,390; makefile: 4,269
file content (67 lines) | stat: -rw-r--r-- 2,048 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
struct A<T> {
    a: T,
}

struct B<T, U>(T, U);

fn main() {
    match 0 {
        //~^ ERROR non-exhaustive patterns: `usize::MAX..` not covered [E0004]
        0 => (),
        1..=usize::MAX => (),
    }

    match (0usize, 0usize) {
        //~^ ERROR non-exhaustive patterns: `(usize::MAX.., _)` not covered [E0004]
        (0, 0) => (),
        (1..=usize::MAX, 1..=usize::MAX) => (),
    }

    match (0isize, 0usize) {
        //~^ ERROR non-exhaustive patterns: `(..isize::MIN, _)` and `(isize::MAX.., _)` not covered [E0004]
        (isize::MIN..=isize::MAX, 0) => (),
        (isize::MIN..=isize::MAX, 1..=usize::MAX) => (),
    }

    // Should not report note about usize not having fixed max value
    match Some(1usize) {
        //~^ ERROR non-exhaustive patterns: `Some(_)` not covered
        None => {}
    }

    match Some(4) {
        //~^ ERROR non-exhaustive patterns: `Some(usize::MAX..)` not covered
        Some(0) => (),
        Some(1..=usize::MAX) => (),
        None => (),
    }

    match Some(Some(Some(0))) {
        //~^ ERROR non-exhaustive patterns: `Some(Some(Some(usize::MAX..)))` not covered
        Some(Some(Some(0))) => (),
        Some(Some(Some(1..=usize::MAX))) => (),
        Some(Some(None)) => (),
        Some(None) => (),
        None => (),
    }

    match (A { a: 0usize }) {
        //~^ ERROR non-exhaustive patterns: `A { a: usize::MAX.. }` not covered [E0004]
        A { a: 0 } => (),
        A { a: 1..=usize::MAX } => (),
    }

    match B(0isize, 0usize) {
        //~^ ERROR non-exhaustive patterns: `B(..isize::MIN, _)` and `B(isize::MAX.., _)` not covered [E0004]
        B(isize::MIN..=isize::MAX, 0) => (),
        B(isize::MIN..=isize::MAX, 1..=usize::MAX) => (),
    }

    // Should report only the note about usize not having fixed max value and not report
    // report the note about isize
    match B(0isize, 0usize) {
        //~^ ERROR non-exhaustive patterns: `B(_, usize::MAX..)` not covered [E0004]
        B(_, 0) => (),
        B(_, 1..=usize::MAX) => (),
    }
}