alloy-rs / core

High-performance, well-tested & documented core libraries for Ethereum, in Rust
https://alloy.rs
Apache License 2.0
792 stars 155 forks source link

[Bug] `sol!` should emit `#[allow(clippy::pub_underscore_fields)]` #769

Closed benluelo closed 1 month ago

benluelo commented 1 month ago

Component

sol! macro

What version of Alloy are you on?

alloy v0.4.2

Operating System

None

Describe the bug

since sol! doesn't change the case of fields, it should allow clippy::pub_underscore_fields (and perhaps allow some other lints as well?)

sol! {
    function someFunction(
        bytes calldata _ignored
    );
}
warning: field marked as public but also inferred as unused because it's prefixed with `_`
  --> src/main.rs:53:1
   |
53 | / alloy::sol! {
54 | |     function someFunction(
55 | |         bytes calldata _ignored
56 | |     );
57 | | }
   | |_^
   |
   = help: consider removing the underscore, or making the field private
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#pub_underscore_fields
note: the lint level is defined here
  --> src/main.rs:1:9
   |
1  | #![warn(clippy::pedantic)]
   |         ^^^^^^^^^^^^^^^^
   = note: `#[warn(clippy::pub_underscore_fields)]` implied by `#[warn(clippy::pedantic)]`
   = note: this warning originates in the macro `$crate::sol_types::sol` which comes from the expansion of the macro `alloy::sol` (in Nightly builds, run with -Z macro-backtrace for more info)

and yes, this can be fixed by putting #[allow(clippy::pub_underscore_fields)] everywhere where this is an issue, but that's quite annoying when there are large contracts being copied into the sol! macro