@@ -2,7 +2,7 @@ use clippy_config::Conf;
22use clippy_utils:: consts:: { ConstEvalCtxt , Constant } ;
33use clippy_utils:: diagnostics:: { span_lint, span_lint_and_sugg, span_lint_and_then} ;
44use clippy_utils:: msrvs:: { self , Msrv } ;
5- use clippy_utils:: res:: { MaybeQPath , MaybeResPath } ;
5+ use clippy_utils:: res:: MaybeResPath ;
66use clippy_utils:: source:: { SpanRangeExt , snippet, snippet_with_applicability} ;
77use clippy_utils:: sugg:: Sugg ;
88use clippy_utils:: ty:: implements_trait;
@@ -15,7 +15,7 @@ use rustc_lint::{LateContext, LateLintPass, Lint};
1515use rustc_middle:: ty:: { self , ClauseKind , GenericArgKind , PredicatePolarity , Ty } ;
1616use rustc_session:: impl_lint_pass;
1717use rustc_span:: source_map:: Spanned ;
18- use rustc_span:: { Span , sym} ;
18+ use rustc_span:: { DesugaringKind , Span , sym} ;
1919use std:: cmp:: Ordering ;
2020
2121declare_clippy_lint ! {
@@ -368,7 +368,9 @@ fn can_switch_ranges<'tcx>(
368368 // Check if `expr` is the argument of a compiler-generated `IntoIter::into_iter(expr)`
369369 if let ExprKind :: Call ( func, [ arg] ) = parent_expr. kind
370370 && arg. hir_id == use_ctxt. child_id
371- && func. opt_lang_path ( ) == Some ( LangItem :: IntoIterIntoIter )
371+ && let ExprKind :: Path ( qpath) = func. kind
372+ && cx. tcx . qpath_is_lang_item ( qpath, LangItem :: IntoIterIntoIter )
373+ && parent_expr. span . is_desugaring ( DesugaringKind :: ForLoop )
372374 {
373375 return true ;
374376 }
0 commit comments