]> git.lizzy.rs Git - rust.git/blob - tests/target/pattern.rs
Tidy up and pass tests
[rust.git] / tests / target / pattern.rs
1 // rustfmt-normalize_comments: true
2 fn main() {
3     let z = match x {
4         "pat1" => 1,
5         (ref x, ref mut y /* comment */) => 2,
6     };
7
8     if let <T as Trait>::CONST = ident {
9         do_smth();
10     }
11
12     let Some(ref xyz /* comment! */) = opt;
13
14     if let None = opt2 {
15         panic!("oh noes");
16     }
17
18     let foo @ bar(f) = 42;
19     let a::foo(..) = 42;
20     let [] = 42;
21     let [a.., b, c] = 42;
22     let [a, b, c..] = 42;
23     let [a, b, c, d.., e, f, g] = 42;
24     let foo {} = 42;
25     let foo { .. } = 42;
26     let foo { x, y: ref foo, .. } = 42;
27     let foo {
28         x,
29         yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: ref foo,
30         ..
31     } = 42;
32     let foo {
33         x,
34         yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: ref foo,
35     } = 42;
36     let foo {
37         x,
38         yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: ref foo,
39         ..
40     };
41     let foo {
42         x,
43         yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: ref foo,
44     };
45 }
46
47 impl<'a, 'b> ResolveGeneratedContentFragmentMutator<'a, 'b> {
48     fn mutate_fragment(&mut self, fragment: &mut Fragment) {
49         match **info {
50             GeneratedContentInfo::ContentItem(ContentItem::Counter(
51                 ref counter_name,
52                 counter_style,
53             )) => {}
54         }
55     }
56 }
57
58 fn issue_1319() {
59     if let (Event { .. }, ..) = ev_state {}
60 }
61
62 fn issue_1874() {
63     if let Some(()) = x {
64         y
65     }
66 }
67
68 fn combine_patterns() {
69     let x = match y {
70         Some(Some(Foo {
71             z: Bar(..),
72             a: Bar(..),
73             b: Bar(..),
74         })) => z,
75         _ => return,
76     };
77 }