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``
This commit is contained in:
Yacin Tmimi 2021-09-27 16:55:23 -04:00 committed by Caleb Cartwright
parent cb144c35e7
commit a5138b34d5
2 changed files with 12 additions and 2 deletions

View File

@ -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),

View File

@ -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"),
}
};
}