chore(lint): allow restriction/pedantic lints in test cfg only#292
Merged
sachiniyer merged 2 commits intomainfrom May 9, 2026
Merged
chore(lint): allow restriction/pedantic lints in test cfg only#292sachiniyer merged 2 commits intomainfrom
sachiniyer merged 2 commits intomainfrom
Conversation
All clippy violations from these lints lived inside `#[cfg(test)]` modules (and the `tests/` integration crate); none were in production code. Scope the restriction lints (`unwrap_used`, `expect_used`, `panic`, `as_conversions`, `cast_sign_loss`, `cast_possible_wrap`) and a few pedantic ones that only fired on test code (`needless_collect`, `absolute_paths`, `if_then_some_else_none`, `doc_markdown`, `semicolon_outside_block`, plus the integration-test-only `redundant_closure_for_method_calls` and `tests_outside_test_module`) to test cfg via `#![cfg_attr(test, allow(...))]`. Production code is still held to the same bar. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The binary crate has no tests, so the test-cfg allow block had no effect. lib.rs already covers all `#[cfg(test)] mod tests` in src/ since they compile as part of the lib crate; tests/integration.rs keeps its own block because it's a separate crate. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cargo clippy --all-targetswas failing with 238 errors, all in test codeunwrap_used,expect_used,panic,as_conversions,cast_sign_loss,cast_possible_wrap) and a handful of pedantic lints that only fire on test code tocfg(test)via#![cfg_attr(test, allow(...))]insrc/lib.rs,src/main.rs, andtests/integration.rsWhy
unwrap/expect/panicand similar lints are idiomatic in tests, where panicking on bad assumptions is the desired failure mode. Tests are also a common place for one-off casts (as), pedantic style nits (needless_collect,redundant_closure_for_method_calls), and integration-test layout (tests_outside_test_module). Holding tests to the same bar as production created 200+ false-positive errors with no production benefit.The reason string on each
allowblock satisfiesclippy::allow_attributes_without_reason, which is denied repo-wide.Test plan
cargo clippy --all-targets— 0 errors, 0 warningscargo checkcargo test --lib— 290 tests pass🤖 Generated with Claude Code