RS.CLIPPY.REDUNDANT_LOCALS
Redundant redefinition of a local binding
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: redundant_locals. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks for redundant redefinitions of local bindings.
Why is this bad?
Redundant redefinitions of local bindings do not change behavior other than variable's lifetimes and are likely to be unintended.
These rebindings can be intentional to shorten the lifetimes of variables because they affect when the Drop implementation is called. Other than that, they do not affect your code's meaning but they may affect rustc's stack allocation.
Example
let a = 0;
let a = a;
fn foo(b: i32) {
let b = b;
}
Use instead:
let a = 0;
// no redefinition with the same name
fn foo(b: i32) {
// no redefinition with the same name
}