diff options
| author | Yacin Tmimi <ytmimi@horizonmedia.com> | 2021-09-27 16:55:23 -0400 |
|---|---|---|
| committer | Caleb Cartwright <calebcartwright@users.noreply.github.com> | 2021-09-27 17:49:10 -0500 |
| commit | a5138b34d5f2644d916e906a3d460856a1b1a42a (patch) | |
| tree | 6913327fdc58c5587429f8ded35826f0c96b29c7 | |
| parent | cb144c35e7d7151bb4b6ccd9b30a4141959166d1 (diff) | |
| download | rust-a5138b34d5f2644d916e906a3d460856a1b1a42a.tar.gz rust-a5138b34d5f2644d916e906a3d460856a1b1a42a.zip | |
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``
| -rw-r--r-- | src/patterns.rs | 5 | ||||
| -rw-r--r-- | tests/target/issue-5005/minimum_example.rs | 9 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/patterns.rs b/src/patterns.rs index 0c6a6f3e814..4c6a2d5d75b 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), diff --git a/tests/target/issue-5005/minimum_example.rs b/tests/target/issue-5005/minimum_example.rs new file mode 100644 index 00000000000..11cc645fa53 --- /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"), + } + }; +} |
