Skip to content

Commit cd3d166

Browse files
Rollup merge of #85278 - ayushmishra2005:code-refactoring, r=jackh726
Improve match statements
2 parents 1a926bf + 27defcd commit cd3d166

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

compiler/rustc_mir/src/transform/early_otherwise_branch.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,7 @@ impl<'tcx> MirPass<'tcx> for EarlyOtherwiseBranch {
170170
}
171171

172172
fn is_switch<'tcx>(terminator: &Terminator<'tcx>) -> bool {
173-
match terminator.kind {
174-
TerminatorKind::SwitchInt { .. } => true,
175-
_ => false,
176-
}
173+
matches!(terminator.kind, TerminatorKind::SwitchInt { .. })
177174
}
178175

179176
struct Helper<'a, 'tcx> {

compiler/rustc_mir/src/transform/simplify_try.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -628,10 +628,7 @@ impl<'a, 'tcx> SimplifyBranchSameOptimizationFinder<'a, 'tcx> {
628628
// But `asm!(...)` could abort the program,
629629
// so we cannot assume that the `unreachable` terminator itself is reachable.
630630
// FIXME(Centril): use a normalization pass instead of a check.
631-
|| bb.statements.iter().any(|stmt| match stmt.kind {
632-
StatementKind::LlvmInlineAsm(..) => true,
633-
_ => false,
634-
})
631+
|| bb.statements.iter().any(|stmt| matches!(stmt.kind, StatementKind::LlvmInlineAsm(..)))
635632
})
636633
.peekable();
637634

0 commit comments

Comments
 (0)