RS.CLIPPY.SHADOW_SAME

Rebinding a name to itself, e.g., `let mut x = &mut x`

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_same. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Checks for bindings that shadow other bindings already in scope, while just changing reference level or mutability.

Why restrict this?

To require that what are formally distinct variables be given distinct names.

See also shadow_reuse and shadow_unrelated for other restrictions on shadowing.

Example

let x = &x;

Use instead:

let y = &x; // use different variable name