Put leading | in patterns under OrPat

Previously it was one level above, and that caused problems with macros that expand to it, because macros expect to get only one top-level node.
This commit is contained in:
Chayim Refael Friedman 2024-10-27 05:08:49 +02:00
parent 6a67a4d3cd
commit e12a001b55
11 changed files with 87 additions and 31 deletions

View file

@ -1598,6 +1598,10 @@ impl ExprCollector<'_> {
for (id, _) in current_is_used.into_iter() {
binding_list.check_is_used(self, id);
}
if let &[pat] = &*pats {
// Leading pipe without real OR pattern. Leaving an one-item OR pattern may confuse later stages.
return pat;
}
Pat::Or(pats.into())
}
ast::Pat::ParenPat(p) => return self.collect_pat_opt(p.pat(), binding_list),