Skip to content

Commit 759b7d6

Browse files
0xMushowgrandizzy
andauthored
Replace #[allow()] with #[expect()] (#10131)
* Replace `#[allow()]` with `#[expect()]` * Remove unfulfilled `#[expect()]` and revert one that can't be changed * Revert to allow[()] on large enums * Keep `#[expect()]`` on large enums * Keep `#[expect()]` on large enums * Fix all CI * Fix all CI * Fix all CI * Replace #[expect()] with #[allow()] * Fix CI failure --------- Co-authored-by: grandizzy <[email protected]>
1 parent 198f281 commit 759b7d6

File tree

60 files changed

+68
-89
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+68
-89
lines changed

crates/anvil/core/src/eth/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub struct Params<T: Default> {
3636
/// Represents ethereum JSON-RPC API
3737
#[derive(Clone, Debug, serde::Deserialize)]
3838
#[serde(tag = "method", content = "params")]
39-
#[allow(clippy::large_enum_variant)]
39+
#[expect(clippy::large_enum_variant)]
4040
pub enum EthRequest {
4141
#[serde(rename = "web3_clientVersion", with = "empty_params")]
4242
Web3ClientVersion(()),

crates/anvil/core/src/eth/serde_helpers.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! custom serde helper functions
22
3-
#[allow(dead_code)]
43
pub mod sequence {
54
use serde::{
65
de::DeserializeOwned, ser::SerializeSeq, Deserialize, Deserializer, Serialize, Serializer,

crates/anvil/core/src/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ pub struct ReorgOptions {
3636
}
3737

3838
#[derive(Debug, Clone, Deserialize)]
39-
#[allow(clippy::large_enum_variant)]
4039
#[serde(untagged)]
40+
#[expect(clippy::large_enum_variant)]
4141
pub enum TransactionData {
4242
JSON(TransactionRequest),
4343
Raw(Bytes),

crates/anvil/src/eth/api.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ pub struct EthApi {
133133

134134
impl EthApi {
135135
/// Creates a new instance
136-
#[allow(clippy::too_many_arguments)]
136+
#[expect(clippy::too_many_arguments)]
137137
pub fn new(
138138
pool: Arc<Pool>,
139139
backend: Arc<backend::mem::Backend>,
@@ -2803,7 +2803,7 @@ impl EthApi {
28032803
}
28042804

28052805
/// Returns the first signer that can sign for the given address
2806-
#[allow(clippy::borrowed_box)]
2806+
#[expect(clippy::borrowed_box)]
28072807
pub fn get_signer(&self, address: Address) -> Option<&Box<dyn Signer>> {
28082808
self.signers.iter().find(|signer| signer.is_signer_for(address))
28092809
}

crates/anvil/src/eth/backend/mem/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ pub struct Backend {
213213

214214
impl Backend {
215215
/// Initialises the balance of the given accounts
216-
#[allow(clippy::too_many_arguments)]
216+
#[expect(clippy::too_many_arguments)]
217217
pub async fn with_genesis(
218218
db: Arc<AsyncRwLock<Box<dyn Db>>>,
219219
env: Arc<RwLock<EnvWithHandlerCfg>>,
@@ -1022,7 +1022,7 @@ impl Backend {
10221022
}
10231023

10241024
/// Creates an EVM instance with optionally injected precompiles.
1025-
#[allow(clippy::type_complexity)]
1025+
#[expect(clippy::type_complexity)]
10261026
fn new_evm_with_inspector_ref<'i, 'db>(
10271027
&self,
10281028
db: &'db dyn DatabaseRef<Error = DatabaseError>,
@@ -2876,7 +2876,6 @@ impl TransactionValidator for Backend {
28762876
}
28772877

28782878
/// Creates a `AnyRpcTransaction` as it's expected for the `eth` RPC api from storage data
2879-
#[allow(clippy::too_many_arguments)]
28802879
pub fn transaction_build(
28812880
tx_hash: Option<B256>,
28822881
eth_transaction: MaybeImpersonatedTransaction,

crates/anvil/src/eth/backend/mem/storage.rs

-1
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,6 @@ impl BlockchainStorage {
350350
self.best_number = U64::from(block_number);
351351
}
352352

353-
#[allow(unused)]
354353
pub fn empty() -> Self {
355354
Self {
356355
blocks: Default::default(),

crates/anvil/src/service.rs

-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ impl Future for NodeService {
9494
let filters = pin.filters.clone();
9595

9696
// evict filters that timed out
97-
#[allow(clippy::redundant_async_block)]
9897
tokio::task::spawn(async move { filters.evict().await });
9998
}
10099

crates/anvil/tests/it/eip4844.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ async fn can_check_blob_fields_on_genesis() {
205205
assert_eq!(block.header.excess_blob_gas, Some(0));
206206
}
207207

208-
#[allow(clippy::disallowed_macros)]
208+
#[expect(clippy::disallowed_macros)]
209209
#[tokio::test(flavor = "multi_thread")]
210210
async fn can_correctly_estimate_blob_gas_with_recommended_fillers() {
211211
let node_config = NodeConfig::test().with_hardfork(Some(EthereumHardfork::Cancun.into()));
@@ -248,7 +248,7 @@ async fn can_correctly_estimate_blob_gas_with_recommended_fillers() {
248248
);
249249
}
250250

251-
#[allow(clippy::disallowed_macros)]
251+
#[expect(clippy::disallowed_macros)]
252252
#[tokio::test(flavor = "multi_thread")]
253253
async fn can_correctly_estimate_blob_gas_with_recommended_fillers_with_signer() {
254254
let node_config = NodeConfig::test().with_hardfork(Some(EthereumHardfork::Cancun.into()));

crates/anvil/tests/it/fork.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ const DEAD_BALANCE_AT_BLOCK_NUMBER: u128 = 12_556_069_338_441_120_059_867u128;
2828
const BLOCK_TIMESTAMP: u64 = 1_650_274_250u64;
2929

3030
/// Represents an anvil fork of an anvil node
31-
#[allow(unused)]
31+
#[expect(unused)]
3232
pub struct LocalFork {
3333
origin_api: EthApi,
3434
origin_handle: NodeHandle,
3535
fork_api: EthApi,
3636
fork_handle: NodeHandle,
3737
}
3838

39-
#[allow(dead_code)]
39+
#[expect(dead_code)]
4040
impl LocalFork {
4141
/// Spawns two nodes with the test config
4242
pub async fn new() -> Self {

crates/anvil/tests/it/main.rs

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ mod txpool;
2222
pub mod utils;
2323
mod wsapi;
2424

25-
#[allow(unused)]
2625
pub(crate) fn init_tracing() {
2726
let _ = tracing_subscriber::FmtSubscriber::builder()
2827
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())

crates/anvil/tests/it/pubsub.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ async fn test_subscriptions() {
247247
assert_eq!(blocks, vec![1, 2, 3])
248248
}
249249

250-
#[allow(clippy::disallowed_macros)]
250+
#[expect(clippy::disallowed_macros)]
251251
#[tokio::test(flavor = "multi_thread")]
252252
async fn test_sub_new_heads_fast() {
253253
let (api, handle) = spawn(NodeConfig::test()).await;

crates/cast/src/cmd/create2.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ pub struct Create2Args {
8989
no_random: bool,
9090
}
9191

92-
#[allow(dead_code)]
9392
pub struct Create2Output {
9493
pub address: Address,
9594
pub salt: B256,
@@ -227,7 +226,7 @@ impl Create2Args {
227226
}
228227

229228
// Calculate the `CREATE2` address.
230-
#[allow(clippy::needless_borrows_for_generic_args)]
229+
#[expect(clippy::needless_borrows_for_generic_args)]
231230
let addr = deployer.create2(&salt.0, &init_code_hash);
232231

233232
// Check if the regex matches the calculated address' checksum.

crates/cast/src/cmd/send.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ pub enum SendTxSubcommands {
8585
}
8686

8787
impl SendTxArgs {
88-
#[allow(unknown_lints, dependency_on_unit_never_type_fallback)]
88+
#[expect(dependency_on_unit_never_type_fallback)]
8989
pub async fn run(self) -> eyre::Result<()> {
9090
let Self {
9191
eth,

crates/cast/src/rlp_converter.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ mod test {
109109
}
110110

111111
#[test]
112-
#[allow(clippy::disallowed_macros)]
112+
#[expect(clippy::disallowed_macros)]
113113
fn encode_decode_test() -> alloy_rlp::Result<()> {
114114
let parameters = vec![
115115
(1, b"\xc0".to_vec(), Item::Array(vec![])),
@@ -151,7 +151,7 @@ mod test {
151151
}
152152

153153
#[test]
154-
#[allow(clippy::disallowed_macros)]
154+
#[expect(clippy::disallowed_macros)]
155155
fn deserialize_from_str_test_hex() -> JsonResult<()> {
156156
let parameters = vec![
157157
(1, "[\"\"]", Item::Array(vec![Item::Data(vec![])])),

crates/cast/src/tx.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use serde_json::value::RawValue;
2525
use std::fmt::Write;
2626

2727
/// Different sender kinds used by [`CastTxBuilder`].
28-
#[allow(clippy::large_enum_variant)]
28+
#[expect(clippy::large_enum_variant)]
2929
pub enum SenderKind<'a> {
3030
/// An address without signer. Used for read-only calls and transactions sent through unlocked
3131
/// accounts.

crates/cheatcodes/spec/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl Cheatcodes<'static> {
107107
}
108108

109109
#[cfg(test)]
110-
#[allow(clippy::disallowed_macros)]
110+
#[expect(clippy::disallowed_macros)]
111111
mod tests {
112112
use super::*;
113113
use std::{fs, path::Path};

crates/cheatcodes/src/script.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ pub struct Wallets {
196196
}
197197

198198
impl Wallets {
199-
#[allow(missing_docs)]
199+
#[expect(missing_docs)]
200200
pub fn new(multi_wallet: MultiWallet, provided_sender: Option<Address>) -> Self {
201201
Self { inner: Arc::new(Mutex::new(WalletsInner { multi_wallet, provided_sender })) }
202202
}

crates/cheatcodes/src/test/expect.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ impl RevertParameters for ExpectedRevert {
672672
/// `vm.expectCall(address(0xc4f3), abi.encodeWithSelector(0xd34db33f))` will expect the call to
673673
/// address(0xc4f3) and selector `0xd34db33f` to be made at least once. If the amount of calls is
674674
/// 0, the test will fail. If the call is made more than once, the test will pass.
675-
#[allow(clippy::too_many_arguments)] // It is what it is
675+
#[expect(clippy::too_many_arguments)] // It is what it is
676676
fn expect_call(
677677
state: &mut Cheatcodes,
678678
target: &Address,
@@ -1010,7 +1010,7 @@ fn checks_topics_and_data(checks: [bool; 5], expected: &RawLog, log: &RawLog) ->
10101010

10111011
fn expect_safe_memory(state: &mut Cheatcodes, start: u64, end: u64, depth: u64) -> Result {
10121012
ensure!(start < end, "memory range start ({start}) is greater than end ({end})");
1013-
#[allow(clippy::single_range_in_vec_init)] // Wanted behaviour
1013+
#[expect(clippy::single_range_in_vec_init)] // Wanted behaviour
10141014
let offsets = state.allowed_mem_writes.entry(depth).or_insert_with(|| vec![0..0x60]);
10151015
offsets.push(start..end);
10161016
Ok(Default::default())

crates/chisel/src/executor.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ impl Type {
801801
}
802802

803803
// Type members, like array, bytes etc
804-
#[allow(clippy::single_match)]
804+
#[expect(clippy::single_match)]
805805
match &self {
806806
Self::Access(inner, access) => {
807807
if let Some(ty) = inner.as_ref().clone().try_as_ethabi(None) {
@@ -1286,7 +1286,6 @@ fn func_members(func: &pt::FunctionDefinition, custom_type: &[String]) -> Option
12861286
/// Whether execution should continue after inspecting this expression
12871287
#[inline]
12881288
fn should_continue(expr: &pt::Expression) -> bool {
1289-
#[allow(clippy::match_like_matches_macro)]
12901289
match expr {
12911290
// assignments
12921291
pt::Expression::PreDecrement(_, _) | // --<inner>

crates/chisel/src/solidity_helper.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ impl Hinter for SolidityHelper {
241241

242242
impl Helper for SolidityHelper {}
243243

244-
#[allow(non_upper_case_globals)]
244+
#[expect(non_upper_case_globals)]
245245
#[deny(unreachable_patterns)]
246246
fn token_style(token: &Token) -> Style {
247247
use solar_parse::{

crates/cli/src/utils/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ impl<'a> Git<'a> {
376376
self.cmd().arg("init").exec().map(drop)
377377
}
378378

379-
#[allow(clippy::should_implement_trait)] // this is not std::ops::Add clippy
379+
#[expect(clippy::should_implement_trait)] // this is not std::ops::Add clippy
380380
pub fn add<I, S>(self, paths: I) -> Result<()>
381381
where
382382
I: IntoIterator<Item = S>,

crates/common/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::{env, error::Error};
33
use chrono::DateTime;
44
use vergen::EmitBuilder;
55

6-
#[allow(clippy::disallowed_macros)]
6+
#[expect(clippy::disallowed_macros)]
77
fn main() -> Result<(), Box<dyn Error>> {
88
// Re-run the build script if the build script itself changes or if the
99
// environment variables change.

crates/common/fmt/src/console.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ mod tests {
453453
p_3: U256,
454454
}
455455

456-
#[allow(unused)]
456+
#[expect(unused)]
457457
#[derive(Clone, Debug, ConsoleFmt)]
458458
enum Logs {
459459
Log1(Log1),

crates/common/fmt/src/ui.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ impl<T: UIfmt> UIfmt for WithOtherFields<T> {
781781
/// Various numerical ethereum types used for pretty printing
782782
#[derive(Clone, Debug, Deserialize)]
783783
#[serde(untagged)]
784-
#[allow(missing_docs)]
784+
#[expect(missing_docs)]
785785
pub enum EthValue {
786786
U64(U64),
787787
U256(U256),

crates/common/src/compile.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ pub fn etherscan_project(
548548

549549
/// Configures the reporter and runs the given closure.
550550
pub fn with_compilation_reporter<O>(quiet: bool, f: impl FnOnce() -> O) -> O {
551-
#[allow(clippy::collapsible_else_if)]
551+
#[expect(clippy::collapsible_else_if)]
552552
let reporter = if quiet || shell::is_json() {
553553
Report::new(NoReporter::default())
554554
} else {

crates/common/src/contracts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const CALL_PROTECTION_BYTECODE_PREFIX: [u8; 21] =
2828
hex!("730000000000000000000000000000000000000000");
2929

3030
/// Subset of [CompactBytecode] excluding sourcemaps.
31-
#[allow(missing_docs)]
31+
#[expect(missing_docs)]
3232
#[derive(Debug, Clone)]
3333
pub struct BytecodeData {
3434
pub object: Option<BytecodeObject>,

crates/common/src/errors/fs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ use std::{
33
path::{Path, PathBuf},
44
};
55

6-
#[allow(unused_imports)]
6+
#[expect(unused_imports)]
77
use std::fs::{self, File};
88

99
/// Various error variants for `fs` operations that serve as an addition to the io::Error which
1010
/// does not provide any information about the path.
1111
#[derive(Debug, thiserror::Error)]
12-
#[allow(missing_docs)]
12+
#[expect(missing_docs)]
1313
pub enum FsPathError {
1414
/// Provides additional path context for [`fs::write`].
1515
#[error("failed to write to {path:?}: {source}")]

crates/common/src/evm.rs

-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,6 @@ impl EvmArgs {
280280

281281
/// We have to serialize chain IDs and not names because when extracting an EVM `Env`, it expects
282282
/// `chain_id` to be `u64`.
283-
#[allow(clippy::trivially_copy_pass_by_ref)]
284283
fn id<S: serde::Serializer>(chain: &Option<Chain>, s: S) -> Result<S::Ok, S::Error> {
285284
if let Some(chain) = chain {
286285
s.serialize_u64(chain.id())

crates/common/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
66
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
77

8-
#[allow(unused_extern_crates)] // Used by `ConsoleFmt`.
8+
#[expect(unused_extern_crates)] // Used by `ConsoleFmt`.
99
extern crate self as foundry_common;
1010

1111
#[macro_use]

crates/common/src/term.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,15 @@ impl TermSettings {
4545
}
4646
}
4747

48-
#[allow(missing_docs)]
48+
#[expect(missing_docs)]
4949
pub struct Spinner {
5050
indicator: &'static [&'static str],
5151
no_progress: bool,
5252
message: String,
5353
idx: usize,
5454
}
5555

56-
#[allow(unused)]
57-
#[allow(missing_docs)]
56+
#[expect(missing_docs)]
5857
impl Spinner {
5958
pub fn new(msg: impl Into<String>) -> Self {
6059
Self::with_indicator(SPINNERS[0], msg)

crates/config/src/fix.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl std::error::Error for InsertProfileError {}
6969
impl TomlFile {
7070
/// Insert a name as `[profile.name]`. Creating the `[profile]` table where necessary and
7171
/// throwing an error if there exists a conflict
72-
#[allow(clippy::result_large_err)]
72+
#[expect(clippy::result_large_err)]
7373
fn insert_profile(
7474
&mut self,
7575
profile_str: &str,

crates/config/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -4578,7 +4578,7 @@ mod tests {
45784578
}
45794579

45804580
// a test to print the config, mainly used to update the example config in the README
4581-
#[allow(clippy::disallowed_macros)]
4581+
#[expect(clippy::disallowed_macros)]
45824582
#[test]
45834583
#[ignore]
45844584
fn print_config() {
@@ -4604,7 +4604,6 @@ mod tests {
46044604
}
46054605

46064606
#[test]
4607-
#[allow(unknown_lints, non_local_definitions)]
46084607
fn can_use_impl_figment_macro() {
46094608
#[derive(Default, Serialize)]
46104609
struct MyArgs {

crates/debugger/src/tui/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl<'a> TUI<'a> {
100100
}
101101

102102
// TODO: Update once on 1.82
103-
#[allow(deprecated)]
103+
#[expect(deprecated)]
104104
type PanicHandler = Box<dyn Fn(&std::panic::PanicInfo<'_>) + 'static + Sync + Send>;
105105

106106
/// Handles terminal state.

0 commit comments

Comments
 (0)