-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Spurious "redundant redefinition of a binding" error from redundant_locals #11290
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
Comments
We'll need to be more careful if they're in differing blocks, by making sure they're never mutated or explicitly used. |
Well... this is embarassing. I think the best way to handle this would be to just not emit |
That won't catch it if it's immutable and dropped, though. It'll still lint in those cases |
We could use For |
fn main() {
let copy = 0;
let not_copy = Box::new(0);
{
let copy = copy;
let not_copy = not_copy;
drop(copy);
drop(not_copy);
}
} Isn't this still always redundant? |
Hmm... I actually think so. For (Also, you can't drop a |
Summary
Nightly clippy is showing what I believe to be a spurious "redundant redefinition of a binding" error for lexically scoped mutable bindings.
Lint Name
redundant_locals
Reproducer
I tried this code:
I saw this happen:
I expected to see no error for the shadowed mutable binding case, as for the shadowed immutable binding.
Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: