Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 0d810ed

Browse files
committed
Fix clippy lints in crates/ and enable this on CI
1 parent 4cd303d commit 0d810ed

File tree

7 files changed

+31
-12
lines changed

7 files changed

+31
-12
lines changed

.github/workflows/main.yml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,24 @@ jobs:
105105
rustup target add x86_64-unknown-linux-musl
106106
cargo generate-lockfile && ./ci/run-docker.sh ${{ matrix.target }}
107107
108-
- name: Clippy
109-
# Tests and utilities can't build on no_std targets
110-
if: "!contains(matrix.target, 'thumb')"
111-
# Run clippy on `libm`
112-
run: cargo clippy --target "${{ matrix.target }}" --package libm --all-targets
113-
108+
clippy:
109+
name: Clippy
110+
runs-on: ubuntu-latest
111+
steps:
112+
- uses: actions/checkout@master
113+
- name: Install Rust
114+
run: |
115+
rustup update nightly --no-self-update
116+
rustup default nightly
117+
rustup component add clippy
118+
- uses: Swatinem/rust-cache@v2
119+
- name: Download musl source
120+
run: ./ci/download-musl.sh
121+
- run: |
122+
cargo clippy --all \
123+
--exclude cb \
124+
--features libm-test/build-musl,libm-test/test-multiprecision \
125+
--all-targets
114126
115127
builtins:
116128
name: Check use with compiler-builtins

crates/libm-macros/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ fn validate(input: &StructuredInput) -> syn::Result<Vec<&'static FunctionInfo>>
353353
if !input.skip.is_empty() && input.only.is_some() {
354354
let e = syn::Error::new(
355355
input.only_span.unwrap(),
356-
format!("only one of `skip` or `only` may be specified"),
356+
"only one of `skip` or `only` may be specified",
357357
);
358358
return Err(e);
359359
}

crates/libm-test/src/gen/random.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static TEST_CASES: LazyLock<CachedInput> = LazyLock::new(|| make_test_cases(NTES
3737
/// value so tests don't run forever.
3838
static TEST_CASES_JN: LazyLock<CachedInput> = LazyLock::new(|| {
3939
// Start with regular test cases
40-
let mut cases = (&*TEST_CASES).clone();
40+
let mut cases = (*TEST_CASES).clone();
4141

4242
// These functions are extremely slow, limit them
4343
let ntests_jn = (NTESTS / 1000).max(80);

crates/libm-test/src/precision.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ fn maybe_check_nan_bits<F: Float>(actual: F, expected: F, ctx: &CheckCtx) -> Opt
238238

239239
// abs and copysign require signaling NaNs to be propagated, so verify bit equality.
240240
if actual.to_bits() == expected.to_bits() {
241-
return SKIP;
241+
SKIP
242242
} else {
243243
Some(Err(anyhow::anyhow!("NaNs have different bitpatterns")))
244244
}

crates/libm-test/src/test_traits.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ macro_rules! impl_int {
214214
};
215215
}
216216

217-
fn validate_int<'a, I, Input>(actual: I, expected: I, input: Input, ctx: &CheckCtx) -> TestResult
217+
fn validate_int<I, Input>(actual: I, expected: I, input: Input, ctx: &CheckCtx) -> TestResult
218218
where
219219
I: Int + Hex,
220220
Input: Hex + fmt::Debug,
@@ -274,7 +274,7 @@ macro_rules! impl_float {
274274
};
275275
}
276276

277-
fn validate_float<'a, F, Input>(actual: F, expected: F, input: Input, ctx: &CheckCtx) -> TestResult
277+
fn validate_float<F, Input>(actual: F, expected: F, input: Input, ctx: &CheckCtx) -> TestResult
278278
where
279279
F: Float + Hex,
280280
Input: Hex + fmt::Debug,

crates/musl-math-sys/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ fn build_musl_math(cfg: &Config) {
124124
// Run configuration steps. Usually done as part of the musl `Makefile`.
125125
let obj_include = cfg.out_dir.join("musl_obj/include");
126126
fs::create_dir_all(&obj_include).unwrap();
127-
fs::create_dir_all(&obj_include.join("bits")).unwrap();
127+
fs::create_dir_all(obj_include.join("bits")).unwrap();
128128
let sed_stat = Command::new("sed")
129129
.arg("-f")
130130
.arg(musl_dir.join("tools/mkalltypes.sed"))

crates/musl-math-sys/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::ffi::{c_char, c_int, c_long};
77
/// unsound.
88
macro_rules! functions {
99
( $(
10+
$( #[$meta:meta] )*
1011
$pfx_name:ident: $name:ident( $($arg:ident: $aty:ty),+ ) -> $rty:ty;
1112
)* ) => {
1213
extern "C" {
@@ -15,6 +16,7 @@ macro_rules! functions {
1516

1617
$(
1718
// Expose a safe version
19+
$( #[$meta] )*
1820
pub fn $name( $($arg: $aty),+ ) -> $rty {
1921
// SAFETY: FFI calls with no preconditions
2022
unsafe { $pfx_name( $($arg),+ ) }
@@ -231,8 +233,13 @@ functions! {
231233
musl_logf: logf(a: f32) -> f32;
232234
musl_modf: modf(a: f64, b: &mut f64) -> f64;
233235
musl_modff: modff(a: f32, b: &mut f32) -> f32;
236+
237+
// FIXME: these need to be unsafe
238+
#[allow(clippy::not_unsafe_ptr_arg_deref)]
234239
musl_nan: nan(a: *const c_char) -> f64;
240+
#[allow(clippy::not_unsafe_ptr_arg_deref)]
235241
musl_nanf: nanf(a: *const c_char) -> f32;
242+
236243
musl_nearbyint: nearbyint(a: f64) -> f64;
237244
musl_nearbyintf: nearbyintf(a: f32) -> f32;
238245
musl_nextafter: nextafter(a: f64, b: f64) -> f64;

0 commit comments

Comments
 (0)