Merge rust-bitcoin/rust-bitcoin#2403: Make crate level attributes uniform

0997382772 io: Enable alloc from std (Tobin C. Harding)
ba1166a63b Make crate level attributes uniform (Tobin C. Harding)

Pull request description:

  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.

ACKs for top commit:
  apoelstra:
    ACK 0997382772
  Kixunil:
    ACK 0997382772

Tree-SHA512: ef1f638aca171536287cce369be98998e871d26468ad2d8c39d9004db610b406471809c283540a4a19bcede78b12b8976a1bb37e5d431fbff8c8a3e53a64d4e3
This commit is contained in:
Andrew Poelstra 2024-02-01 14:12:02 +00:00
commit 7b937acf17
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
6 changed files with 43 additions and 23 deletions

View File

@ -29,18 +29,20 @@
//! happen the implementations diverge one day. //! happen the implementations diverge one day.
#![cfg_attr(all(not(feature = "std"), not(test)), no_std)] #![cfg_attr(all(not(feature = "std"), not(test)), no_std)]
// Experimental features we need. // Experimental features we need.
#![cfg_attr(bench, feature(test))]
#![cfg_attr(docsrs, feature(doc_auto_cfg))] #![cfg_attr(docsrs, feature(doc_auto_cfg))]
// Coding conventions #![cfg_attr(bench, feature(test))]
// Coding conventions.
#![warn(missing_docs)] #![warn(missing_docs)]
// Instead of littering the codebase for non-fuzzing code just globally allow. // Instead of littering the codebase for non-fuzzing code just globally allow.
#![cfg_attr(fuzzing, allow(dead_code, unused_imports))] #![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::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::manual_range_contains)] // more readable than clippy's format
#![allow(clippy::unconditional_recursion)] // broken; see https://github.com/rust-lang/rust-clippy/issues/12133
// Disable 16-bit support at least for now as we can't guarantee it yet. // Disable 16-bit support at least for now as we can't guarantee it yet.
#[cfg(target_pointer_width = "16")] #[cfg(target_pointer_width = "16")]

View File

@ -65,21 +65,21 @@
//! # fn main() {} //! # fn main() {}
//! ``` //! ```
// Coding conventions #![cfg_attr(all(not(test), not(feature = "std")), no_std)]
#![warn(missing_docs)]
// Experimental features we need. // Experimental features we need.
#![cfg_attr(docsrs, feature(doc_auto_cfg))] #![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![cfg_attr(bench, feature(test))] #![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 // Coding conventions.
// that don't do anything but annoy us and cant actually ever be resolved. #![warn(missing_docs)]
#![allow(bare_trait_objects)]
#![allow(ellipsis_inclusive_range_patterns)]
#![cfg_attr(all(not(test), not(feature = "std")), no_std)]
// Instead of littering the codebase for non-fuzzing code just globally allow. // Instead of littering the codebase for non-fuzzing code just globally allow.
#![cfg_attr(hashes_fuzz, allow(dead_code, unused_imports))] #![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::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")))] #[cfg(all(feature = "alloc", not(feature = "std")))]
extern crate alloc; extern crate alloc;

View File

@ -7,12 +7,16 @@
//! //!
#![no_std] #![no_std]
// Experimental features we need. // Experimental features we need.
#![cfg_attr(docsrs, feature(doc_auto_cfg))] #![cfg_attr(docsrs, feature(doc_auto_cfg))]
// Coding conventions
// Coding conventions.
#![warn(missing_docs)] #![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::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")] #[cfg(feature = "alloc")]
extern crate alloc; extern crate alloc;

View File

@ -15,7 +15,7 @@ exclude = ["tests", "contrib"]
[features] [features]
default = ["std"] default = ["std"]
std = [] std = ["alloc"]
alloc = [] alloc = []
[package.metadata.docs.rs] [package.metadata.docs.rs]

View File

@ -9,10 +9,18 @@
//! `std::io`'s traits without unnecessary complexity. //! `std::io`'s traits without unnecessary complexity.
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
// Experimental features we need. // Experimental features we need.
#![cfg_attr(docsrs, feature(doc_auto_cfg))] #![cfg_attr(docsrs, feature(doc_auto_cfg))]
#[cfg(any(feature = "alloc", feature = "std"))] // 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(feature = "alloc")]
extern crate alloc; extern crate alloc;
mod error; mod error;
@ -308,6 +316,9 @@ pub fn sink() -> Sink { Sink }
mod tests { mod tests {
use super::*; use super::*;
#[cfg(feature = "alloc")]
use alloc::{string::ToString, vec};
#[test] #[test]
fn buf_read_fill_and_consume_slice() { fn buf_read_fill_and_consume_slice() {
let data = [0_u8, 1, 2]; let data = [0_u8, 1, 2];
@ -331,7 +342,7 @@ mod tests {
} }
#[test] #[test]
#[cfg(any(feature = "alloc", feature = "std"))] #[cfg(feature = "alloc")]
fn read_to_limit_greater_than_total_length() { fn read_to_limit_greater_than_total_length() {
let s = "16-byte-string!!".to_string(); let s = "16-byte-string!!".to_string();
let mut reader = Cursor::new(&s); let mut reader = Cursor::new(&s);
@ -344,7 +355,7 @@ mod tests {
} }
#[test] #[test]
#[cfg(any(feature = "alloc", feature = "std"))] #[cfg(feature = "alloc")]
fn read_to_limit_less_than_total_length() { fn read_to_limit_less_than_total_length() {
let s = "16-byte-string!!".to_string(); let s = "16-byte-string!!".to_string();
let mut reader = Cursor::new(&s); let mut reader = Cursor::new(&s);

View File

@ -6,10 +6,13 @@
// Experimental features we need. // Experimental features we need.
#![cfg_attr(docsrs, feature(doc_auto_cfg))] #![cfg_attr(docsrs, feature(doc_auto_cfg))]
// Coding conventions
// Coding conventions.
#![warn(missing_docs)] #![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::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] #![no_std]