mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-15 01:17:16 +00:00
Simplify if_chain.
This commit is contained in:
parent
d14fdc0203
commit
185fa0d1b1
1 changed files with 14 additions and 16 deletions
|
@ -1214,11 +1214,11 @@ 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();
|
||||||
then {
|
if let Some(num_lit) = NumericLiteral::from_lit_kind(&src, &lit.node);
|
||||||
let from_nbits = 128 - n.leading_zeros();
|
let from_nbits = 128 - n.leading_zeros();
|
||||||
let to_nbits = fp_ty_mantissa_nbits(cast_to);
|
let to_nbits = fp_ty_mantissa_nbits(cast_to);
|
||||||
if let Some(num_lit) = NumericLiteral::from_lit_kind(&src, &lit.node) {
|
if from_nbits != 0 && to_nbits != 0 && from_nbits <= to_nbits && num_lit.is_decimal();
|
||||||
if from_nbits != 0 && to_nbits != 0 && from_nbits <= to_nbits && num_lit.is_decimal() {
|
then {
|
||||||
span_lint_and_sugg(
|
span_lint_and_sugg(
|
||||||
cx,
|
cx,
|
||||||
UNNECESSARY_CAST,
|
UNNECESSARY_CAST,
|
||||||
|
@ -1231,8 +1231,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Casts {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
match lit.node {
|
match lit.node {
|
||||||
LitKind::Int(_, LitIntType::Unsuffixed) | LitKind::Float(_, LitFloatType::Unsuffixed) => {},
|
LitKind::Int(_, LitIntType::Unsuffixed) | LitKind::Float(_, LitFloatType::Unsuffixed) => {},
|
||||||
_ => {
|
_ => {
|
||||||
|
|
Loading…
Reference in a new issue