What is the rationale behind allowing variable shadowing in Rust? [closed]

Because it was initially supported and never removed:

It’s more like we never forbade shadowing, since it just fell out of the implementation of the compiler.

As I recall, Graydon floated the idea of forbidding shadowing, but I stuck up for the feature, nobody else really cared, and so it stayed.

pcwalton

See also:

  • RFC 459: Disallow type/lifetime parameter shadowing
  • What does ‘let x = x’ do in Rust?
  • Why do I need rebinding/shadowing when I can have mutable variable binding?
  • In Rust, what’s the difference between “shadowing” and “mutability”?

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)