Repository: rust-lang/rustfmt (rust)

Issue:
formatting removes part of qualified path inside macro
Pretty niche use case, but running `rustfmt` makes the code no longer compile.

```rust
#![feature(more_qualified_paths)]
macro_rules! show {
    ($ty:ty, $ex:expr) => {
        match $ex {
            <$ty>::A(_val) => println!("got a"), // formatting removes <$ty>::
            <$ty>::B => println!("got b"),
        }
    };
}

#[derive(Debug)]
pub enum Enum1 {
    A(u8),
    B,
}

fn main() {
    show!(Enum1, Enum1::B);
}
```

```sh
$ rustfmt --version
rustfmt 1.4.37-nightly (addb4da 2021-09-25)
```

Pull request description:
Prevent removal of qualified path for tuple struct inside macro
fixes #5005 

This was very similar to #4964 and the fix was to extract and pass along
the ``qself`` of the ``PatKind::TupleStruct``

Patch:
diff --git a/src/patterns.rs b/src/patterns.rs
index 0c6a6f3e..4c6a2d5d 100644
--- a/src/patterns.rs
+++ b/src/patterns.rs
@@ -226,8 +226,9 @@ impl Rewrite for Pat {
             PatKind::Path(ref q_self, ref path) => {
                 rewrite_path(context, PathContext::Expr, q_self.as_ref(), path, shape)
             }
-            PatKind::TupleStruct(_, ref path, ref pat_vec) => {
-                let path_str = rewrite_path(context, PathContext::Expr, None, path, shape)?;
+            PatKind::TupleStruct(ref q_self, ref path, ref pat_vec) => {
+                let path_str =
+                    rewrite_path(context, PathContext::Expr, q_self.as_ref(), path, shape)?;
                 rewrite_tuple_pat(pat_vec, Some(path_str), self.span, context, shape)
             }
             PatKind::Lit(ref expr) => expr.rewrite(context, shape),


Test patch:
diff --git a/tests/target/issue-5005/minimum_example.rs b/tests/target/issue-5005/minimum_example.rs
new file mode 100644
index 00000000..11cc645f
--- /dev/null
+++ b/tests/target/issue-5005/minimum_example.rs
@@ -0,0 +1,9 @@
+#![feature(more_qualified_paths)]
+macro_rules! show {
+    ($ty:ty, $ex:expr) => {
+        match $ex {
+            <$ty>::A(_val) => println!("got a"), // formatting should not remove <$ty>::
+            <$ty>::B => println!("got b"),
+        }
+    };
+}