Skip to content

Commit 3e6d4da

Browse files
authored
build: Do not rely on RUSTFLAGS for Clippy lint configuration (#499)
* chore: Stop using RUSTFLAGS to configure Clippy lints * chore: Remove now unneeded workaround for RUSTFLAGS * chore: Speed up pre-commit checks and reuse build cache more * fixup: Use consistent syntax in RUSTDOCFLAGS to deny warnings * Fix rust lint ordering in Cargo.toml
1 parent 4ab27c2 commit 3e6d4da

File tree

14 files changed

+124
-94
lines changed

14 files changed

+124
-94
lines changed

.cargo-husky/hooks/pre-commit

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22
#
3-
# Intended to be in sync with .github/workflows/hardhat-core-ci.yml's
4-
# test-edr-rs
3+
# Intended to be in sync with .github/workflows/edr-ci.yml's `test-edr-rs` job.
4+
55

66
if [ -z "${ALCHEMY_URL}" ] || [ -z "${INFURA_URL}" ]; then
77
echo WARNING: skipping remote tests because the ALCHEMY_URL and INFURA_URL environment variables are not defined. Local test results may differ from those in CI.
@@ -13,9 +13,11 @@ fi
1313
# Set -x here to avoid printing secrets
1414
set -xe
1515

16-
# Setting RUSTFLAGS env for clippy makes it not include custom rules
17-
RUSTFLAGS=-Dwarnings cargo check --workspace --all-targets ${ALL_FEATURES}
18-
cargo clippy --all --all-targets ${ALL_FEATURES} -- -D warnings
16+
# Do not modify or set RUSTFLAGS as this overrides any flags that may have been set
17+
# by the user and prevents from reusing the build cache.
18+
# See https://github.com/rust-lang/cargo/issues/8424#issuecomment-1734683743 and the thread.
19+
20+
cargo clippy --workspace --all-targets ${ALL_FEATURES} -- --deny warnings
1921
cargo +nightly fmt --all -- --check
2022
cargo test --doc --workspace ${ALL_FEATURES}
2123
cargo test --workspace --all-targets ${ALL_FEATURES}

.cargo/config.toml

-83
Original file line numberDiff line numberDiff line change
@@ -3,86 +3,3 @@ gen-execution-api = "run --bin tools -- gen-execution-api"
33
scenario = "run --release --bin tools -- scenario"
44
scenario-with-tracing = "run --release --features tracing --bin tools -- scenario"
55
replay-block = "run --release --bin tools -- replay-block"
6-
7-
[target.'cfg(all())']
8-
rustflags = [
9-
"-Wclippy::all",
10-
"-Wclippy::await_holding_lock",
11-
"-Wclippy::bool-to-int-with-if",
12-
"-Wclippy::cast_lossless",
13-
"-Wclippy::char_lit_as_u8",
14-
"-Wclippy::checked_conversions",
15-
"-Wclippy::dbg_macro",
16-
"-Wclippy::debug_assert_with_mut_call",
17-
"-Wclippy::default_trait_access",
18-
"-Wclippy::doc_markdown",
19-
"-Wclippy::empty_enum",
20-
"-Wclippy::enum_glob_use",
21-
"-Wclippy::exit",
22-
"-Wclippy::expl_impl_clone_on_copy",
23-
"-Wclippy::explicit_deref_methods",
24-
"-Wclippy::explicit_into_iter_loop",
25-
"-Wclippy::fallible_impl_from",
26-
"-Wclippy::filter_map_next",
27-
"-Wclippy::flat_map_option",
28-
"-Wclippy::float_cmp_const",
29-
"-Wclippy::fn_params_excessive_bools",
30-
"-Wclippy::from_iter_instead_of_collect",
31-
"-Wclippy::if-not-else",
32-
"-Wclippy::implicit_clone",
33-
"-Wclippy::imprecise_flops",
34-
"-Wclippy::inconsistent_struct_constructor",
35-
"-Wclippy::inefficient_to_string",
36-
"-Wclippy::invalid_upcast_comparisons",
37-
"-Wclippy::items-after-statements",
38-
"-Wclippy::large_digit_groups",
39-
"-Wclippy::large_stack_arrays",
40-
"-Wclippy::large_types_passed_by_value",
41-
"-Wclippy::let_unit_value",
42-
"-Wclippy::linkedlist",
43-
"-Wclippy::lossy_float_literal",
44-
"-Wclippy::macro_use_imports",
45-
"-Wclippy::manual-assert",
46-
"-Wclippy::manual_ok_or",
47-
"-Wclippy::map_err_ignore",
48-
"-Wclippy::map_flatten",
49-
"-Wclippy::map_unwrap_or",
50-
"-Wclippy::match_on_vec_items",
51-
"-Wclippy::match_same_arms",
52-
"-Wclippy::match_wild_err_arm",
53-
"-Wclippy::match_wildcard_for_single_variants",
54-
"-Wclippy::mem_forget",
55-
"-Wclippy::missing_enforced_import_renames",
56-
"-Wclippy::mut_mut",
57-
"-Wclippy::mutex_integer",
58-
"-Wclippy::needless_borrow",
59-
"-Wclippy::needless_continue",
60-
"-Wclippy::needless_for_each",
61-
"-Wclippy::option_option",
62-
"-Wclippy::path_buf_push_overwrite",
63-
"-Wclippy::ptr_as_ptr",
64-
"-Wclippy::rc_mutex",
65-
"-Wclippy::redundant_closure_for_method_calls",
66-
"-Wclippy::ref_option_ref",
67-
"-Wclippy::rest_pat_in_fully_bound_structs",
68-
"-Wclippy::same_functions_in_if_condition",
69-
"-Wclippy::semicolon_if_nothing_returned",
70-
"-Wclippy::single_match_else",
71-
"-Wclippy::string_add_assign",
72-
"-Wclippy::string_add",
73-
"-Wclippy::string_lit_as_bytes",
74-
"-Wclippy::string_to_string",
75-
"-Wclippy::todo",
76-
"-Wclippy::trait_duplication_in_bounds",
77-
"-Wclippy::unimplemented",
78-
"-Wclippy::uninlined_format_args",
79-
"-Wclippy::unnested_or_patterns",
80-
"-Wclippy::unused_self",
81-
"-Wclippy::useless_transmute",
82-
"-Wclippy::verbose_file_reads",
83-
"-Wclippy::wildcard-imports",
84-
"-Wclippy::zero_sized_map_values",
85-
"-Wfuture_incompatible",
86-
"-Wnonstandard_style",
87-
"-Wrust_2018_idioms",
88-
]

.github/workflows/edr-ci.yml

+4-6
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ on:
2121
- "crates/**"
2222
workflow_dispatch:
2323

24+
env:
25+
RUSTFLAGS: -Dwarnings
26+
RUSTDOCFLAGS: -Dwarnings
27+
2428
concurrency:
2529
group: ${{github.workflow}}-${{github.ref}}
2630
cancel-in-progress: true
@@ -29,10 +33,6 @@ jobs:
2933
check-edr:
3034
name: Check EDR
3135
runs-on: ubuntu-latest
32-
# Setting RUSTFLAGS env for clippy makes it not include custom rules
33-
env:
34-
RUSTFLAGS: -Dwarnings
35-
RUSTDOCFLAGS: "-D warnings"
3636
steps:
3737
- uses: actions/checkout@v3
3838

@@ -170,8 +170,6 @@ jobs:
170170

171171
- name: Cargo doc
172172
uses: actions-rs/cargo@v1
173-
env:
174-
RUSTDOCFLAGS: "-D warnings"
175173
with:
176174
command: doc
177175
args: --workspace --no-deps --all-features

Cargo.toml

+83
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,86 @@ rpath = true
1212

1313
[profile.test]
1414
opt-level = 2
15+
16+
[workspace.lints.rust]
17+
future_incompatible = "warn"
18+
nonstandard_style = "warn"
19+
rust_2018_idioms = "warn"
20+
21+
[workspace.lints.clippy]
22+
all = "warn"
23+
await_holding_lock = "warn"
24+
bool-to-int-with-if = "warn"
25+
cast_lossless = "warn"
26+
char_lit_as_u8 = "warn"
27+
checked_conversions = "warn"
28+
dbg_macro = "warn"
29+
debug_assert_with_mut_call = "warn"
30+
default_trait_access = "warn"
31+
doc_markdown = "warn"
32+
empty_enum = "warn"
33+
enum_glob_use = "warn"
34+
exit = "warn"
35+
expl_impl_clone_on_copy = "warn"
36+
explicit_deref_methods = "warn"
37+
explicit_into_iter_loop = "warn"
38+
fallible_impl_from = "warn"
39+
filter_map_next = "warn"
40+
flat_map_option = "warn"
41+
float_cmp_const = "warn"
42+
fn_params_excessive_bools = "warn"
43+
from_iter_instead_of_collect = "warn"
44+
if-not-else = "warn"
45+
implicit_clone = "warn"
46+
imprecise_flops = "warn"
47+
inconsistent_struct_constructor = "warn"
48+
inefficient_to_string = "warn"
49+
invalid_upcast_comparisons = "warn"
50+
items-after-statements = "warn"
51+
large_digit_groups = "warn"
52+
large_stack_arrays = "warn"
53+
large_types_passed_by_value = "warn"
54+
let_unit_value = "warn"
55+
linkedlist = "warn"
56+
lossy_float_literal = "warn"
57+
macro_use_imports = "warn"
58+
manual-assert = "warn"
59+
manual_ok_or = "warn"
60+
map_err_ignore = "warn"
61+
map_flatten = "warn"
62+
map_unwrap_or = "warn"
63+
match_on_vec_items = "warn"
64+
match_same_arms = "warn"
65+
match_wild_err_arm = "warn"
66+
match_wildcard_for_single_variants = "warn"
67+
mem_forget = "warn"
68+
missing_enforced_import_renames = "warn"
69+
mut_mut = "warn"
70+
mutex_integer = "warn"
71+
needless_borrow = "warn"
72+
needless_continue = "warn"
73+
needless_for_each = "warn"
74+
option_option = "warn"
75+
path_buf_push_overwrite = "warn"
76+
ptr_as_ptr = "warn"
77+
rc_mutex = "warn"
78+
redundant_closure_for_method_calls = "warn"
79+
ref_option_ref = "warn"
80+
rest_pat_in_fully_bound_structs = "warn"
81+
same_functions_in_if_condition = "warn"
82+
semicolon_if_nothing_returned = "warn"
83+
single_match_else = "warn"
84+
string_add_assign = "warn"
85+
string_add = "warn"
86+
string_lit_as_bytes = "warn"
87+
string_to_string = "warn"
88+
todo = "warn"
89+
trait_duplication_in_bounds = "warn"
90+
unimplemented = "warn"
91+
uninlined_format_args = "warn"
92+
unnested_or_patterns = "warn"
93+
unused_self = "warn"
94+
useless_transmute = "warn"
95+
verbose_file_reads = "warn"
96+
wildcard-imports = "warn"
97+
zero_sized_map_values = "warn"

crates/edr_defaults/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ version = "0.3.5"
44
edition = "2021"
55

66
[dependencies]
7+
8+
[lints]
9+
workspace = true

crates/edr_eth/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@ serde = ["dep:serde", "c-kzg/serde", "revm-primitives/serde"]
4242
std = ["hash256-std-hasher/std", "hash-db/std", "hex/std", "itertools/use_std", "k256/std", "k256/precomputed-tables", "revm-primitives/std", "serde?/std", "sha2/std", "sha3/std", "triehash/std"]
4343
test-remote = []
4444
tracing = ["dep:tracing"]
45+
46+
[lints]
47+
workspace = true

crates/edr_evm/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,6 @@ tempfile = "3.7.1"
4040
test-remote = []
4141
test-utils = []
4242
tracing = ["dep:tracing", "edr_eth/tracing"]
43+
44+
[lints]
45+
workspace = true

crates/edr_napi/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,6 @@ scenarios = ["rand"]
5353

5454
[profile.release]
5555
lto = true
56+
57+
[lints]
58+
workspace = true

crates/edr_provider/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,6 @@ toml = { version = "0.5.9", default-features = false }
4343
[features]
4444
test-utils = ["anyhow"]
4545
tracing = ["dep:tracing", "edr_eth/tracing", "edr_evm/tracing"]
46+
47+
[lints]
48+
workspace = true

crates/edr_rpc_client/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,6 @@ walkdir = { version = "2.3.3", default-features = false }
3333
[features]
3434
test-remote = []
3535
tracing = ["dep:tracing", "dep:reqwest-tracing"]
36+
37+
[lints]
38+
workspace = true

crates/edr_rpc_eth/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@ walkdir = { version = "2.3.3", default-features = false }
2525
[features]
2626
test-remote = []
2727
tracing = ["dep:tracing", "edr_rpc_client/tracing"]
28+
29+
[lints]
30+
workspace = true

crates/edr_solidity/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ edition = "2021"
66
[dependencies]
77
edr_eth = { version = "0.3.5", path = "../edr_eth" }
88
edr_evm = { version = "0.3.5", path = "../edr_evm" }
9+
10+
[lints]
11+
workspace = true

crates/edr_test_utils/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ edition = "2021"
66
[dependencies]
77
serde = { version = "1.0.147", default-features = false, features = ["derive"] }
88
serde_json = { version = "1.0.89" }
9+
10+
[lints]
11+
workspace = true

crates/tools/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,6 @@ walkdir = { version = "2.4.0", features = [] }
2929

3030
[features]
3131
tracing = ["dep:tracing", "dep:tracing-flame", "dep:tracing-subscriber", "edr_eth/tracing", "edr_evm/tracing", "edr_provider/tracing"]
32+
33+
[lints]
34+
workspace = true

0 commit comments

Comments
 (0)