File tree Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Original file line number Diff line number Diff line change 1
1
use super :: utils:: make_iterator_snippet;
2
2
use super :: MANUAL_FLATTEN ;
3
3
use clippy_utils:: diagnostics:: span_lint_and_then;
4
+ use clippy_utils:: visitors:: LocalUsedVisitor ;
4
5
use clippy_utils:: { is_lang_ctor, path_to_local_id} ;
5
6
use if_chain:: if_chain;
6
7
use rustc_errors:: Applicability ;
@@ -47,6 +48,9 @@ pub(super) fn check<'tcx>(
47
48
let some_ctor = is_lang_ctor( cx, qpath, OptionSome ) ;
48
49
let ok_ctor = is_lang_ctor( cx, qpath, ResultOk ) ;
49
50
if some_ctor || ok_ctor;
51
+ // Ensure epxr in `if let` is not used afterwards
52
+ let mut used_visitor = LocalUsedVisitor :: new( cx, pat_hir_id) ;
53
+ if !match_arms. iter( ) . any( |arm| used_visitor. check_arm( arm) ) ;
50
54
then {
51
55
let if_let_type = if some_ctor { "Some" } else { "Ok" } ;
52
56
// Prepare the error message
You can’t perform that action at this time.
0 commit comments