Simplify an if let Some
to a ?
This commit is contained in:
parent
1722aa79ea
commit
bd4197cbf9
1 changed files with 10 additions and 13 deletions
|
@ -140,20 +140,17 @@ impl IntRange {
|
||||||
value: mir::ConstantKind<'tcx>,
|
value: mir::ConstantKind<'tcx>,
|
||||||
) -> Option<IntRange> {
|
) -> Option<IntRange> {
|
||||||
let ty = value.ty();
|
let ty = value.ty();
|
||||||
if let Some((target_size, bias)) = Self::integral_size_and_signed_bias(tcx, ty) {
|
let (target_size, bias) = Self::integral_size_and_signed_bias(tcx, ty)?;
|
||||||
let val = match value {
|
let val = match value {
|
||||||
mir::ConstantKind::Ty(c) if let ty::ConstKind::Value(valtree) = c.kind() => {
|
mir::ConstantKind::Ty(c) if let ty::ConstKind::Value(valtree) = c.kind() => {
|
||||||
valtree.unwrap_leaf().to_bits(target_size).ok()
|
valtree.unwrap_leaf().to_bits(target_size).ok()
|
||||||
},
|
},
|
||||||
// This is a more general form of the previous case.
|
// This is a more general form of the previous case.
|
||||||
_ => value.try_eval_bits(tcx, param_env, ty),
|
_ => value.try_eval_bits(tcx, param_env, ty),
|
||||||
}?;
|
}?;
|
||||||
|
|
||||||
let val = val ^ bias;
|
let val = val ^ bias;
|
||||||
Some(IntRange { range: val..=val, bias })
|
Some(IntRange { range: val..=val, bias })
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue