rust-clippy
rust-clippy copied to clipboard
conditions that are always true or false
What it does
It would be great if clippy could somehow try to const-eval expressions in conditions and warn if they always return true/false.
Lint Name
?
Category
suspicious, complexity
Advantage
This could find logic bugs for example
Drawbacks
No response
Example
#![feature(inline_const)]
const X: [i32; 7] = [1, 2, 3, 4, 5, 6, 9];
pub fn main() {
// always true
if const { X[1] == 2 } {}
// always false
if const { X[0] == X[4] } || 2 == X[0] {}
}