@@ -2,21 +2,20 @@ use super::WHILE_LET_ON_ITERATOR;
2
2
use clippy_utils:: diagnostics:: span_lint_and_sugg;
3
3
use clippy_utils:: higher;
4
4
use clippy_utils:: source:: snippet_with_applicability;
5
- use clippy_utils:: { get_enclosing_loop_or_closure, is_lang_item , is_refutable, is_trait_method, visitors:: is_res_used} ;
5
+ use clippy_utils:: { get_enclosing_loop_or_closure, is_lang_ctor , is_refutable, is_trait_method, visitors:: is_res_used} ;
6
6
use if_chain:: if_chain;
7
7
use rustc_errors:: Applicability ;
8
8
use rustc_hir:: intravisit:: { walk_expr, ErasedMap , NestedVisitorMap , Visitor } ;
9
- use rustc_hir:: { def:: Res , Expr , ExprKind , HirId , LangItem , Local , PatKind , QPath , UnOp } ;
9
+ use rustc_hir:: { def:: Res , Expr , ExprKind , HirId , LangItem , Local , PatKind , UnOp } ;
10
10
use rustc_lint:: LateContext ;
11
11
use rustc_span:: { symbol:: sym, Span , Symbol } ;
12
12
13
13
pub ( super ) fn check ( cx : & LateContext < ' tcx > , expr : & ' tcx Expr < ' _ > ) {
14
14
let ( scrutinee_expr, iter_expr, some_pat, loop_expr) = if_chain ! {
15
15
if let Some ( higher:: WhileLet { if_then, let_pat, let_expr } ) = higher:: WhileLet :: hir( expr) ;
16
16
// check for `Some(..)` pattern
17
- if let PatKind :: TupleStruct ( QPath :: Resolved ( None , pat_path) , some_pat, _) = let_pat. kind;
18
- if let Res :: Def ( _, pat_did) = pat_path. res;
19
- if is_lang_item( cx, pat_did, LangItem :: OptionSome ) ;
17
+ if let PatKind :: TupleStruct ( ref pat_path, some_pat, _) = let_pat. kind;
18
+ if is_lang_ctor( cx, pat_path, LangItem :: OptionSome ) ;
20
19
// check for call to `Iterator::next`
21
20
if let ExprKind :: MethodCall ( method_name, _, [ iter_expr] , _) = let_expr. kind;
22
21
if method_name. ident. name == sym:: next;
0 commit comments