@@ -3,7 +3,7 @@ use clippy_utils::diagnostics::span_lint_and_sugg;
33use clippy_utils:: source:: { indent_of, reindent_multiline, snippet_opt} ;
44use clippy_utils:: ty:: is_type_diagnostic_item;
55use clippy_utils:: usage:: contains_return_break_continue_macro;
6- use clippy_utils:: { in_constant, match_qpath , path_to_local_id, paths, sugg} ;
6+ use clippy_utils:: { in_constant, match_qpath_res , path_to_local_id, paths, sugg} ;
77use if_chain:: if_chain;
88use rustc_errors:: Applicability ;
99use rustc_hir:: { Arm , Expr , ExprKind , Pat , PatKind } ;
@@ -68,23 +68,23 @@ impl Case {
6868}
6969
7070fn lint_manual_unwrap_or < ' tcx > ( cx : & LateContext < ' tcx > , expr : & ' tcx Expr < ' tcx > ) {
71- fn applicable_or_arm < ' a > ( arms : & ' a [ Arm < ' a > ] ) -> Option < & ' a Arm < ' a > > {
71+ fn applicable_or_arm < ' a > ( cx : & LateContext < ' _ > , arms : & ' a [ Arm < ' a > ] ) -> Option < & ' a Arm < ' a > > {
7272 if_chain ! {
7373 if arms. len( ) == 2 ;
7474 if arms. iter( ) . all( |arm| arm. guard. is_none( ) ) ;
7575 if let Some ( ( idx, or_arm) ) = arms. iter( ) . enumerate( ) . find( |( _, arm) |
7676 match arm. pat. kind {
7777 PatKind :: Path ( ref some_qpath) =>
78- match_qpath ( some_qpath, & paths:: OPTION_NONE ) ,
78+ match_qpath_res ( cx , some_qpath, arm . pat . hir_id , & paths:: OPTION_NONE ) ,
7979 PatKind :: TupleStruct ( ref err_qpath, & [ Pat { kind: PatKind :: Wild , .. } ] , _) =>
80- match_qpath ( err_qpath, & paths:: RESULT_ERR ) ,
80+ match_qpath_res ( cx , err_qpath, arm . pat . hir_id , & paths:: RESULT_ERR ) ,
8181 _ => false ,
8282 }
8383 ) ;
8484 let unwrap_arm = & arms[ 1 - idx] ;
8585 if let PatKind :: TupleStruct ( ref unwrap_qpath, & [ unwrap_pat] , _) = unwrap_arm. pat. kind;
86- if match_qpath ( unwrap_qpath, & paths:: OPTION_SOME )
87- || match_qpath ( unwrap_qpath, & paths:: RESULT_OK ) ;
86+ if match_qpath_res ( cx , unwrap_qpath, unwrap_arm . hir_id , & paths:: OPTION_SOME )
87+ || match_qpath_res ( cx , unwrap_qpath, unwrap_arm . hir_id , & paths:: RESULT_OK ) ;
8888 if let PatKind :: Binding ( _, binding_hir_id, ..) = unwrap_pat. kind;
8989 if path_to_local_id( unwrap_arm. body, binding_hir_id) ;
9090 if !contains_return_break_continue_macro( or_arm. body) ;
@@ -106,7 +106,7 @@ fn lint_manual_unwrap_or<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
106106 } else {
107107 None
108108 } ;
109- if let Some ( or_arm) = applicable_or_arm( match_arms) ;
109+ if let Some ( or_arm) = applicable_or_arm( cx , match_arms) ;
110110 if let Some ( or_body_snippet) = snippet_opt( cx, or_arm. body. span) ;
111111 if let Some ( indent) = indent_of( cx, expr. span) ;
112112 if constant_simple( cx, cx. typeck_results( ) , or_arm. body) . is_some( ) ;
0 commit comments