Replace enum ==
s with match
es where it makes sense
This commit is contained in:
parent
f55b0022db
commit
fd649a3cc5
16 changed files with 258 additions and 231 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue