diff options
| author | bors <bors@rust-lang.org> | 2024-03-13 07:17:22 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-03-13 07:17:22 +0000 |
| commit | 762d3170f6d17b541b9306bae1502cef329168e1 (patch) | |
| tree | b822140a2e67628477ac0b2090f68f23313375fa /compiler/rustc_parse/src/parser | |
| parent | 5a6c1aa2bccfcbfa42f486a54c09bd698378faef (diff) | |
| parent | 62e9e46937895e56571957151dce6d865f90f147 (diff) | |
| download | rust-762d3170f6d17b541b9306bae1502cef329168e1.tar.gz rust-762d3170f6d17b541b9306bae1502cef329168e1.zip | |
Auto merge of #122423 - matthiaskrgr:rollup-qywgl45, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - #121820 (pattern analysis: Store field indices in `DeconstructedPat` to avoid virtual wildcards) - #121908 (match lowering: don't collect test alternatives ahead of time) - #122203 (Add `intrinsic_name` to get plain intrinsic name) - #122226 (coverage: Remove or migrate all unstable values of `-Cinstrument-coverage`) - #122255 (Use `min_exhaustive_patterns` in core & std) - #122360 ( Don't Create `ParamCandidate` When Obligation Contains Errors ) - #122383 (Enable PR tracking review assignment for rust-lang/rust) - #122386 (Move `Once` implementations to `sys`) - #122400 (Fix ICE in diagnostics for parenthesized type arguments) - #122410 (rustdoc: do not preload fonts when browsing locally) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -rw-r--r-- | compiler/rustc_parse/src/parser/path.rs | 52 |
1 files changed, 31 insertions, 21 deletions
diff --git a/compiler/rustc_parse/src/parser/path.rs b/compiler/rustc_parse/src/parser/path.rs index 2edf2111de7..163d10d03f0 100644 --- a/compiler/rustc_parse/src/parser/path.rs +++ b/compiler/rustc_parse/src/parser/path.rs @@ -449,9 +449,13 @@ impl<'a> Parser<'a> { prev_token_before_parsing: Token, error: &mut Diag<'_>, ) { - if ((style == PathStyle::Expr && self.parse_paren_comma_seq(|p| p.parse_expr()).is_ok()) - || (style == PathStyle::Pat - && self + match style { + PathStyle::Expr + if let Ok(_) = self + .parse_paren_comma_seq(|p| p.parse_expr()) + .map_err(|error| error.cancel()) => {} + PathStyle::Pat + if let Ok(_) = self .parse_paren_comma_seq(|p| { p.parse_pat_allow_top_alt( None, @@ -460,25 +464,31 @@ impl<'a> Parser<'a> { CommaRecoveryMode::LikelyTuple, ) }) - .is_ok())) - && !matches!(self.token.kind, token::ModSep | token::RArrow) - { - error.span_suggestion_verbose( - prev_token_before_parsing.span, - format!( - "consider removing the `::` here to {}", - match style { - PathStyle::Expr => "call the expression", - PathStyle::Pat => "turn this into a tuple struct pattern", - _ => { - return; - } - } - ), - "", - Applicability::MaybeIncorrect, - ); + .map_err(|error| error.cancel()) => {} + _ => { + return; + } } + + if let token::ModSep | token::RArrow = self.token.kind { + return; + } + + error.span_suggestion_verbose( + prev_token_before_parsing.span, + format!( + "consider removing the `::` here to {}", + match style { + PathStyle::Expr => "call the expression", + PathStyle::Pat => "turn this into a tuple struct pattern", + _ => { + return; + } + } + ), + "", + Applicability::MaybeIncorrect, + ); } /// Parses generic args (within a path segment) with recovery for extra leading angle brackets. |
