2020-03-18 09:24:48 -05:00
|
|
|
#![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
|
2023-07-02 07:35:19 -05:00
|
|
|
#![allow(
|
|
|
|
clippy::if_same_then_else,
|
|
|
|
clippy::branches_sharing_code,
|
|
|
|
clippy::unnecessary_literal_unwrap
|
|
|
|
)]
|
2023-08-24 14:32:12 -05:00
|
|
|
//@no-rustfix
|
2020-03-18 09:24:48 -05:00
|
|
|
fn test_nested() {
|
|
|
|
fn nested() {
|
|
|
|
let x = Some(());
|
|
|
|
if x.is_some() {
|
2023-08-24 14:32:12 -05:00
|
|
|
// unnecessary
|
|
|
|
x.unwrap();
|
|
|
|
//~^ ERROR: called `unwrap` on `x` after checking its variant with `is_some`
|
2020-03-18 09:24:48 -05:00
|
|
|
} else {
|
2023-08-24 14:32:12 -05:00
|
|
|
// will panic
|
|
|
|
x.unwrap();
|
|
|
|
//~^ ERROR: this call to `unwrap()` will always panic
|
2020-03-18 09:24:48 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|