Skip to content

Commit b6e234c

Browse files
authored
Rollup merge of #86407 - LingMan:map-or, r=LeSeulArtichaut
Use `map_or` instead of open-coding it `@rustbot` modify labels +C-cleanup +T-compiler
2 parents 90e82c9 + 382ba79 commit b6e234c

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

compiler/rustc_mir/src/transform/const_prop.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,12 +1205,9 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
12051205
let mut eval_to_int = |op| {
12061206
// This can be `None` if the lhs wasn't const propagated and we just
12071207
// triggered the assert on the value of the rhs.
1208-
match self.eval_operand(op, source_info) {
1209-
Some(op) => DbgVal::Val(
1210-
self.ecx.read_immediate(&op).unwrap().to_const_int(),
1211-
),
1212-
None => DbgVal::Underscore,
1213-
}
1208+
self.eval_operand(op, source_info).map_or(DbgVal::Underscore, |op| {
1209+
DbgVal::Val(self.ecx.read_immediate(&op).unwrap().to_const_int())
1210+
})
12141211
};
12151212
let msg = match msg {
12161213
AssertKind::DivisionByZero(op) => {

0 commit comments

Comments
 (0)