@@ -3,12 +3,14 @@ use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then};
33use clippy_utils:: source:: snippet_with_context;
44use clippy_utils:: usage:: local_used_after_expr;
55use clippy_utils:: visitors:: { for_each_expr_with_closures, Descend } ;
6- use clippy_utils:: { is_diag_item_method, match_def_path, meets_msrv, msrvs, path_to_local_id, paths} ;
6+ use clippy_utils:: {
7+ is_diag_item_method, is_path_lang_item, match_def_path, meets_msrv, msrvs, path_to_local_id, paths,
8+ } ;
79use core:: ops:: ControlFlow ;
810use if_chain:: if_chain;
911use rustc_errors:: Applicability ;
1012use rustc_hir:: {
11- BindingAnnotation , Expr , ExprKind , HirId , LangItem , Local , MatchSource , Node , Pat , PatKind , QPath , Stmt , StmtKind ,
13+ BindingAnnotation , Expr , ExprKind , HirId , LangItem , Local , MatchSource , Node , Pat , PatKind , Stmt , StmtKind ,
1214} ;
1315use rustc_lint:: LateContext ;
1416use rustc_middle:: ty;
@@ -347,13 +349,7 @@ fn parse_iter_usage<'tcx>(
347349
348350 let ( unwrap_kind, span) = if let Some ( ( _, Node :: Expr ( e) ) ) = iter. next ( ) {
349351 match e. kind {
350- ExprKind :: Call (
351- Expr {
352- kind : ExprKind :: Path ( QPath :: LangItem ( LangItem :: TryTraitBranch , ..) ) ,
353- ..
354- } ,
355- _,
356- ) => {
352+ ExprKind :: Call ( callee, _) if is_path_lang_item ( cx, callee, LangItem :: TryTraitBranch ) => {
357353 let parent_span = e. span . parent_callsite ( ) . unwrap ( ) ;
358354 if parent_span. ctxt ( ) == ctxt {
359355 ( Some ( UnwrapKind :: QuestionMark ) , parent_span)
0 commit comments