Auto merge of #10013 - Jarcho:issue_9886, r=Manishearth

Don't lint `manual_assert` in `else if`

fixes #9886
changelog: `manual_assert`: Don't lint in `else if`
This commit is contained in:
bors 2022-12-01 22:49:40 +00:00
commit fec00573a5
5 changed files with 21 additions and 2 deletions

View file

@ -62,6 +62,11 @@ fn main() {
panic!("panic5");
}
assert!(!a.is_empty(), "with expansion {}", one!());
if a.is_empty() {
let _ = 0;
} else if a.len() == 1 {
panic!("panic6");
}
}
fn issue7730(a: u8) {

View file

@ -50,6 +50,11 @@ fn main() {
assert!(!(b.is_empty() || a.is_empty()), "panic4");
assert!(!(a.is_empty() || !b.is_empty()), "panic5");
assert!(!a.is_empty(), "with expansion {}", one!());
if a.is_empty() {
let _ = 0;
} else if a.len() == 1 {
panic!("panic6");
}
}
fn issue7730(a: u8) {

View file

@ -65,7 +65,7 @@ LL | | }
| |_____^ help: try instead: `assert!(!a.is_empty(), "with expansion {}", one!());`
error: only a `panic!` in `if`-then statement
--> $DIR/manual_assert.rs:73:5
--> $DIR/manual_assert.rs:78:5
|
LL | / if a > 2 {
LL | | // comment

View file

@ -66,6 +66,11 @@ fn main() {
if a.is_empty() {
panic!("with expansion {}", one!())
}
if a.is_empty() {
let _ = 0;
} else if a.len() == 1 {
panic!("panic6");
}
}
fn issue7730(a: u8) {