diff --git a/Cargo.toml b/Cargo.toml index 86470f659..881acab26 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -377,6 +377,7 @@ unreachable_pub = "deny" unused_qualifications = "deny" variant_size_differences = "deny" non_camel_case_types = "deny" +unsafe_code = "deny" # Hot # unused_results = "deny" diff --git a/binaries/cuprated/src/main.rs b/binaries/cuprated/src/main.rs index 21eb07d58..122240680 100644 --- a/binaries/cuprated/src/main.rs +++ b/binaries/cuprated/src/main.rs @@ -1,5 +1,9 @@ #![doc = include_str!("../README.md")] #![cfg_attr(docsrs, feature(doc_cfg))] +#![forbid( + unsafe_code, + reason = "Crate-specific lints. There should be good reasoning when removing these." +)] #![allow( unused_imports, unreachable_pub, diff --git a/consensus/context/src/lib.rs b/consensus/context/src/lib.rs index adb333830..651adf365 100644 --- a/consensus/context/src/lib.rs +++ b/consensus/context/src/lib.rs @@ -4,6 +4,13 @@ //! This is used during contextual validation, this does not have all the data for contextual validation //! (outputs) for that you will need a [`Database`]. +#![forbid( + clippy::should_panic_without_expect, + clippy::single_char_lifetime_names, + unsafe_code, + reason = "Crate-specific lints. There should be good reasoning when removing these." +)] + // Used in documentation references for [`BlockChainContextRequest`] // FIXME: should we pull in a dependency just to link docs? use monero_serai as _; @@ -363,7 +370,7 @@ pub enum BlockChainContextResponse { } /// The blockchain context service. -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct BlockchainContextService { cached_context: Cache>, Arc>, diff --git a/consensus/context/src/task.rs b/consensus/context/src/task.rs index 327a3e067..9c0cce7f9 100644 --- a/consensus/context/src/task.rs +++ b/consensus/context/src/task.rs @@ -29,6 +29,7 @@ use crate::{ }; /// A request from the context service to the context task. +#[derive(Debug)] pub(super) struct ContextTaskRequest { /// The request. pub req: BlockChainContextRequest, diff --git a/consensus/fast-sync/src/fast_sync.rs b/consensus/fast-sync/src/fast_sync.rs index 6016bb0c6..beded342b 100644 --- a/consensus/fast-sync/src/fast_sync.rs +++ b/consensus/fast-sync/src/fast_sync.rs @@ -41,13 +41,14 @@ fn max_height() -> u64 { (HASHES_OF_HASHES.len() * BATCH_SIZE) as u64 } -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, PartialEq, Eq, Copy, Clone)] pub struct ValidBlockId(BlockId); fn valid_block_ids(block_ids: &[BlockId]) -> Vec { block_ids.iter().map(|b| ValidBlockId(*b)).collect() } +#[derive(Debug)] #[expect(clippy::large_enum_variant)] pub enum FastSyncRequest { ValidateHashes { @@ -110,6 +111,7 @@ impl From for FastSyncError { } } +#[derive(Debug)] pub struct FastSyncService { context_svc: BlockchainContextService, } diff --git a/consensus/fast-sync/src/lib.rs b/consensus/fast-sync/src/lib.rs index 8dbdc6495..9c6d32a28 100644 --- a/consensus/fast-sync/src/lib.rs +++ b/consensus/fast-sync/src/lib.rs @@ -1,3 +1,14 @@ +#![forbid( + clippy::missing_assert_message, + clippy::should_panic_without_expect, + clippy::single_char_lifetime_names, + unsafe_code, + unused_results, + missing_copy_implementations, + missing_debug_implementations, + reason = "Crate-specific lints. There should be good reasoning when removing these." +)] + // Used in `create.rs` use clap as _; use cuprate_blockchain as _; diff --git a/consensus/rules/src/blocks.rs b/consensus/rules/src/blocks.rs index b9f5683fa..1c9961f11 100644 --- a/consensus/rules/src/blocks.rs +++ b/consensus/rules/src/blocks.rs @@ -210,7 +210,7 @@ fn check_txs_unique(txs: &[[u8; 32]]) -> Result<(), BlockError> { /// This struct contains the data needed to verify a block, implementers MUST make sure /// the data in this struct is calculated correctly. -#[derive(Debug, Clone, Eq, PartialEq)] +#[derive(Debug, Copy, Clone, Eq, PartialEq)] pub struct ContextToVerifyBlock { /// ref: pub median_weight_for_block_reward: usize, diff --git a/consensus/rules/src/lib.rs b/consensus/rules/src/lib.rs index eef20c1e5..1ff979e56 100644 --- a/consensus/rules/src/lib.rs +++ b/consensus/rules/src/lib.rs @@ -1,3 +1,10 @@ +#![forbid( + unsafe_code, + missing_copy_implementations, + missing_debug_implementations, + reason = "Crate-specific lints. There should be good reasoning when removing these." +)] + cfg_if::cfg_if! { // Used in external `tests/`. if #[cfg(test)] { diff --git a/consensus/src/lib.rs b/consensus/src/lib.rs index 3d8169c4c..9b94d1b92 100644 --- a/consensus/src/lib.rs +++ b/consensus/src/lib.rs @@ -7,6 +7,12 @@ //! with [`BlockchainResponse`]. //! +#![forbid( + unsafe_code, + missing_copy_implementations, + reason = "Crate-specific lints. There should be good reasoning when removing these." +)] + cfg_if::cfg_if! { // Used in external `tests/`. if #[cfg(test)] { diff --git a/constants/src/lib.rs b/constants/src/lib.rs index f1b29fb0d..94e3f5dd8 100644 --- a/constants/src/lib.rs +++ b/constants/src/lib.rs @@ -1,5 +1,18 @@ #![doc = include_str!("../README.md")] -#![deny(missing_docs, reason = "all constants should document what they are")] +#![forbid( + clippy::missing_assert_message, + clippy::missing_docs_in_private_items, + clippy::missing_errors_doc, + clippy::missing_panics_doc, + clippy::should_panic_without_expect, + clippy::single_char_lifetime_names, + missing_docs, + unsafe_code, + unused_results, + missing_copy_implementations, + missing_debug_implementations, + reason = "Crate-specific lints. There should be good reasoning when removing these." +)] #![no_std] // This can be removed if we eventually need `std`. mod macros; diff --git a/constants/src/macros.rs b/constants/src/macros.rs index f41ae7b87..d6df1c62c 100644 --- a/constants/src/macros.rs +++ b/constants/src/macros.rs @@ -1,3 +1,5 @@ +//! General macros. + /// Output a string link to `monerod` source code. #[allow( clippy::allow_attributes, diff --git a/cryptonight/src/lib.rs b/cryptonight/src/lib.rs index a52c8d56e..995d227cd 100644 --- a/cryptonight/src/lib.rs +++ b/cryptonight/src/lib.rs @@ -1,3 +1,14 @@ +#![forbid( + clippy::missing_errors_doc, + clippy::missing_panics_doc, + clippy::should_panic_without_expect, + clippy::single_char_lifetime_names, + unsafe_code, + missing_copy_implementations, + missing_debug_implementations, + reason = "Crate-specific lints. There should be good reasoning when removing these." +)] + mod blake256; mod cnaes; mod hash_v2; @@ -18,6 +29,7 @@ pub struct DataCanNotBeHashed; /// Calculates the `CryptoNight` v1 hash of buf. /// +/// # Errors /// This will return an error if buf is less than 43 bytes. pub fn cryptonight_hash_v1(buf: &[u8]) -> Result<[u8; 32], DataCanNotBeHashed> { if buf.len() < 43 { diff --git a/helper/src/lib.rs b/helper/src/lib.rs index 9bd64fa17..83db0e4b7 100644 --- a/helper/src/lib.rs +++ b/helper/src/lib.rs @@ -1,5 +1,10 @@ #![doc = include_str!("../README.md")] #![cfg_attr(not(feature = "std"), no_std)] +#![forbid( + clippy::should_panic_without_expect, + clippy::single_char_lifetime_names, + reason = "Crate-specific lints. There should be good reasoning when removing these." +)] //---------------------------------------------------------------------------------------------------- Public API #[cfg(feature = "asynch")] diff --git a/helper/src/thread.rs b/helper/src/thread.rs index 45890d9c4..ca9d5952f 100644 --- a/helper/src/thread.rs +++ b/helper/src/thread.rs @@ -69,6 +69,7 @@ impl_thread_percent! { /// /// On macOS and *BSD: +20 /// On Linux: +19 +#[expect(unsafe_code, reason = "Must call C")] pub fn low_priority_thread() { #[cfg(target_os = "windows")] { diff --git a/net/epee-encoding/src/lib.rs b/net/epee-encoding/src/lib.rs index a814cac1d..ce7a3ef42 100644 --- a/net/epee-encoding/src/lib.rs +++ b/net/epee-encoding/src/lib.rs @@ -59,6 +59,13 @@ //! //! ``` +#![forbid( + clippy::missing_assert_message, + clippy::should_panic_without_expect, + unsafe_code, + reason = "Crate-specific lints. There should be good reasoning when removing these." +)] + #[cfg(test)] use hex as _; diff --git a/net/fixed-bytes/src/lib.rs b/net/fixed-bytes/src/lib.rs index b1b064b1e..c86c38e13 100644 --- a/net/fixed-bytes/src/lib.rs +++ b/net/fixed-bytes/src/lib.rs @@ -1,4 +1,14 @@ #![doc = include_str!("../README.md")] +#![forbid( + clippy::missing_assert_message, + clippy::missing_errors_doc, + clippy::missing_panics_doc, + clippy::should_panic_without_expect, + clippy::single_char_lifetime_names, + unsafe_code, + missing_debug_implementations, + reason = "Crate-specific lints. There should be good reasoning when removing these." +)] use core::{ fmt::{Debug, Formatter}, diff --git a/net/levin/src/lib.rs b/net/levin/src/lib.rs index a3f4b694d..1ff249edf 100644 --- a/net/levin/src/lib.rs +++ b/net/levin/src/lib.rs @@ -27,7 +27,13 @@ //! This project is licensed under the MIT License. // Coding conventions -#![forbid(unsafe_code)] +#![forbid( + clippy::missing_assert_message, + clippy::should_panic_without_expect, + unsafe_code, + unused_results, + reason = "Crate-specific lints. There should be good reasoning when removing these." +)] #![deny(non_upper_case_globals)] #![deny(non_camel_case_types)] #![deny(unused_mut)] diff --git a/net/wire/src/lib.rs b/net/wire/src/lib.rs index 674a2e916..ef03ab3fb 100644 --- a/net/wire/src/lib.rs +++ b/net/wire/src/lib.rs @@ -22,6 +22,14 @@ //! //! This project is licensed under the MIT License. +#![forbid( + clippy::missing_assert_message, + clippy::missing_panics_doc, + clippy::should_panic_without_expect, + unsafe_code, + reason = "Crate-specific lints. There should be good reasoning when removing these." +)] + pub mod network_address; pub mod p2p; diff --git a/p2p/address-book/src/lib.rs b/p2p/address-book/src/lib.rs index 054be4625..15f56725f 100644 --- a/p2p/address-book/src/lib.rs +++ b/p2p/address-book/src/lib.rs @@ -10,6 +10,15 @@ //! clear net peers getting linked to their dark counterparts //! and so peers will only get told about peers they can //! connect to. + +#![forbid( + clippy::missing_assert_message, + clippy::should_panic_without_expect, + missing_docs, + unsafe_code, + reason = "Crate-specific lints. There should be good reasoning when removing these." +)] + use std::{io::ErrorKind, path::PathBuf, time::Duration}; use cuprate_p2p_core::{NetZoneAddress, NetworkZone}; diff --git a/p2p/async-buffer/src/lib.rs b/p2p/async-buffer/src/lib.rs index 8174481e6..8236127d5 100644 --- a/p2p/async-buffer/src/lib.rs +++ b/p2p/async-buffer/src/lib.rs @@ -4,6 +4,15 @@ //! //! Weight is used to bound the channel, on creation you specify a max weight and for each value you //! specify a weight. + +#![forbid( + clippy::missing_errors_doc, + clippy::should_panic_without_expect, + unsafe_code, + missing_copy_implementations, + reason = "Crate-specific lints. There should be good reasoning when removing these." +)] + use std::{ cmp::min, future::Future, diff --git a/p2p/bucket/src/lib.rs b/p2p/bucket/src/lib.rs index 0f73eea29..d7026b5d4 100644 --- a/p2p/bucket/src/lib.rs +++ b/p2p/bucket/src/lib.rs @@ -38,11 +38,23 @@ //! //! ``` -use arrayvec::{ArrayVec, CapacityError}; -use rand::random; +#![forbid( + clippy::missing_assert_message, + clippy::missing_docs_in_private_items, + clippy::missing_errors_doc, + clippy::should_panic_without_expect, + clippy::single_char_lifetime_names, + missing_docs, + unsafe_code, + missing_copy_implementations, + reason = "Crate-specific lints. There should be good reasoning when removing these." +)] use std::{collections::BTreeMap, net::Ipv4Addr}; +use arrayvec::{ArrayVec, CapacityError}; +use rand::random; + /// A discriminant that can be computed from the type. pub trait Bucketable: Sized + Eq + Clone { /// The type of the discriminant being used in the Binary tree. diff --git a/p2p/dandelion-tower/src/lib.rs b/p2p/dandelion-tower/src/lib.rs index 2c8de713a..3f9270dfd 100644 --- a/p2p/dandelion-tower/src/lib.rs +++ b/p2p/dandelion-tower/src/lib.rs @@ -58,6 +58,17 @@ //! When removing data, for example because of a new block, you can remove from both pools provided it doesn't leak //! any data about stem transactions. You will probably want to set up a task that monitors the tx pool for stuck transactions, //! transactions that slipped in just as one was removed etc, this crate does not handle that. + +#![forbid( + clippy::missing_assert_message, + clippy::missing_errors_doc, + clippy::should_panic_without_expect, + clippy::single_char_lifetime_names, + unsafe_code, + missing_copy_implementations, + reason = "Crate-specific lints. There should be good reasoning when removing these." +)] + mod config; #[cfg(feature = "txpool")] pub mod pool; diff --git a/p2p/p2p-core/src/lib.rs b/p2p/p2p-core/src/lib.rs index e57469329..60767506d 100644 --- a/p2p/p2p-core/src/lib.rs +++ b/p2p/p2p-core/src/lib.rs @@ -57,6 +57,14 @@ //! # }); //! ``` +#![forbid( + clippy::missing_assert_message, + clippy::should_panic_without_expect, + clippy::single_char_lifetime_names, + unsafe_code, + reason = "Crate-specific lints. There should be good reasoning when removing these." +)] + cfg_if::cfg_if! { // Used in `tests/` if #[cfg(test)] { diff --git a/p2p/p2p/src/lib.rs b/p2p/p2p/src/lib.rs index fb506582d..051794098 100644 --- a/p2p/p2p/src/lib.rs +++ b/p2p/p2p/src/lib.rs @@ -2,6 +2,16 @@ //! //! This crate contains a [`NetworkInterface`] which allows interacting with the Monero P2P network on //! a certain [`NetworkZone`] + +#![forbid( + clippy::missing_assert_message, + clippy::missing_errors_doc, + clippy::should_panic_without_expect, + clippy::single_char_lifetime_names, + unsafe_code, + reason = "Crate-specific lints. There should be good reasoning when removing these." +)] + use std::sync::Arc; use futures::FutureExt; diff --git a/pruning/src/lib.rs b/pruning/src/lib.rs index e49aedb1f..a83996bc2 100644 --- a/pruning/src/lib.rs +++ b/pruning/src/lib.rs @@ -18,6 +18,16 @@ //! ``` //! +#![forbid( + clippy::missing_assert_message, + clippy::should_panic_without_expect, + clippy::single_char_lifetime_names, + unsafe_code, + unused_results, + missing_debug_implementations, + reason = "Crate-specific lints. There should be good reasoning when removing these." +)] + use std::cmp::Ordering; use cuprate_constants::block::MAX_BLOCK_HEIGHT_USIZE; diff --git a/rpc/interface/src/lib.rs b/rpc/interface/src/lib.rs index 1f84738e2..94f8defa1 100644 --- a/rpc/interface/src/lib.rs +++ b/rpc/interface/src/lib.rs @@ -1,5 +1,19 @@ #![doc = include_str!("../README.md")] #![cfg_attr(docsrs, feature(doc_cfg))] +#![forbid( + clippy::missing_assert_message, + clippy::missing_docs_in_private_items, + clippy::missing_errors_doc, + clippy::missing_panics_doc, + clippy::should_panic_without_expect, + clippy::single_char_lifetime_names, + missing_docs, + unsafe_code, + unused_results, + missing_copy_implementations, + missing_debug_implementations, + reason = "Crate-specific lints. There should be good reasoning when removing these." +)] mod route; mod router_builder; diff --git a/rpc/interface/src/router_builder.rs b/rpc/interface/src/router_builder.rs index d18a694c9..843f5a3ba 100644 --- a/rpc/interface/src/router_builder.rs +++ b/rpc/interface/src/router_builder.rs @@ -69,7 +69,7 @@ macro_rules! generate_router_builder { /// .all() /// .build(); /// ``` - #[derive(Clone)] + #[derive(Debug, Clone)] pub struct RouterBuilder { router: Router, } diff --git a/rpc/interface/src/rpc_handler_dummy.rs b/rpc/interface/src/rpc_handler_dummy.rs index 9d5009e45..4b9be4cdf 100644 --- a/rpc/interface/src/rpc_handler_dummy.rs +++ b/rpc/interface/src/rpc_handler_dummy.rs @@ -28,7 +28,7 @@ use crate::rpc_handler::RpcHandler; /// /// This is mostly used for testing purposes and can /// be disabled by disable the `dummy` feature flag. -#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] pub struct RpcHandlerDummy { /// Should this RPC server be [restricted](RpcHandler::restricted)? diff --git a/rpc/json-rpc/src/lib.rs b/rpc/json-rpc/src/lib.rs index dfc4b1817..842f194e8 100644 --- a/rpc/json-rpc/src/lib.rs +++ b/rpc/json-rpc/src/lib.rs @@ -1,4 +1,16 @@ #![doc = include_str!("../README.md")] +#![forbid( + clippy::missing_assert_message, + clippy::missing_docs_in_private_items, + clippy::missing_errors_doc, + clippy::missing_panics_doc, + clippy::should_panic_without_expect, + missing_docs, + unsafe_code, + missing_copy_implementations, + missing_debug_implementations, + reason = "Crate-specific lints. There should be good reasoning when removing these." +)] pub mod error; diff --git a/rpc/types/src/lib.rs b/rpc/types/src/lib.rs index 403a3ea3a..2d09e24af 100644 --- a/rpc/types/src/lib.rs +++ b/rpc/types/src/lib.rs @@ -4,6 +4,17 @@ clippy::allow_attributes, reason = "macros (internal + serde) make this lint hard to satisfy" )] +#![forbid( + clippy::missing_assert_message, + clippy::missing_errors_doc, + clippy::missing_panics_doc, + clippy::should_panic_without_expect, + clippy::single_char_lifetime_names, + unsafe_code, + unused_results, + missing_debug_implementations, + reason = "Crate-specific lints. There should be good reasoning when removing these." +)] mod constants; #[cfg(any(feature = "serde", feature = "epee"))] diff --git a/storage/blockchain/src/lib.rs b/storage/blockchain/src/lib.rs index 7db8cc6ee..d6b163334 100644 --- a/storage/blockchain/src/lib.rs +++ b/storage/blockchain/src/lib.rs @@ -3,6 +3,13 @@ // See `cuprate-database` for reasoning. clippy::significant_drop_tightening )] +#![forbid( + clippy::should_panic_without_expect, + missing_docs, + missing_copy_implementations, + missing_debug_implementations, + reason = "Crate-specific lints. There should be good reasoning when removing these." +)] // Only allow building 64-bit targets. // diff --git a/storage/blockchain/src/service/read.rs b/storage/blockchain/src/service/read.rs index 45c5aa6fd..6bfc9ec19 100644 --- a/storage/blockchain/src/service/read.rs +++ b/storage/blockchain/src/service/read.rs @@ -174,6 +174,7 @@ fn thread_local(env: &impl Env) -> ThreadLocal { macro_rules! get_tables { ($env_inner:ident, $tx_ro:ident, $tables:ident) => {{ $tables.get_or_try(|| { + #[expect(unsafe_code)] match $env_inner.open_tables($tx_ro) { // SAFETY: see above macro doc comment. Ok(tables) => Ok(unsafe { crate::unsafe_sendable::UnsafeSendable::new(tables) }), diff --git a/storage/blockchain/src/unsafe_sendable.rs b/storage/blockchain/src/unsafe_sendable.rs index 76c789993..7fa2ca93c 100644 --- a/storage/blockchain/src/unsafe_sendable.rs +++ b/storage/blockchain/src/unsafe_sendable.rs @@ -1,5 +1,7 @@ //! Wrapper type for partially-`unsafe` usage of `T: !Send`. +#![expect(unsafe_code)] + //---------------------------------------------------------------------------------------------------- Import use std::{ borrow::Borrow, diff --git a/storage/database/src/backend/heed/database.rs b/storage/database/src/backend/heed/database.rs index c17fddf68..170310414 100644 --- a/storage/database/src/backend/heed/database.rs +++ b/storage/database/src/backend/heed/database.rs @@ -121,6 +121,7 @@ impl DatabaseIter for HeedTableRo<'_, T> { } //---------------------------------------------------------------------------------------------------- DatabaseRo Impl +#[expect(unsafe_code)] // SAFETY: `HeedTableRo: !Send` as it holds a reference to `heed::RoTxn: Send + !Sync`. unsafe impl DatabaseRo for HeedTableRo<'_, T> { #[inline] @@ -150,6 +151,7 @@ unsafe impl DatabaseRo for HeedTableRo<'_, T> { } //---------------------------------------------------------------------------------------------------- DatabaseRw Impl +#[expect(unsafe_code)] // SAFETY: The `Send` bound only applies to `HeedTableRo`. // `HeedTableRw`'s write transaction is `!Send`. unsafe impl DatabaseRo for HeedTableRw<'_, '_, T> { diff --git a/storage/database/src/backend/heed/env.rs b/storage/database/src/backend/heed/env.rs index 4d7e1b5c2..b590c6ea0 100644 --- a/storage/database/src/backend/heed/env.rs +++ b/storage/database/src/backend/heed/env.rs @@ -112,6 +112,7 @@ impl Env for ConcreteEnv { #[cold] #[inline(never)] // called once. + #[expect(unsafe_code, reason = "LMDB/heed invariants")] fn open(config: Config) -> Result { // @@ -220,6 +221,7 @@ impl Env for ConcreteEnv { // and we have a WriteGuard to it, so we're safe. // // + #[expect(unsafe_code)] unsafe { // INVARIANT: `resize()` returns a valid `usize` to resize to. self.env diff --git a/storage/database/src/backend/redb/database.rs b/storage/database/src/backend/redb/database.rs index 84d7c75c8..e0b3f552f 100644 --- a/storage/database/src/backend/redb/database.rs +++ b/storage/database/src/backend/redb/database.rs @@ -108,6 +108,7 @@ impl DatabaseIter for RedbTableRo { } //---------------------------------------------------------------------------------------------------- DatabaseRo +#[expect(unsafe_code)] // SAFETY: Both `redb`'s transaction and table types are `Send + Sync`. unsafe impl DatabaseRo for RedbTableRo { #[inline] @@ -137,6 +138,7 @@ unsafe impl DatabaseRo for RedbTableRo } //---------------------------------------------------------------------------------------------------- DatabaseRw +#[expect(unsafe_code)] // SAFETY: Both `redb`'s transaction and table types are `Send + Sync`. unsafe impl DatabaseRo for RedbTableRw<'_, T::Key, T::Value> { #[inline] diff --git a/storage/database/src/database.rs b/storage/database/src/database.rs index fcee041f5..2c0c1b454 100644 --- a/storage/database/src/database.rs +++ b/storage/database/src/database.rs @@ -109,6 +109,7 @@ This will return [`crate::RuntimeError::KeyNotFound`] if: /// /// - /// - +#[expect(unsafe_code)] pub unsafe trait DatabaseRo { /// Get the value corresponding to a key. #[doc = doc_database!()] diff --git a/storage/database/src/lib.rs b/storage/database/src/lib.rs index 8e48fca0d..e13ce7b18 100644 --- a/storage/database/src/lib.rs +++ b/storage/database/src/lib.rs @@ -12,7 +12,17 @@ // Rust thinks `env_inner` can be dropped earlier // but it cannot, we need it for the lifetime of // the database transaction + tables. - clippy::significant_drop_tightening + clippy::significant_drop_tightening, +)] +#![forbid( + clippy::missing_assert_message, + clippy::missing_docs_in_private_items, + clippy::missing_errors_doc, + clippy::missing_panics_doc, + clippy::should_panic_without_expect, + missing_docs, + missing_copy_implementations, + reason = "Crate-specific lints. There should be good reasoning when removing these." )] // Allow some lints in tests. #![cfg_attr( diff --git a/storage/service/src/lib.rs b/storage/service/src/lib.rs index 51d896a4d..37195e5c9 100644 --- a/storage/service/src/lib.rs +++ b/storage/service/src/lib.rs @@ -1,4 +1,14 @@ #![doc = include_str!("../README.md")] +#![forbid( + clippy::missing_assert_message, + clippy::missing_errors_doc, + clippy::should_panic_without_expect, + clippy::single_char_lifetime_names, + missing_docs, + unsafe_code, + missing_copy_implementations, + reason = "Crate-specific lints. There should be good reasoning when removing these." +)] mod reader_threads; mod service; diff --git a/storage/txpool/src/lib.rs b/storage/txpool/src/lib.rs index 53e53ecfe..dbe20f2bd 100644 --- a/storage/txpool/src/lib.rs +++ b/storage/txpool/src/lib.rs @@ -3,6 +3,13 @@ // See `cuprate-database` for reasoning. clippy::significant_drop_tightening )] +#![forbid( + clippy::missing_assert_message, + clippy::should_panic_without_expect, + clippy::single_char_lifetime_names, + unsafe_code, + reason = "Crate-specific lints. There should be good reasoning when removing these." +)] // Used in docs: . use tower as _; diff --git a/types/src/json/output.rs b/types/src/json/output.rs index 182618cda..bde6116cf 100644 --- a/types/src/json/output.rs +++ b/types/src/json/output.rs @@ -10,7 +10,7 @@ use serde::{Deserialize, Serialize}; use crate::hex::HexBytes; /// JSON representation of an output. -#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct Output { pub amount: u64, @@ -18,7 +18,7 @@ pub struct Output { } /// [`Output::target`]. -#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", serde(untagged))] pub enum Target { @@ -35,7 +35,7 @@ impl Default for Target { } /// [`Target::TaggedKey::tagged_key`]. -#[derive(Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct TaggedKey { pub key: HexBytes<32>, diff --git a/types/src/json/tx.rs b/types/src/json/tx.rs index a18dc89a6..25588d675 100644 --- a/types/src/json/tx.rs +++ b/types/src/json/tx.rs @@ -343,7 +343,7 @@ pub struct Clsag { } /// [`RctSignatures::NonCoinbase::ecdhInfo`]. -#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", serde(untagged))] #[expect(variant_size_differences)] diff --git a/types/src/lib.rs b/types/src/lib.rs index 7aaf0b9e2..72e9d7a74 100644 --- a/types/src/lib.rs +++ b/types/src/lib.rs @@ -3,6 +3,19 @@ #![cfg_attr(any(feature = "proptest"), allow(non_local_definitions))] // Allow some lints when running in debug mode. #![cfg_attr(debug_assertions, allow(clippy::todo, clippy::multiple_crate_versions))] +#![forbid( + clippy::missing_assert_message, + clippy::missing_docs_in_private_items, + clippy::missing_errors_doc, + clippy::missing_panics_doc, + clippy::should_panic_without_expect, + clippy::single_char_lifetime_names, + unsafe_code, + unused_results, + missing_copy_implementations, + missing_debug_implementations, + reason = "Crate-specific lints. There should be good reasoning when removing these." +)] //---------------------------------------------------------------------------------------------------- Public API // Import private modules, export public types. diff --git a/types/src/types.rs b/types/src/types.rs index 8a5b5aad4..ec9364868 100644 --- a/types/src/types.rs +++ b/types/src/types.rs @@ -197,7 +197,7 @@ pub struct MinerData { /// A transaction in the txpool. /// /// Used in [`MinerData::tx_backlog`]. -#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct MinerDataTxBacklogEntry { pub id: [u8; 32], pub weight: u64, @@ -243,7 +243,7 @@ pub struct ChainInfo { } /// Used in RPC's `add_aux_pow`. -#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct AuxPow { pub id: [u8; 32], pub hash: [u8; 32], diff --git a/zmq/types/src/json_message_types.rs b/zmq/types/src/json_message_types.rs index 2699600f4..7549091a3 100644 --- a/zmq/types/src/json_message_types.rs +++ b/zmq/types/src/json_message_types.rs @@ -39,7 +39,7 @@ pub struct TxPoolAdd { /// ZMQ `json-minimal-txpool_add` subscriber messages contain an array of /// `TxPoolAddMin` JSON objects. See `TxPoolAdd` for information on which /// transactions are published to subscribers. -#[derive(Debug, Default, Clone, Serialize, Deserialize)] +#[derive(Copy, Debug, Default, Clone, Serialize, Deserialize)] pub struct TxPoolAddMin { /// transaction ID pub id: HexBytes<32>, @@ -128,7 +128,7 @@ pub struct ToKey { } /// Holds the block height of the coinbase transaction. -#[derive(Debug, Default, Clone, Serialize, Deserialize)] +#[derive(Copy, Debug, Default, Clone, Serialize, Deserialize)] pub struct MinerInput { /// namespace layer around the block height pub r#gen: Gen, @@ -136,7 +136,7 @@ pub struct MinerInput { /// Additional namespace layer around the block height in `ChainMain`; gen is /// another name for a coinbase transaction -#[derive(Debug, Default, Clone, Serialize, Deserialize)] +#[derive(Copy, Debug, Default, Clone, Serialize, Deserialize)] pub struct Gen { /// block height when the coinbase transaction was created pub height: u64, @@ -266,7 +266,7 @@ pub struct MinerTx { } /// Holds a transaction entry in the `MinerData` `tx_backlog` field. -#[derive(Debug, Default, Clone, Serialize, Deserialize)] +#[derive(Copy, Debug, Default, Clone, Serialize, Deserialize)] pub struct TxBacklog { /// transaction ID pub id: HexBytes<32>, diff --git a/zmq/types/src/lib.rs b/zmq/types/src/lib.rs index 3f9562b6f..8f40a928d 100644 --- a/zmq/types/src/lib.rs +++ b/zmq/types/src/lib.rs @@ -1 +1,14 @@ +#![forbid( + clippy::missing_assert_message, + clippy::missing_errors_doc, + clippy::missing_panics_doc, + clippy::should_panic_without_expect, + clippy::single_char_lifetime_names, + unsafe_code, + unused_results, + missing_copy_implementations, + missing_debug_implementations, + reason = "Crate-specific lints. There should be good reasoning when removing these." +)] + pub mod json_message_types;