Skip to content

Commit

Permalink
Fix clippy warnings (#1138)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
NobodyXu committed Jul 7, 2024
1 parent 3fe874f commit 2802459
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ jobs:
rustup default stable
shell: bash
- uses: Swatinem/rust-cache@v2
- run: cargo clippy
- run: cargo clippy --no-deps

rustfmt:
name: Rustfmt
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
//! ```

#![doc(html_root_url = "https://docs.rs/cc/1.0")]
#![cfg_attr(test, deny(warnings))]
#![deny(warnings)]
#![deny(missing_docs)]
#![deny(clippy::disallowed_methods)]

Expand Down Expand Up @@ -3942,7 +3942,7 @@ impl Build {
}
}
fn is_wasi_target(target: &str) -> bool {
const TARGETS: [&'static str; 7] = [
const TARGETS: [&str; 7] = [
"wasm32-wasi",
"wasm32-wasip1",
"wasm32-wasip1-threads",
Expand All @@ -3951,7 +3951,7 @@ impl Build {
"wasm32-unknown-wasi",
"wasm32-unknown-unknown",
];
return TARGETS.contains(&target);
TARGETS.contains(&target)
}

fn cuda_file_count(&self) -> usize {
Expand Down
4 changes: 2 additions & 2 deletions src/windows/find_tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ mod impl_ {
///
/// The function returned cannot be used after the handle is dropped.
unsafe fn get_proc_address<F>(&self, name: &[u8]) -> Option<F> {
let symbol = unsafe { GetProcAddress(self.0, name.as_ptr() as _) };
symbol.map(|symbol| unsafe { mem::transmute_copy(&symbol) })
let symbol = GetProcAddress(self.0, name.as_ptr() as _);
symbol.map(|symbol| mem::transmute_copy(&symbol))
}
}

Expand Down
39 changes: 19 additions & 20 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,17 +573,16 @@ fn macos_cpp_minimums() {
#[cfg(target_os = "macos")]
#[test]
fn clang_apple_tvos() {
for target in &["aarch64-apple-tvos"] {
let test = Test::clang();
test.gcc()
.__set_env("TVOS_DEPLOYMENT_TARGET", "9.0")
.target(target)
.host(target)
.file("foo.c")
.compile("foo");
let target = "aarch64-apple-tvos";
let test = Test::clang();
test.gcc()
.__set_env("TVOS_DEPLOYMENT_TARGET", "9.0")
.target(target)
.host(target)
.file("foo.c")
.compile("foo");

test.cmd(0).must_have("-mappletvos-version-min=9.0");
}
test.cmd(0).must_have("-mappletvos-version-min=9.0");
}

#[cfg(target_os = "macos")]
Expand Down Expand Up @@ -626,17 +625,17 @@ fn clang_apple_mac_catalyst() {
#[cfg(target_os = "macos")]
#[test]
fn clang_apple_tvsimulator() {
for target in &["x86_64-apple-tvos"] {
let test = Test::clang();
test.gcc()
.__set_env("TVOS_DEPLOYMENT_TARGET", "9.0")
.target(target)
.host(target)
.file("foo.c")
.compile("foo");
let target = "x86_64-apple-tvos";

test.cmd(0).must_have("-mappletvsimulator-version-min=9.0");
}
let test = Test::clang();
test.gcc()
.__set_env("TVOS_DEPLOYMENT_TARGET", "9.0")
.target(target)
.host(target)
.file("foo.c")
.compile("foo");

test.cmd(0).must_have("-mappletvsimulator-version-min=9.0");
}

#[cfg(target_os = "macos")]
Expand Down

0 comments on commit 2802459

Please sign in to comment.