#![warn(clippy::collapsible_match)]
-#![allow(clippy::needless_return, clippy::no_effect, clippy::single_match)]
+#![allow(
+ clippy::equatable_if_let,
+ clippy::needless_return,
+ clippy::no_effect,
+ clippy::single_match,
+ clippy::uninlined_format_args
+)]
fn lint_cases(opt_opt: Option<Option<u32>>, res_opt: Result<Option<u32>, String>) {
// match without block
}
fn negative_cases(res_opt: Result<Option<u32>, String>, res_res: Result<Result<u32, String>, String>) {
+ while let Some(x) = make() {
+ if let Some(1) = x {
+ todo!();
+ }
+ }
// no wild pattern in outer match
match res_opt {
Ok(val) => match val {
},
_ => return,
}
+ if let Ok(val) = res_opt {
+ if let Some(n) = val {
+ let _ = || {
+ // usage in closure
+ println!("{:?}", val);
+ };
+ }
+ }
+ let _: &dyn std::any::Any = match &Some(Some(1)) {
+ Some(e) => match e {
+ Some(e) => e,
+ e => e,
+ },
+ // else branch looks the same but the binding is different
+ e => e,
+ };
+}
+
+pub enum Issue9647 {
+ A { a: Option<Option<u8>>, b: () },
+ B,
+}
+
+pub fn test_1(x: Issue9647) {
+ if let Issue9647::A { a, .. } = x {
+ if let Some(u) = a {
+ println!("{u:?}")
+ }
+ }
+}
+
+pub fn test_2(x: Issue9647) {
+ if let Issue9647::A { a: Some(a), .. } = x {
+ if let Some(u) = a {
+ println!("{u}")
+ }
+ }
}
fn make<T>() -> T {