From ea831308f7505e85060067e22d030e683e21ec30 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Sat, 23 Sep 2023 12:28:26 +0900 Subject: [PATCH] Apply more clippy restriction/pedantic lints --- build.rs | 5 +++-- portable-atomic-util/build.rs | 3 ++- portable-atomic-util/src/lib.rs | 24 +++++++++++++----------- src/lib.rs | 26 +++++++++++++------------- tools/codegen/src/ffi.rs | 2 +- 5 files changed, 32 insertions(+), 28 deletions(-) diff --git a/build.rs b/build.rs index ac34fd87..9db9d0dc 100644 --- a/build.rs +++ b/build.rs @@ -2,7 +2,8 @@ // The rustc-cfg emitted by the build script are *not* public API. -#![warn(rust_2018_idioms, single_use_lifetimes)] +#![warn(rust_2018_idioms, single_use_lifetimes, clippy::pedantic)] +#![allow(clippy::match_same_arms, clippy::single_match_else, clippy::too_many_lines)] #[path = "version.rs"] mod version; @@ -255,7 +256,7 @@ fn main() { // arm-linux-androideabi is v5te // https://github.com/rust-lang/rust/blob/1.70.0/compiler/rustc_target/src/spec/arm_linux_androideabi.rs#L11-L12 _ if target == "arm-linux-androideabi" => subarch = "v5te", - // armeb-unknown-linux-gnueabi is v8 + // armeb-unknown-linux-gnueabi is v8 & aclass // https://github.com/rust-lang/rust/blob/1.70.0/compiler/rustc_target/src/spec/armeb_unknown_linux_gnueabi.rs#L12 _ if target == "armeb-unknown-linux-gnueabi" => subarch = "v8", // v6 targets other than v6m don't have *class target feature. diff --git a/portable-atomic-util/build.rs b/portable-atomic-util/build.rs index d66a2643..e68eb3cc 100644 --- a/portable-atomic-util/build.rs +++ b/portable-atomic-util/build.rs @@ -2,7 +2,8 @@ // The rustc-cfg emitted by the build script are *not* public API. -#![warn(rust_2018_idioms, single_use_lifetimes)] +#![warn(rust_2018_idioms, single_use_lifetimes, clippy::pedantic)] +#![allow(clippy::single_match_else, clippy::too_many_lines)] // version.rs is shared with portable-atomic's build script, and portable-atomic-util only uses a part of it. #[allow(dead_code)] diff --git a/portable-atomic-util/src/lib.rs b/portable-atomic-util/src/lib.rs index 560517bc..5d24c974 100644 --- a/portable-atomic-util/src/lib.rs +++ b/portable-atomic-util/src/lib.rs @@ -45,31 +45,33 @@ See [#1] for other primitives being considered for addition to this crate. ) ))] #![warn( - missing_debug_implementations, - missing_docs, rust_2018_idioms, single_use_lifetimes, - unreachable_pub -)] -#![cfg_attr(not(portable_atomic_no_unsafe_op_in_unsafe_fn), warn(unsafe_op_in_unsafe_fn))] // unsafe_op_in_unsafe_fn requires Rust 1.52 -#![cfg_attr(portable_atomic_no_unsafe_op_in_unsafe_fn, allow(unused_unsafe))] -#![warn( + unreachable_pub, clippy::pedantic, - // lints for public library + // Lints that may help when writing public library. + missing_debug_implementations, + missing_docs, clippy::alloc_instead_of_core, clippy::exhaustive_enums, clippy::exhaustive_structs, + clippy::impl_trait_in_params, + // clippy::missing_inline_in_public_items, clippy::std_instead_of_alloc, clippy::std_instead_of_core, - // lints that help writing unsafe code + // Lints that may help when writing unsafe code. + improper_ctypes, + // improper_ctypes_definitions, // requires Rust 1.46 + // unsafe_op_in_unsafe_fn, // set conditionally since it requires Rust 1.52 clippy::as_ptr_cast_mut, clippy::default_union_representation, + clippy::inline_asm_x86_att_syntax, clippy::trailing_empty_array, clippy::transmute_undefined_repr, clippy::undocumented_unsafe_blocks, - // misc - clippy::inline_asm_x86_att_syntax, )] +#![cfg_attr(not(portable_atomic_no_unsafe_op_in_unsafe_fn), warn(unsafe_op_in_unsafe_fn))] // unsafe_op_in_unsafe_fn requires Rust 1.52 +#![cfg_attr(portable_atomic_no_unsafe_op_in_unsafe_fn, allow(unused_unsafe))] #![allow( clippy::cast_lossless, clippy::doc_markdown, diff --git a/src/lib.rs b/src/lib.rs index 115b682e..4fa69e9c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -196,33 +196,33 @@ RUSTFLAGS="--cfg portable_atomic_no_outline_atomics" cargo ... ) ))] #![warn( - improper_ctypes, - missing_debug_implementations, - missing_docs, rust_2018_idioms, single_use_lifetimes, - unreachable_pub -)] -#![cfg_attr(not(portable_atomic_no_unsafe_op_in_unsafe_fn), warn(unsafe_op_in_unsafe_fn))] // unsafe_op_in_unsafe_fn requires Rust 1.52 -#![cfg_attr(portable_atomic_no_unsafe_op_in_unsafe_fn, allow(unused_unsafe))] -#![warn( + unreachable_pub, clippy::pedantic, - // lints for public library + // Lints that may help when writing public library. + missing_debug_implementations, + missing_docs, clippy::alloc_instead_of_core, clippy::exhaustive_enums, clippy::exhaustive_structs, + clippy::impl_trait_in_params, + clippy::missing_inline_in_public_items, clippy::std_instead_of_alloc, clippy::std_instead_of_core, - // lints that help writing unsafe code + // Lints that may help when writing unsafe code. + improper_ctypes, + // improper_ctypes_definitions, // requires Rust 1.46 + // unsafe_op_in_unsafe_fn, // set conditionally since it requires Rust 1.52 clippy::as_ptr_cast_mut, clippy::default_union_representation, + clippy::inline_asm_x86_att_syntax, clippy::trailing_empty_array, clippy::transmute_undefined_repr, clippy::undocumented_unsafe_blocks, - // misc - clippy::inline_asm_x86_att_syntax, - clippy::missing_inline_in_public_items, )] +#![cfg_attr(not(portable_atomic_no_unsafe_op_in_unsafe_fn), warn(unsafe_op_in_unsafe_fn))] // unsafe_op_in_unsafe_fn requires Rust 1.52 +#![cfg_attr(portable_atomic_no_unsafe_op_in_unsafe_fn, allow(unused_unsafe))] #![allow( clippy::cast_lossless, clippy::doc_markdown, diff --git a/tools/codegen/src/ffi.rs b/tools/codegen/src/ffi.rs index 501909eb..a6a3725e 100644 --- a/tools/codegen/src/ffi.rs +++ b/tools/codegen/src/ffi.rs @@ -494,7 +494,7 @@ pub(crate) fn gen() -> Result<()> { src_dir.join("include"), src_dir.join("include/sys"), src_dir.join("lib/libpthread"), - ] + ]; } fuchsia => { header_path = src_dir.join(header.path);