From 8fd345dd4b85b6758896995beb5b0417efd52364 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 4 Oct 2023 01:35:07 +0000 Subject: [PATCH] review comments --- compiler/rustc_parse/src/parser/expr.rs | 5 ++--- tests/ui/parser/missing-fat-arrow.rs | 5 +---- tests/ui/parser/missing-fat-arrow.stderr | 10 +++++----- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 2f8e3bb6497..91bb2d9eb66 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -2998,7 +2998,6 @@ fn parse_match_guard_condition(&mut self) -> PResult<'a, P> { } else { Applicability::MaybeIncorrect }; - // self.recover_stmt_(SemiColonMode::Ignore, BlockMode::Ignore); err.span_suggestion_verbose(sugg_sp, msg, "=> ".to_string(), applicability); } } @@ -3171,7 +3170,7 @@ pub(super) fn parse_struct_fields( self.token.span.shrink_to_lo(), "try naming a field", &format!("{ident}: ", ), - Applicability::HasPlaceholders, + Applicability::MaybeIncorrect, ); } if in_if_guard && close_delim == Delimiter::Brace { @@ -3325,7 +3324,7 @@ fn parse_expr_field(&mut self) -> PResult<'a, ExprField> { // Check if a colon exists one ahead. This means we're parsing a fieldname. let is_shorthand = !this.look_ahead(1, |t| t == &token::Colon || t == &token::Eq); - // Proactively check whether parsing the field will be correct. + // Proactively check whether parsing the field will be incorrect. let is_wrong = this.token.is_ident() && !this.token.is_reserved_ident() && !this.look_ahead(1, |t| { diff --git a/tests/ui/parser/missing-fat-arrow.rs b/tests/ui/parser/missing-fat-arrow.rs index fef16129cd0..325f1ccf2fd 100644 --- a/tests/ui/parser/missing-fat-arrow.rs +++ b/tests/ui/parser/missing-fat-arrow.rs @@ -6,11 +6,8 @@ fn main() { match value { Some(x) if x == y { self.next_token()?; //~ ERROR expected identifier, found keyword `self` - Ok(true) }, - _ => { - Ok(false) - } + _ => {} } let _: i32 = (); //~ ERROR mismatched types } diff --git a/tests/ui/parser/missing-fat-arrow.stderr b/tests/ui/parser/missing-fat-arrow.stderr index abfed7a5683..a6c786905e9 100644 --- a/tests/ui/parser/missing-fat-arrow.stderr +++ b/tests/ui/parser/missing-fat-arrow.stderr @@ -12,7 +12,7 @@ LL | Some(x) if x == y => { | ++ error: expected one of `,`, `:`, or `}`, found `.` - --> $DIR/missing-fat-arrow.rs:25:14 + --> $DIR/missing-fat-arrow.rs:22:14 | LL | Some(a) if a.value == b { | - while parsing this struct @@ -31,7 +31,7 @@ LL | Some(a) if a.value == b => { | ++ error: expected one of `,`, `:`, or `}`, found `.` - --> $DIR/missing-fat-arrow.rs:35:14 + --> $DIR/missing-fat-arrow.rs:32:14 | LL | Some(a) if a.value == b { | - while parsing this struct @@ -50,7 +50,7 @@ LL | Some(a) if a.value == b => { | ++ error[E0308]: mismatched types - --> $DIR/missing-fat-arrow.rs:15:18 + --> $DIR/missing-fat-arrow.rs:12:18 | LL | let _: i32 = (); | --- ^^ expected `i32`, found `()` @@ -58,7 +58,7 @@ LL | let _: i32 = (); | expected due to this error[E0308]: mismatched types - --> $DIR/missing-fat-arrow.rs:29:18 + --> $DIR/missing-fat-arrow.rs:26:18 | LL | let _: i32 = (); | --- ^^ expected `i32`, found `()` @@ -66,7 +66,7 @@ LL | let _: i32 = (); | expected due to this error[E0308]: mismatched types - --> $DIR/missing-fat-arrow.rs:40:18 + --> $DIR/missing-fat-arrow.rs:37:18 | LL | let _: i32 = (); | --- ^^ expected `i32`, found `()`