Move condition out of maybe_recover_colon_colon_in_pat_typo
.
This commit is contained in:
parent
7a37e0c2ff
commit
d4347ed678
2 changed files with 7 additions and 6 deletions
|
@ -1,7 +1,7 @@
|
|||
use super::pat::Expected;
|
||||
use super::{
|
||||
BlockMode, CommaRecoveryMode, Parser, PathStyle, RecoverColon, RecoverComma, Restrictions,
|
||||
SemiColonMode, SeqSep, TokenExpectType, TokenType,
|
||||
BlockMode, CommaRecoveryMode, Parser, PathStyle, RecoverComma, Restrictions, SemiColonMode,
|
||||
SeqSep, TokenExpectType, TokenType,
|
||||
};
|
||||
|
||||
use crate::lexer::UnmatchedBrace;
|
||||
|
@ -2444,10 +2444,9 @@ impl<'a> Parser<'a> {
|
|||
crate fn maybe_recover_colon_colon_in_pat_typo(
|
||||
&mut self,
|
||||
mut first_pat: P<Pat>,
|
||||
ra: RecoverColon,
|
||||
expected: Expected,
|
||||
) -> P<Pat> {
|
||||
if RecoverColon::Yes != ra || token::Colon != self.token.kind {
|
||||
if token::Colon != self.token.kind {
|
||||
return first_pat;
|
||||
}
|
||||
if !matches!(first_pat.kind, PatKind::Ident(_, _, None) | PatKind::Path(..))
|
||||
|
|
|
@ -100,7 +100,7 @@ impl<'a> Parser<'a> {
|
|||
};
|
||||
|
||||
// Parse the first pattern (`p_0`).
|
||||
let 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 the next token is not a `|`,
|
||||
|
@ -111,7 +111,9 @@ impl<'a> Parser<'a> {
|
|||
// This complicated procedure is done purely for diagnostics UX.
|
||||
|
||||
// Check if the user wrote `foo:bar` instead of `foo::bar`.
|
||||
let first_pat = self.maybe_recover_colon_colon_in_pat_typo(first_pat, ra, expected);
|
||||
if ra == RecoverColon::Yes {
|
||||
first_pat = self.maybe_recover_colon_colon_in_pat_typo(first_pat, expected);
|
||||
}
|
||||
|
||||
if let Some(leading_vert_span) = leading_vert_span {
|
||||
// If there was a leading vert, treat this as an or-pattern. This improves
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue