rust-clippy/tests/ui/checked_unwrap/complex_conditionals_nested.rs

24 lines
588 B
Rust
Raw Normal View History

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