From 1cf47804df8d69192b60cafcf11b9d4d88e223da Mon Sep 17 00:00:00 2001 From: Aaron Kutch Date: Fri, 11 Dec 2020 14:45:35 -0600 Subject: [PATCH] Fix all clippy warnings --- library/compiler-builtins/src/float/add.rs | 5 ++--- library/compiler-builtins/src/float/cmp.rs | 21 ++++++++----------- library/compiler-builtins/src/float/div.rs | 4 ++++ library/compiler-builtins/src/float/mul.rs | 2 +- .../src/int/specialized_div_rem/mod.rs | 7 +++++++ library/compiler-builtins/src/lib.rs | 2 ++ library/compiler-builtins/src/mem/mod.rs | 3 +++ 7 files changed, 28 insertions(+), 16 deletions(-) diff --git a/library/compiler-builtins/src/float/add.rs b/library/compiler-builtins/src/float/add.rs index e8b9f9e77427..67f6c2c1489f 100644 --- a/library/compiler-builtins/src/float/add.rs +++ b/library/compiler-builtins/src/float/add.rs @@ -137,9 +137,8 @@ where a_significand <<= shift; a_exponent -= shift; } - } else - /* addition */ - { + } else { + // addition a_significand += b_significand; // If the addition carried up, we need to right-shift the result and diff --git a/library/compiler-builtins/src/float/cmp.rs b/library/compiler-builtins/src/float/cmp.rs index 79c26b09921f..1d4e384335bd 100644 --- a/library/compiler-builtins/src/float/cmp.rs +++ b/library/compiler-builtins/src/float/cmp.rs @@ -63,25 +63,22 @@ fn cmp(a: F, b: F) -> Result { // a and b as signed integers as we would with a fp_ting-point compare. if a_srep & b_srep >= szero { if a_srep < b_srep { - return Result::Less; + Result::Less } else if a_srep == b_srep { - return Result::Equal; + Result::Equal } else { - return Result::Greater; + Result::Greater } - } // Otherwise, both are negative, so we need to flip the sense of the // comparison to get the correct result. (This assumes a twos- or ones- // complement integer representation; if integers are represented in a // sign-magnitude representation, then this flip is incorrect). - else { - if a_srep > b_srep { - return Result::Less; - } else if a_srep == b_srep { - return Result::Equal; - } else { - return Result::Greater; - } + } else if a_srep > b_srep { + Result::Less + } else if a_srep == b_srep { + Result::Equal + } else { + Result::Greater } } diff --git a/library/compiler-builtins/src/float/div.rs b/library/compiler-builtins/src/float/div.rs index dd6467f88fb7..9ac1e87b4e2d 100644 --- a/library/compiler-builtins/src/float/div.rs +++ b/library/compiler-builtins/src/float/div.rs @@ -1,3 +1,7 @@ +// The functions are complex with many branches, and explicit +// `return`s makes it clear where function exit points are +#![allow(clippy::needless_return)] + use float::Float; use int::{CastInto, DInt, HInt, Int}; diff --git a/library/compiler-builtins/src/float/mul.rs b/library/compiler-builtins/src/float/mul.rs index 540e7bdcfe30..c89f22756af7 100644 --- a/library/compiler-builtins/src/float/mul.rs +++ b/library/compiler-builtins/src/float/mul.rs @@ -181,7 +181,7 @@ where product_high += product_high & one; } - return F::from_repr(product_high); + F::from_repr(product_high) } intrinsics! { diff --git a/library/compiler-builtins/src/int/specialized_div_rem/mod.rs b/library/compiler-builtins/src/int/specialized_div_rem/mod.rs index 14e758fc5a8f..391db765da47 100644 --- a/library/compiler-builtins/src/int/specialized_div_rem/mod.rs +++ b/library/compiler-builtins/src/int/specialized_div_rem/mod.rs @@ -1,5 +1,12 @@ // TODO: when `unsafe_block_in_unsafe_fn` is stabilized, remove this #![allow(unused_unsafe)] +// The functions are complex with many branches, and explicit +// `return`s makes it clear where function exit points are +#![allow(clippy::needless_return)] +#![allow(clippy::comparison_chain)] +// Clippy is confused by the complex configuration +#![allow(clippy::if_same_then_else)] +#![allow(clippy::needless_bool)] //! This `specialized_div_rem` module is originally from version 1.0.0 of the //! `specialized-div-rem` crate. Note that `for` loops with ranges are not used in this diff --git a/library/compiler-builtins/src/lib.rs b/library/compiler-builtins/src/lib.rs index 9190c4251e54..efd63ff77952 100644 --- a/library/compiler-builtins/src/lib.rs +++ b/library/compiler-builtins/src/lib.rs @@ -17,6 +17,8 @@ // compiler on ABIs and such, so we should be "good enough" for now and changes // to the `u128` ABI will be reflected here. #![allow(improper_ctypes, improper_ctypes_definitions)] +// `mem::swap` cannot be used because it may generate references to memcpy in unoptimized code. +#![allow(clippy::manual_swap)] // We disable #[no_mangle] for tests so that we can verify the test results // against the native compiler-rt implementations of the builtins. diff --git a/library/compiler-builtins/src/mem/mod.rs b/library/compiler-builtins/src/mem/mod.rs index 107762c43a6d..03dc965ca4ac 100644 --- a/library/compiler-builtins/src/mem/mod.rs +++ b/library/compiler-builtins/src/mem/mod.rs @@ -1,3 +1,6 @@ +// Trying to satisfy clippy here is hopeless +#![allow(clippy::style)] + #[allow(warnings)] #[cfg(target_pointer_width = "16")] type c_int = i16;