summaryrefslogtreecommitdiffstats
path: root/src/tools/rustfmt/tests/source/pattern.rs
blob: f06d03cadf2f79556e5ae76b151605128087790d (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
88
89
90
// rustfmt-normalize_comments: true
#![feature(exclusive_range_pattern)]
use core::u8::MAX;

fn main() {
    let z = match x {
        "pat1" => 1,
        ( ref  x, ref  mut  y /*comment*/) => 2,
    };

    if let <  T as  Trait   > :: CONST = ident {
        do_smth();
    }

    let Some ( ref   xyz  /*   comment!   */) = opt;

    if let  None  =   opt2 { panic!("oh noes"); }

    let foo@bar (f) = 42;
    let a::foo ( ..) = 42;
    let [ ] = 42;
    let [a,     b,c ] = 42;
    let [ a,b,c ] = 42;
    let [a,    b, c, d,e,f,     g] = 42;
    let foo {   } = 42;
    let foo {..} = 42;
    let foo { x, y: ref foo,     .. } = 42;
    let foo { x, yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: ref foo,     .. } = 42;
    let foo { x,       yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: ref foo,      } = 42;
    let foo { x, yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: ref foo,     .. };
    let foo { x,       yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: ref foo,      };

    match b"12" {
        [0,
        1..MAX
        ] => {}
        _ => {}
    }
}

impl<'a,'b> ResolveGeneratedContentFragmentMutator<'a,'b> {
    fn mutate_fragment(&mut self, fragment: &mut Fragment) {
        match **info {
            GeneratedContentInfo::ContentItem(
                ContentItem::Counter(
                    ref counter_name,
                    counter_style
                )
            ) => {}}}
}

fn issue_1319() {
    if let (Event { .. }, .. ) = ev_state {}
}

fn issue_1874() {
    if let Some(()) = x {
y
    }
}

fn combine_patterns() {
    let x = match y {
        Some(
            Some(
                Foo {
                    z: Bar(..),
                    a: Bar(..),
                    b: Bar(..),
                },
            ),
        ) => z,
        _ => return,
    };
}

fn slice_patterns() {
    match b"123" {
        [0, ..] => {}
        [0, foo] => {}
        _ => {}
    }
}

fn issue3728() {
    let foo = |
    (c,)
        | c;
    foo((1,));
}