RS.CLIPPY.SHADOW_UNRELATED
Rebinding a name without even using the original value
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: shadow_unrelated. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks for bindings that shadow other bindings already in scope, either without an initialization or with one that does not even use the original value.
Why restrict this?
Shadowing a binding with a closely related one is part of idiomatic Rust, but shadowing a binding by accident with an unrelated one may indicate a mistake.
Additionally, name shadowing in general can hurt readability, especially in
large code bases, because it is easy to lose track of the active binding at
any place in the code. If linting against all shadowing is desired, you may wish
to use the shadow_same and shadow_reuse lints as well.
Example
let x = y;
let x = z; // shadows the earlier binding
Use instead:
let x = y;
let w = z; // use different variable name