summaryrefslogtreecommitdiffstats
path: root/src/test/ui/parser/match-arm-without-braces.rs
blob: bba38fd0fa4c915fd9b3c3548cbfa4dbfb0b6fcc (plain)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
struct S;

impl S {
    fn get<K, V: Default>(_: K) -> Option<V> {
        Default::default()
    }
}

enum Val {
    Foo,
    Bar,
}

impl Default for Val {
    fn default() -> Self {
        Val::Foo
    }
}

fn main() {
    match S::get(1) {
        Some(Val::Foo) => {}
        _ => {}
    }
    match S::get(2) {
        Some(Val::Foo) => 3; //~ ERROR `match` arm body without braces
        _ => 4,
    }
    match S::get(5) {
        Some(Val::Foo) =>
          7; //~ ERROR `match` arm body without braces
          8;
        _ => 9,
    }
    match S::get(10) {
        Some(Val::Foo) =>
          11; //~ ERROR `match` arm body without braces
          12;
        _ => (),
    }
    match S::get(13) {
        None => {}
        Some(Val::Foo) =>
          14; //~ ERROR `match` arm body without braces
          15;
    }
    match S::get(16) {
        Some(Val::Foo) => 17 //~ ERROR expected `,` following `match` arm
        _ => 18,
    };
    match S::get(19) {
        Some(Val::Foo) =>
          20; //~ ERROR `match` arm body without braces
          21
        _ => 22,
    }
    match S::get(23) {
        Some(Val::Foo) =>
          24; //~ ERROR `match` arm body without braces
          25
        _ => (),
    }
    match S::get(26) {
        None => {}
        Some(Val::Foo) =>
          27; //~ ERROR `match` arm body without braces
          28
    }
    match S::get(29) {
        Some(Val::Foo) =>
          30; //~ ERROR expected one of
          31,
        _ => 32,
    }
    match S::get(33) {
        Some(Val::Foo) =>
          34; //~ ERROR expected one of
          35,
        _ => (),
    }
    match S::get(36) {
        None => {}
        Some(Val::Foo) =>
          37; //~ ERROR expected one of
          38,
    }
}