@@ -3,7 +3,7 @@ use super::utils::make_iterator_snippet;
33use clippy_utils:: diagnostics:: span_lint_and_then;
44use clippy_utils:: msrvs:: { self , Msrv } ;
55use clippy_utils:: visitors:: is_local_used;
6- use clippy_utils:: { higher, path_to_local_id, peel_blocks_with_stmt} ;
6+ use clippy_utils:: { higher, is_refutable , path_to_local_id, peel_blocks_with_stmt} ;
77use rustc_errors:: Applicability ;
88use rustc_hir:: def:: { DefKind , Res } ;
99use rustc_hir:: { Expr , Pat , PatKind } ;
@@ -28,7 +28,7 @@ pub(super) fn check<'tcx>(
2828 && let PatKind :: Binding ( _, pat_hir_id, _, _) = pat. kind
2929 && path_to_local_id ( let_expr, pat_hir_id)
3030 // Ensure the `if let` statement is for the `Some` variant of `Option` or the `Ok` variant of `Result`
31- && let PatKind :: TupleStruct ( ref qpath, _ , _) = let_pat. kind
31+ && let PatKind :: TupleStruct ( ref qpath, [ inner_pat ] , _) = let_pat. kind
3232 && let Res :: Def ( DefKind :: Ctor ( ..) , ctor_id) = cx. qpath_res ( qpath, let_pat. hir_id )
3333 && let Some ( variant_id) = cx. tcx . opt_parent ( ctor_id)
3434 && let some_ctor = cx. tcx . lang_items ( ) . option_some_variant ( ) == Some ( variant_id)
@@ -37,6 +37,7 @@ pub(super) fn check<'tcx>(
3737 // Ensure expr in `if let` is not used afterwards
3838 && !is_local_used ( cx, if_then, pat_hir_id)
3939 && msrv. meets ( cx, msrvs:: ITER_FLATTEN )
40+ && !is_refutable ( cx, inner_pat)
4041 {
4142 let if_let_type = if some_ctor { "Some" } else { "Ok" } ;
4243 // Prepare the error message
0 commit comments