Skip to content

Commit a5138b3

Browse files
ytmimicalebcartwright
authored andcommitted
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``
1 parent cb144c3 commit a5138b3

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Diff for: src/patterns.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,9 @@ impl Rewrite for Pat {
226226
PatKind::Path(ref q_self, ref path) => {
227227
rewrite_path(context, PathContext::Expr, q_self.as_ref(), path, shape)
228228
}
229-
PatKind::TupleStruct(_, ref path, ref pat_vec) => {
230-
let path_str = rewrite_path(context, PathContext::Expr, None, path, shape)?;
229+
PatKind::TupleStruct(ref q_self, ref path, ref pat_vec) => {
230+
let path_str =
231+
rewrite_path(context, PathContext::Expr, q_self.as_ref(), path, shape)?;
231232
rewrite_tuple_pat(pat_vec, Some(path_str), self.span, context, shape)
232233
}
233234
PatKind::Lit(ref expr) => expr.rewrite(context, shape),

Diff for: tests/target/issue-5005/minimum_example.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#![feature(more_qualified_paths)]
2+
macro_rules! show {
3+
($ty:ty, $ex:expr) => {
4+
match $ex {
5+
<$ty>::A(_val) => println!("got a"), // formatting should not remove <$ty>::
6+
<$ty>::B => println!("got b"),
7+
}
8+
};
9+
}

0 commit comments

Comments
 (0)