]> git.lizzy.rs Git - rust.git/blob - tests/source/pattern.rs
Tidy up and pass tests
[rust.git] / tests / source / 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 { panic!("oh noes"); }
15
16     let foo@bar (f) = 42;
17     let a::foo ( ..) = 42;
18     let [ ] = 42;
19     let [a..,     b,c ] = 42;
20     let [ a,b,c.. ] = 42;
21     let [a,    b, c, d..,e,f,     g] = 42;
22     let foo {   } = 42;
23     let foo {..} = 42;
24     let foo { x, y: ref foo,     .. } = 42;
25     let foo { x, yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: ref foo,     .. } = 42;
26     let foo { x,       yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: ref foo,      } = 42;
27     let foo { x, yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: ref foo,     .. };
28     let foo { x,       yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: ref foo,      };
29 }
30
31 impl<'a,'b> ResolveGeneratedContentFragmentMutator<'a,'b> {
32     fn mutate_fragment(&mut self, fragment: &mut Fragment) {
33         match **info {
34             GeneratedContentInfo::ContentItem(
35                 ContentItem::Counter(
36                     ref counter_name,
37                     counter_style
38                 )
39             ) => {}}}
40 }
41
42 fn issue_1319() {
43     if let (Event { .. }, .. ) = ev_state {}
44 }
45
46 fn issue_1874() {
47     if let Some(()) = x {
48 y
49     }
50 }
51
52 fn combine_patterns() {
53     let x = match y {
54         Some(
55             Some(
56                 Foo {
57                     z: Bar(..),
58                     a: Bar(..),
59                     b: Bar(..),
60                 },
61             ),
62         ) => z,
63         _ => return,
64     };
65 }