diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2023-01-31 23:38:52 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-31 23:38:52 +0100 |
| commit | 53bb6322dbc80d8a7da69e1ea4dbff98c4a70abb (patch) | |
| tree | cdfff407398d47f6a151da0c7dcf965c7c6f031c /compiler/rustc_parse/src/parser/stmt.rs | |
| parent | c6a104f3e4266cb9f369b7edbc58520ca43f911e (diff) | |
| parent | 340414ed7bbcdd28a6a5baa0e3229c07029387b4 (diff) | |
| download | rust-53bb6322dbc80d8a7da69e1ea4dbff98c4a70abb.tar.gz rust-53bb6322dbc80d8a7da69e1ea4dbff98c4a70abb.zip | |
Rollup merge of #107467 - WaffleLapkin:uneq, r=oli-obk
Improve enum checks Some light refactoring.
Diffstat (limited to 'compiler/rustc_parse/src/parser/stmt.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/stmt.rs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/compiler/rustc_parse/src/parser/stmt.rs b/compiler/rustc_parse/src/parser/stmt.rs index 4ff9927aab5..58c7a398f14 100644 --- a/compiler/rustc_parse/src/parser/stmt.rs +++ b/compiler/rustc_parse/src/parser/stmt.rs @@ -93,11 +93,12 @@ impl<'a> Parser<'a> { // or `auto trait` items. We aim to parse an arbitrary path `a::b` but not something // that starts like a path (1 token), but it fact not a path. // Also, we avoid stealing syntax from `parse_item_`. - if force_collect == ForceCollect::Yes { - self.collect_tokens_no_attrs(|this| this.parse_stmt_path_start(lo, attrs)) - } else { - self.parse_stmt_path_start(lo, attrs) - }? + match force_collect { + ForceCollect::Yes => { + self.collect_tokens_no_attrs(|this| this.parse_stmt_path_start(lo, attrs))? + } + ForceCollect::No => self.parse_stmt_path_start(lo, attrs)?, + } } else if let Some(item) = self.parse_item_common( attrs.clone(), false, @@ -113,13 +114,12 @@ impl<'a> Parser<'a> { self.mk_stmt(lo, StmtKind::Empty) } else if self.token != token::CloseDelim(Delimiter::Brace) { // Remainder are line-expr stmts. - let e = if force_collect == ForceCollect::Yes { - self.collect_tokens_no_attrs(|this| { + let e = match force_collect { + ForceCollect::Yes => self.collect_tokens_no_attrs(|this| { this.parse_expr_res(Restrictions::STMT_EXPR, Some(attrs)) - }) - } else { - self.parse_expr_res(Restrictions::STMT_EXPR, Some(attrs)) - }?; + })?, + ForceCollect::No => self.parse_expr_res(Restrictions::STMT_EXPR, Some(attrs))?, + }; if matches!(e.kind, ExprKind::Assign(..)) && self.eat_keyword(kw::Else) { let bl = self.parse_block()?; // Destructuring assignment ... else. |
