Move condition out of maybe_recover_unexpected_comma
.
This commit is contained in:
parent
d4347ed678
commit
7b6c5c76a5
2 changed files with 9 additions and 6 deletions
|
@ -1,7 +1,7 @@
|
||||||
use super::pat::Expected;
|
use super::pat::Expected;
|
||||||
use super::{
|
use super::{
|
||||||
BlockMode, CommaRecoveryMode, Parser, PathStyle, RecoverComma, Restrictions, SemiColonMode,
|
BlockMode, CommaRecoveryMode, Parser, PathStyle, Restrictions, SemiColonMode, SeqSep,
|
||||||
SeqSep, TokenExpectType, TokenType,
|
TokenExpectType, TokenType,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::lexer::UnmatchedBrace;
|
use crate::lexer::UnmatchedBrace;
|
||||||
|
@ -2580,10 +2580,9 @@ impl<'a> Parser<'a> {
|
||||||
crate fn maybe_recover_unexpected_comma(
|
crate fn maybe_recover_unexpected_comma(
|
||||||
&mut self,
|
&mut self,
|
||||||
lo: Span,
|
lo: Span,
|
||||||
rc: RecoverComma,
|
|
||||||
rt: CommaRecoveryMode,
|
rt: CommaRecoveryMode,
|
||||||
) -> PResult<'a, ()> {
|
) -> PResult<'a, ()> {
|
||||||
if rc == RecoverComma::No || self.token != token::Comma {
|
if self.token != token::Comma {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,9 @@ impl<'a> Parser<'a> {
|
||||||
|
|
||||||
// Parse the first pattern (`p_0`).
|
// Parse the first pattern (`p_0`).
|
||||||
let mut first_pat = self.parse_pat_no_top_alt(expected)?;
|
let mut first_pat = self.parse_pat_no_top_alt(expected)?;
|
||||||
self.maybe_recover_unexpected_comma(first_pat.span, rc, rt)?;
|
if rc == RecoverComma::Yes {
|
||||||
|
self.maybe_recover_unexpected_comma(first_pat.span, rt)?;
|
||||||
|
}
|
||||||
|
|
||||||
// If the next token is not a `|`,
|
// If the next token is not a `|`,
|
||||||
// this is not an or-pattern and we should exit here.
|
// this is not an or-pattern and we should exit here.
|
||||||
|
@ -141,7 +143,9 @@ impl<'a> Parser<'a> {
|
||||||
err.span_label(lo, WHILE_PARSING_OR_MSG);
|
err.span_label(lo, WHILE_PARSING_OR_MSG);
|
||||||
err
|
err
|
||||||
})?;
|
})?;
|
||||||
self.maybe_recover_unexpected_comma(pat.span, rc, rt)?;
|
if rc == RecoverComma::Yes {
|
||||||
|
self.maybe_recover_unexpected_comma(pat.span, rt)?;
|
||||||
|
}
|
||||||
pats.push(pat);
|
pats.push(pat);
|
||||||
}
|
}
|
||||||
let or_pattern_span = lo.to(self.prev_token.span);
|
let or_pattern_span = lo.to(self.prev_token.span);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue