From ba1166a63b809e2caa0c6a192a79ab4d902dd5a6 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Thu, 25 Jan 2024 17:41:01 +1100 Subject: [PATCH] Make crate level attributes uniform Make the trait level attributes uniform across all released crates in the repo. Excludes things that are obviously not needed, eg, bench stuff if there is not bench code. - Remove `uninhabited_references` - this is allow by default now. - Remove `unconditional_recursion` and mark the single false positive we have with an `allow`. Note, this does not add `missing_docs` to the `io` crate. There is an open PR at the moment to add that along with the required docs. --- bitcoin/src/lib.rs | 14 ++++++++------ hashes/src/lib.rs | 18 +++++++++--------- internals/src/lib.rs | 8 ++++++-- io/src/lib.rs | 8 ++++++++ units/src/lib.rs | 7 +++++-- 5 files changed, 36 insertions(+), 19 deletions(-) diff --git a/bitcoin/src/lib.rs b/bitcoin/src/lib.rs index 6ea821b8..e3e81c80 100644 --- a/bitcoin/src/lib.rs +++ b/bitcoin/src/lib.rs @@ -29,18 +29,20 @@ //! happen the implementations diverge one day. #![cfg_attr(all(not(feature = "std"), not(test)), no_std)] + // Experimental features we need. -#![cfg_attr(bench, feature(test))] #![cfg_attr(docsrs, feature(doc_auto_cfg))] -// Coding conventions +#![cfg_attr(bench, feature(test))] + +// Coding conventions. #![warn(missing_docs)] + // Instead of littering the codebase for non-fuzzing code just globally allow. #![cfg_attr(fuzzing, allow(dead_code, unused_imports))] -// Exclude clippy lints we don't think are valuable + +// Exclude lints we don't think are valuable. #![allow(clippy::needless_question_mark)] // https://github.com/rust-bitcoin/rust-bitcoin/pull/2134 -#![allow(clippy::uninhabited_references)] // falsely claims that 100% safe code is UB -#![allow(clippy::manual_range_contains)] // more readable than clippy's format -#![allow(clippy::unconditional_recursion)] // broken; see https://github.com/rust-lang/rust-clippy/issues/12133 +#![allow(clippy::manual_range_contains)] // More readable than clippy's format. // Disable 16-bit support at least for now as we can't guarantee it yet. #[cfg(target_pointer_width = "16")] diff --git a/hashes/src/lib.rs b/hashes/src/lib.rs index dc73b38e..d2e7b850 100644 --- a/hashes/src/lib.rs +++ b/hashes/src/lib.rs @@ -65,21 +65,21 @@ //! # fn main() {} //! ``` -// Coding conventions -#![warn(missing_docs)] +#![cfg_attr(all(not(test), not(feature = "std")), no_std)] + // Experimental features we need. #![cfg_attr(docsrs, feature(doc_auto_cfg))] #![cfg_attr(bench, feature(test))] -// In general, rust is absolutely horrid at supporting users doing things like, -// for example, compiling Rust code for real environments. Disable useless lints -// that don't do anything but annoy us and cant actually ever be resolved. -#![allow(bare_trait_objects)] -#![allow(ellipsis_inclusive_range_patterns)] -#![cfg_attr(all(not(test), not(feature = "std")), no_std)] + +// Coding conventions. +#![warn(missing_docs)] + // Instead of littering the codebase for non-fuzzing code just globally allow. #![cfg_attr(hashes_fuzz, allow(dead_code, unused_imports))] -// Exclude clippy lints we don't think are valuable + +// Exclude lints we don't think are valuable. #![allow(clippy::needless_question_mark)] // https://github.com/rust-bitcoin/rust-bitcoin/pull/2134 +#![allow(clippy::manual_range_contains)] // More readable than clippy's format. #[cfg(all(feature = "alloc", not(feature = "std")))] extern crate alloc; diff --git a/internals/src/lib.rs b/internals/src/lib.rs index f9f41410..95a0e74a 100644 --- a/internals/src/lib.rs +++ b/internals/src/lib.rs @@ -7,12 +7,16 @@ //! #![no_std] + // Experimental features we need. #![cfg_attr(docsrs, feature(doc_auto_cfg))] -// Coding conventions + +// Coding conventions. #![warn(missing_docs)] -// Exclude clippy lints we don't think are valuable + +// Exclude lints we don't think are valuable. #![allow(clippy::needless_question_mark)] // https://github.com/rust-bitcoin/rust-bitcoin/pull/2134 +#![allow(clippy::manual_range_contains)] // More readable than clippy's format. #[cfg(feature = "alloc")] extern crate alloc; diff --git a/io/src/lib.rs b/io/src/lib.rs index a338b52e..d3d8ed55 100644 --- a/io/src/lib.rs +++ b/io/src/lib.rs @@ -9,9 +9,17 @@ //! `std::io`'s traits without unnecessary complexity. #![cfg_attr(not(feature = "std"), no_std)] + // Experimental features we need. #![cfg_attr(docsrs, feature(doc_auto_cfg))] +// Coding conventions. +// #![warn(missing_docs)] + +// Exclude lints we don't think are valuable. +#![allow(clippy::needless_question_mark)] // https://github.com/rust-bitcoin/rust-bitcoin/pull/2134 +#![allow(clippy::manual_range_contains)] // More readable than clippy's format. + #[cfg(any(feature = "alloc", feature = "std"))] extern crate alloc; diff --git a/units/src/lib.rs b/units/src/lib.rs index 2fcd4edd..a79f496c 100644 --- a/units/src/lib.rs +++ b/units/src/lib.rs @@ -6,10 +6,13 @@ // Experimental features we need. #![cfg_attr(docsrs, feature(doc_auto_cfg))] -// Coding conventions + +// Coding conventions. #![warn(missing_docs)] -// Exclude clippy lints we don't think are valuable + +// Exclude lints we don't think are valuable. #![allow(clippy::needless_question_mark)] // https://github.com/rust-bitcoin/rust-bitcoin/pull/2134 +#![allow(clippy::manual_range_contains)] // More readable than clippy's format. #![no_std]