make [ifs_same_cond] use ignore_interior_mutablility configuration
This commit is contained in:
parent
8a9492aa03
commit
f0ae2b71ca
6 changed files with 91 additions and 17 deletions
1
tests/ui-toml/ifs_same_cond/clippy.toml
Normal file
1
tests/ui-toml/ifs_same_cond/clippy.toml
Normal file
|
|
@ -0,0 +1 @@
|
|||
ignore-interior-mutability = ["std::cell::Cell"]
|
||||
24
tests/ui-toml/ifs_same_cond/ifs_same_cond.rs
Normal file
24
tests/ui-toml/ifs_same_cond/ifs_same_cond.rs
Normal 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 {
|
||||
}
|
||||
}
|
||||
|
|
@ -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() {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue