Simplify if_chain.
This commit is contained in:
parent
d14fdc0203
commit
185fa0d1b1
@ -1214,23 +1214,21 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Casts {
|
|||||||
if let LitKind::Int(n, _) = lit.node;
|
if let LitKind::Int(n, _) = lit.node;
|
||||||
if let Some(src) = snippet_opt(cx, lit.span);
|
if let Some(src) = snippet_opt(cx, lit.span);
|
||||||
if cast_to.is_floating_point();
|
if cast_to.is_floating_point();
|
||||||
|
if let Some(num_lit) = NumericLiteral::from_lit_kind(&src, &lit.node);
|
||||||
|
let from_nbits = 128 - n.leading_zeros();
|
||||||
|
let to_nbits = fp_ty_mantissa_nbits(cast_to);
|
||||||
|
if from_nbits != 0 && to_nbits != 0 && from_nbits <= to_nbits && num_lit.is_decimal();
|
||||||
then {
|
then {
|
||||||
let from_nbits = 128 - n.leading_zeros();
|
span_lint_and_sugg(
|
||||||
let to_nbits = fp_ty_mantissa_nbits(cast_to);
|
cx,
|
||||||
if let Some(num_lit) = NumericLiteral::from_lit_kind(&src, &lit.node) {
|
UNNECESSARY_CAST,
|
||||||
if from_nbits != 0 && to_nbits != 0 && from_nbits <= to_nbits && num_lit.is_decimal() {
|
expr.span,
|
||||||
span_lint_and_sugg(
|
&format!("casting integer literal to `{}` is unnecessary", cast_to),
|
||||||
cx,
|
"try",
|
||||||
UNNECESSARY_CAST,
|
format!("{}_{}", n, cast_to),
|
||||||
expr.span,
|
Applicability::MachineApplicable,
|
||||||
&format!("casting integer literal to `{}` is unnecessary", cast_to),
|
);
|
||||||
"try",
|
return;
|
||||||
format!("{}_{}", n, cast_to),
|
|
||||||
Applicability::MachineApplicable,
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
match lit.node {
|
match lit.node {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user