diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-07-30 22:51:38 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-30 22:51:38 +0200 |
| commit | 6f0b237c72851932748120549fe2feeb537124cf (patch) | |
| tree | 211ae2827e910f511c4d74432cff58d441d27293 /compiler/rustc_parse/src/parser/expr.rs | |
| parent | 894db1f22f9c028f73ddeb4e623e6750295345af (diff) | |
| parent | 4776ac0f885044685c6f6127632f42522a88c05d (diff) | |
| download | rust-6f0b237c72851932748120549fe2feeb537124cf.tar.gz rust-6f0b237c72851932748120549fe2feeb537124cf.zip | |
Rollup merge of #128376 - compiler-errors:finish-ur-vegetables, r=jieyouxu
Mark `Parser::eat`/`check` methods as `#[must_use]` These methods return a `bool`, but we probably should either use these values or explicitly throw them away (e.g. when we just want to unconditionally eat a token if it exists). I changed a few places from `eat` to `expect`, but otherwise I tried to leave a comment explaining why the `eat` was okay. This also adds a test for the `pattern_type!` macro, which used to silently accept a missing `is` token.
Diffstat (limited to 'compiler/rustc_parse/src/parser/expr.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/expr.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index a242dc5cd58..a4d9d97045d 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -3153,7 +3153,8 @@ impl<'a> Parser<'a> { if !require_comma { arm_body = Some(expr); - this.eat(&token::Comma); + // Eat a comma if it exists, though. + let _ = this.eat(&token::Comma); Ok(Recovered::No) } else if let Some((span, guar)) = this.parse_arm_body_missing_braces(&expr, arrow_span) @@ -3654,7 +3655,7 @@ impl<'a> Parser<'a> { fields.push(f); } self.recover_stmt_(SemiColonMode::Comma, BlockMode::Ignore); - self.eat(&token::Comma); + let _ = self.eat(&token::Comma); } } } |
