about summary refs log tree commit diff
path: root/src/tools/rustfmt/tests/source/pattern.rs
diff options
context:
space:
mode:
authorCaleb Cartwright <caleb.cartwright@outlook.com>2021-05-14 21:53:36 -0500
committerCaleb Cartwright <caleb.cartwright@outlook.com>2021-05-14 21:53:36 -0500
commitb2d45c0d4b2d44789000ebec6d702cc27db19782 (patch)
treec3accc00616767e5de0f89f69ce87519f02de6d5 /src/tools/rustfmt/tests/source/pattern.rs
parente659b6de9170c055b6f2d16e2679b22d67297b13 (diff)
parent7872306edf2e11a69aaffb9434088fd66b46a863 (diff)
downloadrust-b2d45c0d4b2d44789000ebec6d702cc27db19782.tar.gz
rust-b2d45c0d4b2d44789000ebec6d702cc27db19782.zip
Add 'src/tools/rustfmt/' from commit '7872306edf2e11a69aaffb9434088fd66b46a863'
git-subtree-dir: src/tools/rustfmt
git-subtree-mainline: e659b6de9170c055b6f2d16e2679b22d67297b13
git-subtree-split: 7872306edf2e11a69aaffb9434088fd66b46a863
Diffstat (limited to 'src/tools/rustfmt/tests/source/pattern.rs')
-rw-r--r--src/tools/rustfmt/tests/source/pattern.rs90
1 files changed, 90 insertions, 0 deletions
diff --git a/src/tools/rustfmt/tests/source/pattern.rs b/src/tools/rustfmt/tests/source/pattern.rs
new file mode 100644
index 00000000000..f06d03cadf2
--- /dev/null
+++ b/src/tools/rustfmt/tests/source/pattern.rs
@@ -0,0 +1,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,));
+}