1
Fork 0

use matches!() macro for simple if let conditions

This commit is contained in:
Matthias Krüger 2020-09-18 19:11:06 +02:00
parent 2c69266c06
commit 40dddd3305
15 changed files with 33 additions and 36 deletions

View file

@ -96,8 +96,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
);
}
StmtKind::Let { remainder_scope, init_scope, pattern, initializer, lint_level } => {
let ignores_expr_result =
if let PatKind::Wild = *pattern.kind { true } else { false };
let ignores_expr_result = matches!(*pattern.kind, PatKind::Wild);
this.block_context.push(BlockFrame::Statement { ignores_expr_result });
// Enter the remainder scope, i.e., the bindings' destruction scope.

View file

@ -1793,7 +1793,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
.flat_map(|(bindings, _)| bindings)
.chain(&candidate.bindings)
.filter(|binding| {
if let BindingMode::ByValue = binding.binding_mode { true } else { false }
matches!(binding.binding_mode, BindingMode::ByValue )
});
// Read all of the by reference bindings to ensure that the
// place they refer to can't be modified by the guard.