Skip to content

Commit 2802459

Browse files
authored
Fix clippy warnings (#1138)
* Optimize CI job clippy Pass `--no-deps` to avoid checking dependencies. Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Deny all clippy warning So that the clippy warning will be catched in CI and contributors would not submit code that has clippy warnings. Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Fix clippy warnings Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Fix clippy warning on windows Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> --------- Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
1 parent 3fe874f commit 2802459

File tree

4 files changed

+25
-26
lines changed

4 files changed

+25
-26
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ jobs:
223223
rustup default stable
224224
shell: bash
225225
- uses: Swatinem/rust-cache@v2
226-
- run: cargo clippy
226+
- run: cargo clippy --no-deps
227227

228228
rustfmt:
229229
name: Rustfmt

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@
207207
//! ```
208208
209209
#![doc(html_root_url = "https://docs.rs/cc/1.0")]
210-
#![cfg_attr(test, deny(warnings))]
210+
#![deny(warnings)]
211211
#![deny(missing_docs)]
212212
#![deny(clippy::disallowed_methods)]
213213

@@ -3942,7 +3942,7 @@ impl Build {
39423942
}
39433943
}
39443944
fn is_wasi_target(target: &str) -> bool {
3945-
const TARGETS: [&'static str; 7] = [
3945+
const TARGETS: [&str; 7] = [
39463946
"wasm32-wasi",
39473947
"wasm32-wasip1",
39483948
"wasm32-wasip1-threads",
@@ -3951,7 +3951,7 @@ impl Build {
39513951
"wasm32-unknown-wasi",
39523952
"wasm32-unknown-unknown",
39533953
];
3954-
return TARGETS.contains(&target);
3954+
TARGETS.contains(&target)
39553955
}
39563956

39573957
fn cuda_file_count(&self) -> usize {

src/windows/find_tools.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,8 @@ mod impl_ {
269269
///
270270
/// The function returned cannot be used after the handle is dropped.
271271
unsafe fn get_proc_address<F>(&self, name: &[u8]) -> Option<F> {
272-
let symbol = unsafe { GetProcAddress(self.0, name.as_ptr() as _) };
273-
symbol.map(|symbol| unsafe { mem::transmute_copy(&symbol) })
272+
let symbol = GetProcAddress(self.0, name.as_ptr() as _);
273+
symbol.map(|symbol| mem::transmute_copy(&symbol))
274274
}
275275
}
276276

tests/test.rs

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -573,17 +573,16 @@ fn macos_cpp_minimums() {
573573
#[cfg(target_os = "macos")]
574574
#[test]
575575
fn clang_apple_tvos() {
576-
for target in &["aarch64-apple-tvos"] {
577-
let test = Test::clang();
578-
test.gcc()
579-
.__set_env("TVOS_DEPLOYMENT_TARGET", "9.0")
580-
.target(target)
581-
.host(target)
582-
.file("foo.c")
583-
.compile("foo");
576+
let target = "aarch64-apple-tvos";
577+
let test = Test::clang();
578+
test.gcc()
579+
.__set_env("TVOS_DEPLOYMENT_TARGET", "9.0")
580+
.target(target)
581+
.host(target)
582+
.file("foo.c")
583+
.compile("foo");
584584

585-
test.cmd(0).must_have("-mappletvos-version-min=9.0");
586-
}
585+
test.cmd(0).must_have("-mappletvos-version-min=9.0");
587586
}
588587

589588
#[cfg(target_os = "macos")]
@@ -626,17 +625,17 @@ fn clang_apple_mac_catalyst() {
626625
#[cfg(target_os = "macos")]
627626
#[test]
628627
fn clang_apple_tvsimulator() {
629-
for target in &["x86_64-apple-tvos"] {
630-
let test = Test::clang();
631-
test.gcc()
632-
.__set_env("TVOS_DEPLOYMENT_TARGET", "9.0")
633-
.target(target)
634-
.host(target)
635-
.file("foo.c")
636-
.compile("foo");
628+
let target = "x86_64-apple-tvos";
637629

638-
test.cmd(0).must_have("-mappletvsimulator-version-min=9.0");
639-
}
630+
let test = Test::clang();
631+
test.gcc()
632+
.__set_env("TVOS_DEPLOYMENT_TARGET", "9.0")
633+
.target(target)
634+
.host(target)
635+
.file("foo.c")
636+
.compile("foo");
637+
638+
test.cmd(0).must_have("-mappletvsimulator-version-min=9.0");
640639
}
641640

642641
#[cfg(target_os = "macos")]

0 commit comments

Comments
 (0)