]> git.proxmox.com Git - rustc.git/blame - src/tools/rustfmt/tests/target/pattern.rs
New upstream version 1.52.1+dfsg1
[rustc.git] / src / tools / rustfmt / tests / target / pattern.rs
CommitLineData
f20569fa
XL
1// rustfmt-normalize_comments: true
2#![feature(exclusive_range_pattern)]
3use core::u8::MAX;
4
5fn main() {
6 let z = match x {
7 "pat1" => 1,
8 (ref x, ref mut y /* comment */) => 2,
9 };
10
11 if let <T as Trait>::CONST = ident {
12 do_smth();
13 }
14
15 let Some(ref xyz /* comment! */) = opt;
16
17 if let None = opt2 {
18 panic!("oh noes");
19 }
20
21 let foo @ bar(f) = 42;
22 let a::foo(..) = 42;
23 let [] = 42;
24 let [a, b, c] = 42;
25 let [a, b, c] = 42;
26 let [a, b, c, d, e, f, g] = 42;
27 let foo {} = 42;
28 let foo { .. } = 42;
29 let foo { x, y: ref foo, .. } = 42;
30 let foo {
31 x,
32 yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: ref foo,
33 ..
34 } = 42;
35 let foo {
36 x,
37 yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: ref foo,
38 } = 42;
39 let foo {
40 x,
41 yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: ref foo,
42 ..
43 };
44 let foo {
45 x,
46 yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: ref foo,
47 };
48
49 match b"12" {
50 [0, 1..MAX] => {}
51 _ => {}
52 }
53}
54
55impl<'a, 'b> ResolveGeneratedContentFragmentMutator<'a, 'b> {
56 fn mutate_fragment(&mut self, fragment: &mut Fragment) {
57 match **info {
58 GeneratedContentInfo::ContentItem(ContentItem::Counter(
59 ref counter_name,
60 counter_style,
61 )) => {}
62 }
63 }
64}
65
66fn issue_1319() {
67 if let (Event { .. }, ..) = ev_state {}
68}
69
70fn issue_1874() {
71 if let Some(()) = x {
72 y
73 }
74}
75
76fn combine_patterns() {
77 let x = match y {
78 Some(Some(Foo {
79 z: Bar(..),
80 a: Bar(..),
81 b: Bar(..),
82 })) => z,
83 _ => return,
84 };
85}
86
87fn slice_patterns() {
88 match b"123" {
89 [0, ..] => {}
90 [0, foo] => {}
91 _ => {}
92 }
93}
94
95fn issue3728() {
96 let foo = |(c,)| c;
97 foo((1,));
98}