rust-lang/rust-clippy

Always true expressions in if expressions

Open

#1.593 geöffnet am 3. März 2017

Auf GitHub ansehen
 (3 Kommentare) (0 Reaktionen) (1 zugewiesene Person)Rust (1.391 Forks)batch import
A-lintL-correctnessT-middlegood first issue

Repository-Metriken

Stars
 (10.406 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 19T 22h) (113 gemergte PRs in 30 T)

Beschreibung

I'd like Clippy to find this problem in the code, this expression is always true, and Clippy should also suggest the usage of && here instead:

fn foo1a(name: &str) {
    if name != "Min" || name != "Max" {}
}

Another example:

fn foo1b(x: i32) -> bool {
    x > 10 || x < 25
}

Contributor Guide