use matches!() macro in more places

This commit is contained in:
Matthias Krüger 2021-11-06 01:31:32 +01:00
parent 3cd3bbecc5
commit 0a5640b55f
21 changed files with 49 additions and 86 deletions

View file

@ -485,7 +485,7 @@ fn inject_statement(
// Non-code expressions are injected into the coverage map, without generating executable code.
fn inject_intermediate_expression(mir_body: &mut mir::Body<'tcx>, expression: CoverageKind) {
debug_assert!(if let CoverageKind::Expression { .. } = expression { true } else { false });
debug_assert!(matches!(expression, CoverageKind::Expression { .. }));
debug!(" injecting non-code expression {:?}", expression);
let inject_in_bb = mir::START_BLOCK;
let data = &mut mir_body[inject_in_bb];

View file

@ -94,10 +94,9 @@ impl CoverageSpan {
stmt_index: usize,
) -> Self {
let is_closure = match statement.kind {
StatementKind::Assign(box (_, Rvalue::Aggregate(box ref kind, _))) => match kind {
AggregateKind::Closure(_, _) | AggregateKind::Generator(_, _, _) => true,
_ => false,
},
StatementKind::Assign(box (_, Rvalue::Aggregate(box ref kind, _))) => {
matches!(kind, AggregateKind::Closure(_, _) | AggregateKind::Generator(_, _, _))
}
_ => false,
};

View file

@ -27,9 +27,8 @@ impl MirPass<'_> for UnreachablePropagation {
// This is a temporary solution that handles possibly diverging asm statements.
// Accompanying testcases: mir-opt/unreachable_asm.rs and mir-opt/unreachable_asm_2.rs
let asm_stmt_in_block = || {
bb_data.statements.iter().any(|stmt: &Statement<'_>| match stmt.kind {
StatementKind::LlvmInlineAsm(..) => true,
_ => false,
bb_data.statements.iter().any(|stmt: &Statement<'_>| {
matches!(stmt.kind, StatementKind::LlvmInlineAsm(..))
})
};