rust-lang/rust-clippy

New lint: wildcard pattern in let

Open

#4090 aperta il 13 mag 2019

Vedi su GitHub
 (9 commenti) (0 reazioni) (0 assegnatari)Rust (1391 fork)batch import
A-lintL-restrictiongood first issue

Metriche repository

Star
 (10.406 star)
Metriche merge PR
 (Merge medio 19g 22h) (113 PR mergiate in 30 g)

Descrizione

I think there should be a warning about the wildcard pattern in let. I can't imagine any situation where this makes sense, and there are cases where it's a mistake caused by taking _ for identifier though it's not.

Wrong:

{
    let _ = my scope guard or whatever
    // dropped right away

    do stuff
}

Correct:

{
    let _g = my scope guard or whatever

    do stuff

    // dropped at the end of the scope
}

Guida contributor