Skip to content

Commit

Permalink
Rollup merge of #70424 - lcnr:nit, r=Centril
Browse files Browse the repository at this point in the history
simplify match stmt

We actually have a surprising amount of
```rust
match expr {
    $($p:pat)|+ => true,
    _ => false,
}
```
While I would prefer this to be replaced with `matches!`, most cases are
fairly readable anyway so we can just let them be for now.
  • Loading branch information
Centril authored Mar 26, 2020
2 parents 37e1860 + c21e25c commit 608715b
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/librustc_ast_passes/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,7 @@ impl<'a> AstValidator<'a> {
match expr.kind {
ExprKind::Lit(..) | ExprKind::Err => {}
ExprKind::Path(..) if allow_paths => {}
ExprKind::Unary(UnOp::Neg, ref inner)
if match inner.kind {
ExprKind::Lit(_) => true,
_ => false,
} => {}
ExprKind::Unary(UnOp::Neg, ref inner) if matches!(inner.kind, ExprKind::Lit(_)) => {}
_ => self.err_handler().span_err(
expr.span,
"arbitrary expressions aren't allowed \
Expand Down

0 comments on commit 608715b

Please sign in to comment.