Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Oct 4, 2023
1 parent 18ec4e9 commit 8fd345d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
5 changes: 2 additions & 3 deletions compiler/rustc_parse/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2998,7 +2998,6 @@ impl<'a> Parser<'a> {
} else {
Applicability::MaybeIncorrect
};
// self.recover_stmt_(SemiColonMode::Ignore, BlockMode::Ignore);
err.span_suggestion_verbose(sugg_sp, msg, "=> ".to_string(), applicability);
}
}
Expand Down Expand Up @@ -3171,7 +3170,7 @@ impl<'a> Parser<'a> {
self.token.span.shrink_to_lo(),
"try naming a field",
&format!("{ident}: ", ),
Applicability::HasPlaceholders,
Applicability::MaybeIncorrect,
);
}
if in_if_guard && close_delim == Delimiter::Brace {
Expand Down Expand Up @@ -3325,7 +3324,7 @@ impl<'a> Parser<'a> {

// 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| {
Expand Down
5 changes: 1 addition & 4 deletions tests/ui/parser/missing-fat-arrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
10 changes: 5 additions & 5 deletions tests/ui/parser/missing-fat-arrow.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -50,23 +50,23 @@ 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 `()`
| |
| 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 `()`
| |
| 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 `()`
Expand Down

0 comments on commit 8fd345d

Please sign in to comment.