diff options
| author | ayushmishra2005 <ayushmishra2005@gmail.com> | 2021-05-14 08:57:33 +0530 |
|---|---|---|
| committer | ayushmishra2005 <ayushmishra2005@gmail.com> | 2021-05-14 08:57:33 +0530 |
| commit | 34055a932be83b2d675a6bc4f4cbc6388504819d (patch) | |
| tree | cdded060e5f752ec54ca3a58aebaf6725d07c203 | |
| parent | 17f30e5451f581d753899d2f628e5be354df33cd (diff) | |
| download | rust-34055a932be83b2d675a6bc4f4cbc6388504819d.tar.gz rust-34055a932be83b2d675a6bc4f4cbc6388504819d.zip | |
Improve match statements
3 files changed, 3 insertions, 12 deletions
diff --git a/compiler/rustc_mir/src/transform/early_otherwise_branch.rs b/compiler/rustc_mir/src/transform/early_otherwise_branch.rs index f7ea9faec47..7934d4ba849 100644 --- a/compiler/rustc_mir/src/transform/early_otherwise_branch.rs +++ b/compiler/rustc_mir/src/transform/early_otherwise_branch.rs @@ -170,10 +170,7 @@ impl<'tcx> MirPass<'tcx> for EarlyOtherwiseBranch { } fn is_switch<'tcx>(terminator: &Terminator<'tcx>) -> bool { - match terminator.kind { - TerminatorKind::SwitchInt { .. } => true, - _ => false, - } + matches!(terminator.kind, TerminatorKind::SwitchInt { .. }) } struct Helper<'a, 'tcx> { diff --git a/compiler/rustc_mir/src/transform/simplify_try.rs b/compiler/rustc_mir/src/transform/simplify_try.rs index b42543c04eb..89fddc95c98 100644 --- a/compiler/rustc_mir/src/transform/simplify_try.rs +++ b/compiler/rustc_mir/src/transform/simplify_try.rs @@ -628,10 +628,7 @@ impl<'a, 'tcx> SimplifyBranchSameOptimizationFinder<'a, 'tcx> { // But `asm!(...)` could abort the program, // so we cannot assume that the `unreachable` terminator itself is reachable. // FIXME(Centril): use a normalization pass instead of a check. - || bb.statements.iter().any(|stmt| match stmt.kind { - StatementKind::LlvmInlineAsm(..) => true, - _ => false, - }) + || bb.statements.iter().any(|stmt| matches!(stmt.kind, StatementKind::LlvmInlineAsm(..))) }) .peekable(); diff --git a/src/tools/clippy/tests/ui-toml/min_rust_version/min_rust_version.rs b/src/tools/clippy/tests/ui-toml/min_rust_version/min_rust_version.rs index bc41efa42a1..bf7da4015d3 100644 --- a/src/tools/clippy/tests/ui-toml/min_rust_version/min_rust_version.rs +++ b/src/tools/clippy/tests/ui-toml/min_rust_version/min_rust_version.rs @@ -31,10 +31,7 @@ fn option_as_ref_deref() { } fn match_like_matches() { - let _y = match Some(5) { - Some(0) => true, - _ => false, - }; + let _y = matches!(Some(5), Some(0)); } fn match_same_arms() { |
