Skip to content

Commit 259ceea

Browse files
committed
fix(ci): migrate lints from .cargo/config.toml to [workspace.lints]
The setup-rust-toolchain action sets RUSTFLAGS="-D warnings" by default, which overrides .cargo/config.toml rustflags entirely. This silently dropped all custom lints (clippy::print_stdout, unsafe_code, missing_docs, etc.) since #9883. Move lint configuration to [workspace.lints] in Cargo.toml, which is immune to RUSTFLAGS overrides. Closes #10378
1 parent 87f2996 commit 259ceea

File tree

2 files changed

+47
-80
lines changed

2 files changed

+47
-80
lines changed

.cargo/config.toml

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,5 @@
11
# Zebra cargo configuration
22

3-
# Flags that apply to all Zebra crates and configurations
4-
[target.'cfg(all())']
5-
rustflags = [
6-
# Zebra standard lints for Rust 1.65+
7-
8-
# High-risk code
9-
"-Dunsafe_code",
10-
"-Dnon_ascii_idents",
11-
12-
# Potential bugs
13-
#
14-
# If we deny these lints, we could be excluded from Crater builds:
15-
# https://www.reddit.com/r/rust/comments/f5xpib/psa_denywarnings_is_actively_harmful/
16-
17-
# Compatibility
18-
"-Wrust_2021_compatibility",
19-
"-Wnonstandard_style",
20-
"-Wfuture_incompatible",
21-
22-
# Async code
23-
"-Wclippy::await_holding_lock",
24-
"-Wclippy::await_holding_refcell_ref",
25-
26-
# Pointers
27-
"-Wclippy::cast_ptr_alignment",
28-
"-Wclippy::fn_to_numeric_cast_any",
29-
30-
# Integers
31-
"-Wclippy::checked_conversions",
32-
"-Wclippy::implicit_saturating_sub",
33-
"-Wclippy::invalid_upcast_comparisons",
34-
"-Wclippy::range_minus_one",
35-
"-Wclippy::range_plus_one",
36-
"-Wclippy::unnecessary_cast",
37-
38-
# Incomplete code
39-
"-Wclippy::dbg_macro",
40-
"-Wclippy::todo",
41-
42-
# Manual debugging output.
43-
# Use tracing::trace!() or tracing::debug!() instead.
44-
"-Wclippy::print_stdout",
45-
"-Wclippy::print_stderr",
46-
"-Wclippy::dbg_macro",
47-
48-
# Code styles we want to accept
49-
"-Aclippy::try_err",
50-
51-
# Panics
52-
"-Wclippy::fallible_impl_from",
53-
"-Wclippy::unwrap_in_result",
54-
55-
# Documentation
56-
"-Wmissing_docs",
57-
58-
# TODOs:
59-
# Fix this lint eventually.
60-
"-Aclippy::result_large_err",
61-
62-
# `cargo fix` might help do these fixes,
63-
# or add a config.toml to sub-directories which should allow these lints,
64-
# or try allowing the lint in the specific module (lib.rs doesn't seem to work in some cases)
65-
#
66-
# lint configs that don't work:
67-
# - allowing these lints in lib.rs (command-line warn overrides allow in lib.rs?)
68-
# - adding a [target.'cfg(not(test))'] rustflags config (it runs on test code anyway)
69-
70-
# fix code that triggers these lints,
71-
# or disable the lint for that code (or for all test code)
72-
#
73-
#"-Wclippy::cast_lossless", # 30 non-test warnings, a few test warnings
74-
#"-Wclippy::cast_possible_truncation", # 40 non-test warnings, 20 test warnings
75-
#"-Wclippy::cast_possible_wrap", # 13 test warnings (fixed outside tests)
76-
#"-Wclippy::cast_precision_loss", # 25 non-test warnings, 10 test warnings
77-
#"-Wclippy::cast_sign_loss", # 6 non-test warnings, 15 test warnings
78-
79-
# fix hidden lifetime parameters
80-
#"-Wrust_2018_idioms",
81-
]
82-
833
[build]
844
rustdocflags = [
855
# The -A and -W settings must be the same as the `RUSTDOCFLAGS` in:

Cargo.toml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,3 +314,50 @@ unexpected_cfgs = { level = "warn", check-cfg = [
314314
'cfg(tokio_unstable)', # Used by tokio-console
315315
'cfg(zcash_unstable, values("zfuture", "nu6.1", "nu7"))' # Used in Zebra and librustzcash
316316
] }
317+
318+
# High-risk code
319+
unsafe_code = "deny"
320+
non_ascii_idents = "deny"
321+
322+
# Compatibility
323+
rust_2021_compatibility = "warn"
324+
nonstandard_style = "warn"
325+
future_incompatible = "warn"
326+
327+
# Documentation
328+
missing_docs = "warn"
329+
330+
[workspace.lints.clippy]
331+
# Async code
332+
await_holding_lock = "warn"
333+
await_holding_refcell_ref = "warn"
334+
335+
# Pointers
336+
cast_ptr_alignment = "warn"
337+
fn_to_numeric_cast_any = "warn"
338+
339+
# Integers
340+
checked_conversions = "warn"
341+
implicit_saturating_sub = "warn"
342+
invalid_upcast_comparisons = "warn"
343+
range_minus_one = "warn"
344+
range_plus_one = "warn"
345+
unnecessary_cast = "warn"
346+
347+
# Incomplete code
348+
dbg_macro = "warn"
349+
todo = "warn"
350+
351+
# Manual debugging output — use tracing::trace!() or tracing::debug!() instead
352+
print_stdout = "warn"
353+
print_stderr = "warn"
354+
355+
# Code styles we want to accept
356+
try_err = "allow"
357+
358+
# Panics
359+
fallible_impl_from = "warn"
360+
unwrap_in_result = "warn"
361+
362+
# TODOs: fix this lint eventually
363+
result_large_err = "allow"

0 commit comments

Comments
 (0)