mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
Merge pull request #18419 from ChayimFriedman2/leading-or
fix: Put leading `|` in patterns under `OrPat`
This commit is contained in:
commit
3b3a87fe9b
11 changed files with 87 additions and 31 deletions
|
@ -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),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue