Skip to content

Commit bd4197c

Browse files
committed
Simplify an if let Some to a ?
1 parent 1722aa7 commit bd4197c

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs

+10-13
Original file line numberDiff line numberDiff line change
@@ -140,20 +140,17 @@ impl IntRange {
140140
value: mir::ConstantKind<'tcx>,
141141
) -> Option<IntRange> {
142142
let ty = value.ty();
143-
if let Some((target_size, bias)) = Self::integral_size_and_signed_bias(tcx, ty) {
144-
let val = match value {
145-
mir::ConstantKind::Ty(c) if let ty::ConstKind::Value(valtree) = c.kind() => {
146-
valtree.unwrap_leaf().to_bits(target_size).ok()
147-
},
148-
// This is a more general form of the previous case.
149-
_ => value.try_eval_bits(tcx, param_env, ty),
150-
}?;
143+
let (target_size, bias) = Self::integral_size_and_signed_bias(tcx, ty)?;
144+
let val = match value {
145+
mir::ConstantKind::Ty(c) if let ty::ConstKind::Value(valtree) = c.kind() => {
146+
valtree.unwrap_leaf().to_bits(target_size).ok()
147+
},
148+
// This is a more general form of the previous case.
149+
_ => value.try_eval_bits(tcx, param_env, ty),
150+
}?;
151151

152-
let val = val ^ bias;
153-
Some(IntRange { range: val..=val, bias })
154-
} else {
155-
None
156-
}
152+
let val = val ^ bias;
153+
Some(IntRange { range: val..=val, bias })
157154
}
158155

159156
#[inline]

0 commit comments

Comments
 (0)