-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
clippy::redundant_locals
is not a correctness lint
#13747
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't particularly agree. Where does it say it in the documentation? For:
and are likely to be unintended
This kind of wording is normal for correctness
lints, see for example
clippy::absurd_extreme_comparisons
: "Expressions like max < x are probably mistakes.".
clippy::match_str_case_mismatch
: "The arm is unreachable, which is likely a mistake".
This should have stronger wording tho. Mostly mentioning that it could be an error from refactoring.
they may affect
rustc
's stack allocation.
Is specifically related to cases like rust-lang/rust#112478 which isn't really relevant
In any case I'd say opening a thread on zulip is a good idea. Note this has no impact on performance so it'd only ever be suspicious
.
Correctness to me sounds like there's likely a mistake somewhere, i.e. that the code doesn't do what it's supposed to do. In the code fragment where the lint triggered for me, there was no mistake, it was just an unnecessary line — but that's not what a correctness lint is for. What incorrect code does this lint have in mind that might be detected using this lint? |
This fits both |
Opened a thread on zulip for this: https://rust-lang.zulipchat.com/#narrow/channel/257328-clippy/topic/Lint.20level.20for.20.60redundant_locals.60 |
Even its documentation says so. According to the documentation, it might either be a "suspicious" or a "perf" lint.
10442f6
to
221dc38
Compare
I don't feel strongly about whether it's a Since you don't feel strongly about its classification as (I don't have a zulip account.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the zulip thread: Ok with and in favor of suspicious
for now(?) 👍 Just one change I'd recommend: while talking about stack allocations, it could mention this rarely being intentional to shorten lifetimes.
I'm not sure which change you recommend me to make. I don't see anything about lifetimes in the description of the lint. |
It should mention this "redundant" redefinition as being intentional in these cases: https://rust-lang.zulipchat.com/#narrow/channel/257328-clippy/topic/Lint.20level.20for.20.60redundant_locals.60/near/489074952 |
Even its documentation says so. According to the documentation, it might either be a "suspicious" or a "perf" lint.
changelog: [
redundant_locals
]: Reclassify as "suspicious" lint.