[overly_complex_bool_expr
]: Fix trigger wrongly on never type
This commit is contained in:
parent
c642d0cab6
commit
334bab2c25
@ -232,6 +232,11 @@ fn negate(bin_op_kind: BinOpKind) -> Option<BinOpKind> {
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if self.cx.typeck_results().expr_ty(e).is_never() {
|
||||||
|
return Err("contains never type".to_owned());
|
||||||
|
}
|
||||||
|
|
||||||
for (n, expr) in self.terminals.iter().enumerate() {
|
for (n, expr) in self.terminals.iter().enumerate() {
|
||||||
if eq_expr_value(self.cx, e, expr) {
|
if eq_expr_value(self.cx, e, expr) {
|
||||||
#[expect(clippy::cast_possible_truncation)]
|
#[expect(clippy::cast_possible_truncation)]
|
||||||
|
@ -37,3 +37,13 @@ fn check_expect() {
|
|||||||
#[expect(clippy::overly_complex_bool_expr)]
|
#[expect(clippy::overly_complex_bool_expr)]
|
||||||
let _ = a < b && a >= b;
|
let _ = a < b && a >= b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::never_loop)]
|
||||||
|
fn check_never_type() {
|
||||||
|
loop {
|
||||||
|
_ = (break) || true;
|
||||||
|
}
|
||||||
|
loop {
|
||||||
|
_ = (return) || true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -37,3 +37,13 @@ fn check_expect() {
|
|||||||
#[expect(clippy::overly_complex_bool_expr)]
|
#[expect(clippy::overly_complex_bool_expr)]
|
||||||
let _ = a < b && a >= b;
|
let _ = a < b && a >= b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::never_loop)]
|
||||||
|
fn check_never_type() {
|
||||||
|
loop {
|
||||||
|
_ = (break) || true;
|
||||||
|
}
|
||||||
|
loop {
|
||||||
|
_ = (return) || true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user