1 #![warn(clippy::if_then_some_else_none)]
2 #![feature(custom_inner_attributes)]
5 // Should issue an error.
13 // Should not issue an error since the `else` block has a statement besides `None`.
18 eprintln!("false...");
22 // Should not issue an error since there are more than 2 blocks in the if-else chain.
24 println!("foo true!");
27 println!("bar true!");
34 println!("foo true!");
38 println!("bar true!");
43 // Should not issue an error since the `then` block has `None`, not `Some`.
44 let _ = if foo() { None } else { Some("foo is false") };
46 // Should not issue an error since the `else` block doesn't use `None` directly.
47 let _ = if foo() { Some("foo is true") } else { into_none() };
49 // Should not issue an error since the `then` block doesn't use `Some` directly.
50 let _ = if foo() { into_some("foo") } else { None };
54 #![clippy::msrv = "1.49"]
55 // `bool::then` was stabilized in 1.50. Do not lint this
65 #![clippy::msrv = "1.50"]
82 fn into_some<T>(v: T) -> Option<T> {
86 fn into_none<T>() -> Option<T> {