make [ifs_same_cond] use ignore_interior_mutablility configuration

This commit is contained in:
J-ZhengLi 2023-02-24 10:46:07 +08:00
parent 8a9492aa03
commit f0ae2b71ca
6 changed files with 91 additions and 17 deletions

View file

@ -0,0 +1 @@
ignore-interior-mutability = ["std::cell::Cell"]

View file

@ -0,0 +1,24 @@
#![warn(clippy::ifs_same_cond)]
#![allow(clippy::if_same_then_else, clippy::comparison_chain)]
fn main() {}
fn issue10272() {
use std::cell::Cell;
let x = Cell::new(true);
if x.get() {
} else if !x.take() {
} else if x.get() {
// ok, x is interior mutable type
} else {
}
let a = [Cell::new(true)];
if a[0].get() {
} else if a[0].take() {
} else if a[0].get() {
// ok, a contains interior mutable type
} else {
}
}

View file

@ -51,6 +51,14 @@ fn issue10272() {
} else if a.contains("ha") {
} else if a == "wow" {
}
let p: *mut i8 = std::ptr::null_mut();
if p.is_null() {
} else if p.align_offset(0) == 0 {
} else if p.is_null() {
// ok, p is mutable pointer
} else {
}
}
fn main() {}