fix: ignore explicitly typed variables in misleading_variable_name - #2016
Conversation
|
Thanks, @VrtxOmega. Please forgive me for pasting the below Claude review, but I think I agree with it. Could you please address it? I think the change should be straightforward, so please fold it into the current commit. Also, please sign the CLA. 1. The doc comment and generated README are now inaccuratesrc/lib.rs:24 still reads:
There are now four. The new condition — the variable has no explicit type annotation — is the one users are most likely to need, since it is the documented way to silence a false positive. cargo-dylint/tests/ci.rs:343 regenerates every example's Suggested wording: /// Checks for variables satisfying the following four conditions:
///
/// - The variable is declared without an explicit type.
/// - The variable is initialized with the result of a function call.
/// - The variable's name matches the name of a type defined within the module in which the
/// function is defined.
/// - The variable's type is not the matched type.
|
Signed-off-by: Rage Lopez <VrtxOmega@pm.me>
f62e467 to
86eddda
Compare
|
Thanks — addressed in
The amended CI matrix is running now. |
|
Beautiful. Thank you very much, @VrtxOmega! |
Fixes #1903.
Summary
misleading_variable_namefor let bindings with an explicit type annotationVerification
I locally verified the complete amended diff:
Stringbinding produced a seventh warning and failed the UI fixture. After the fix, the standalone UI test passes while the six existing warning expectations remain unchanged.PATH="$PWD/target/debug:$PATH" CARGO_TARGET_DIR="$PWD/target" cargo +nightly-2026-05-28 test --manifest-path examples/restriction/misleading_variable_name/Cargo.toml— 1 UI test passedcargo test -p cargo-dylint --test ci format_example_readmes— 1 README consistency test passedcargo +nightly-2026-05-28 fmt --all --checkgit diff --checkAssistance disclosure
OpenAI Codex helped inspect the maintainer feedback and execute the local checks. I reviewed the code change, generated README, diff, and verification output before pushing.