Fix clippy lints in crates/ and enable this on CI
This commit is contained in:
parent
c0f7b95e43
commit
2411357947
7 changed files with 31 additions and 12 deletions
|
|
@ -105,12 +105,24 @@ jobs:
|
|||
rustup target add x86_64-unknown-linux-musl
|
||||
cargo generate-lockfile && ./ci/run-docker.sh ${{ matrix.target }}
|
||||
|
||||
- name: Clippy
|
||||
# Tests and utilities can't build on no_std targets
|
||||
if: "!contains(matrix.target, 'thumb')"
|
||||
# Run clippy on `libm`
|
||||
run: cargo clippy --target "${{ matrix.target }}" --package libm --all-targets
|
||||
|
||||
clippy:
|
||||
name: Clippy
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: Install Rust
|
||||
run: |
|
||||
rustup update nightly --no-self-update
|
||||
rustup default nightly
|
||||
rustup component add clippy
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- name: Download musl source
|
||||
run: ./ci/download-musl.sh
|
||||
- run: |
|
||||
cargo clippy --all \
|
||||
--exclude cb \
|
||||
--features libm-test/build-musl,libm-test/test-multiprecision \
|
||||
--all-targets
|
||||
|
||||
builtins:
|
||||
name: Check use with compiler-builtins
|
||||
|
|
|
|||
|
|
@ -353,7 +353,7 @@ fn validate(input: &StructuredInput) -> syn::Result<Vec<&'static FunctionInfo>>
|
|||
if !input.skip.is_empty() && input.only.is_some() {
|
||||
let e = syn::Error::new(
|
||||
input.only_span.unwrap(),
|
||||
format!("only one of `skip` or `only` may be specified"),
|
||||
"only one of `skip` or `only` may be specified",
|
||||
);
|
||||
return Err(e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ static TEST_CASES: LazyLock<CachedInput> = LazyLock::new(|| make_test_cases(NTES
|
|||
/// value so tests don't run forever.
|
||||
static TEST_CASES_JN: LazyLock<CachedInput> = LazyLock::new(|| {
|
||||
// Start with regular test cases
|
||||
let mut cases = (&*TEST_CASES).clone();
|
||||
let mut cases = (*TEST_CASES).clone();
|
||||
|
||||
// These functions are extremely slow, limit them
|
||||
let ntests_jn = (NTESTS / 1000).max(80);
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@ fn maybe_check_nan_bits<F: Float>(actual: F, expected: F, ctx: &CheckCtx) -> Opt
|
|||
|
||||
// abs and copysign require signaling NaNs to be propagated, so verify bit equality.
|
||||
if actual.to_bits() == expected.to_bits() {
|
||||
return SKIP;
|
||||
SKIP
|
||||
} else {
|
||||
Some(Err(anyhow::anyhow!("NaNs have different bitpatterns")))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ macro_rules! impl_int {
|
|||
};
|
||||
}
|
||||
|
||||
fn validate_int<'a, I, Input>(actual: I, expected: I, input: Input, ctx: &CheckCtx) -> TestResult
|
||||
fn validate_int<I, Input>(actual: I, expected: I, input: Input, ctx: &CheckCtx) -> TestResult
|
||||
where
|
||||
I: Int + Hex,
|
||||
Input: Hex + fmt::Debug,
|
||||
|
|
@ -274,7 +274,7 @@ macro_rules! impl_float {
|
|||
};
|
||||
}
|
||||
|
||||
fn validate_float<'a, F, Input>(actual: F, expected: F, input: Input, ctx: &CheckCtx) -> TestResult
|
||||
fn validate_float<F, Input>(actual: F, expected: F, input: Input, ctx: &CheckCtx) -> TestResult
|
||||
where
|
||||
F: Float + Hex,
|
||||
Input: Hex + fmt::Debug,
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ fn build_musl_math(cfg: &Config) {
|
|||
// Run configuration steps. Usually done as part of the musl `Makefile`.
|
||||
let obj_include = cfg.out_dir.join("musl_obj/include");
|
||||
fs::create_dir_all(&obj_include).unwrap();
|
||||
fs::create_dir_all(&obj_include.join("bits")).unwrap();
|
||||
fs::create_dir_all(obj_include.join("bits")).unwrap();
|
||||
let sed_stat = Command::new("sed")
|
||||
.arg("-f")
|
||||
.arg(musl_dir.join("tools/mkalltypes.sed"))
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use std::ffi::{c_char, c_int, c_long};
|
|||
/// unsound.
|
||||
macro_rules! functions {
|
||||
( $(
|
||||
$( #[$meta:meta] )*
|
||||
$pfx_name:ident: $name:ident( $($arg:ident: $aty:ty),+ ) -> $rty:ty;
|
||||
)* ) => {
|
||||
extern "C" {
|
||||
|
|
@ -15,6 +16,7 @@ macro_rules! functions {
|
|||
|
||||
$(
|
||||
// Expose a safe version
|
||||
$( #[$meta] )*
|
||||
pub fn $name( $($arg: $aty),+ ) -> $rty {
|
||||
// SAFETY: FFI calls with no preconditions
|
||||
unsafe { $pfx_name( $($arg),+ ) }
|
||||
|
|
@ -231,8 +233,13 @@ functions! {
|
|||
musl_logf: logf(a: f32) -> f32;
|
||||
musl_modf: modf(a: f64, b: &mut f64) -> f64;
|
||||
musl_modff: modff(a: f32, b: &mut f32) -> f32;
|
||||
|
||||
// FIXME: these need to be unsafe
|
||||
#[allow(clippy::not_unsafe_ptr_arg_deref)]
|
||||
musl_nan: nan(a: *const c_char) -> f64;
|
||||
#[allow(clippy::not_unsafe_ptr_arg_deref)]
|
||||
musl_nanf: nanf(a: *const c_char) -> f32;
|
||||
|
||||
musl_nearbyint: nearbyint(a: f64) -> f64;
|
||||
musl_nearbyintf: nearbyintf(a: f32) -> f32;
|
||||
musl_nextafter: nextafter(a: f64, b: f64) -> f64;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue