From 382ba79380c3e294cb18c2439f6aff945ee7b2d2 Mon Sep 17 00:00:00 2001 From: LingMan Date: Thu, 17 Jun 2021 19:39:58 +0200 Subject: [PATCH] Use `map_or` instead of open-coding it --- compiler/rustc_mir/src/transform/const_prop.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_mir/src/transform/const_prop.rs b/compiler/rustc_mir/src/transform/const_prop.rs index 73a0f5537c3b..b56c247127ce 100644 --- a/compiler/rustc_mir/src/transform/const_prop.rs +++ b/compiler/rustc_mir/src/transform/const_prop.rs @@ -1205,12 +1205,9 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> { let mut eval_to_int = |op| { // This can be `None` if the lhs wasn't const propagated and we just // triggered the assert on the value of the rhs. - match self.eval_operand(op, source_info) { - Some(op) => DbgVal::Val( - self.ecx.read_immediate(&op).unwrap().to_const_int(), - ), - None => DbgVal::Underscore, - } + self.eval_operand(op, source_info).map_or(DbgVal::Underscore, |op| { + DbgVal::Val(self.ecx.read_immediate(&op).unwrap().to_const_int()) + }) }; let msg = match msg { AssertKind::DivisionByZero(op) => {