@@ -3,12 +3,14 @@ use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then};
3
3
use clippy_utils:: source:: snippet_with_context;
4
4
use clippy_utils:: usage:: local_used_after_expr;
5
5
use 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
+ } ;
7
9
use core:: ops:: ControlFlow ;
8
10
use if_chain:: if_chain;
9
11
use rustc_errors:: Applicability ;
10
12
use 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 ,
12
14
} ;
13
15
use rustc_lint:: LateContext ;
14
16
use rustc_middle:: ty;
@@ -347,13 +349,7 @@ fn parse_iter_usage<'tcx>(
347
349
348
350
let ( unwrap_kind, span) = if let Some ( ( _, Node :: Expr ( e) ) ) = iter. next ( ) {
349
351
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 ) => {
357
353
let parent_span = e. span . parent_callsite ( ) . unwrap ( ) ;
358
354
if parent_span. ctxt ( ) == ctxt {
359
355
( Some ( UnwrapKind :: QuestionMark ) , parent_span)
0 commit comments