@@ -2,6 +2,7 @@ use super::EXPLICIT_ITER_LOOP;
2
2
use clippy_utils:: diagnostics:: span_lint_and_sugg;
3
3
use clippy_utils:: msrvs:: { self , Msrv } ;
4
4
use clippy_utils:: source:: snippet_with_applicability;
5
+ use clippy_utils:: sym;
5
6
use clippy_utils:: ty:: {
6
7
implements_trait, implements_trait_with_env, is_copy, is_type_lang_item, make_normalized_projection,
7
8
make_normalized_projection_with_regions, normalize_with_regions,
@@ -11,7 +12,6 @@ use rustc_hir::{Expr, Mutability};
11
12
use rustc_lint:: LateContext ;
12
13
use rustc_middle:: ty:: adjustment:: { Adjust , Adjustment , AutoBorrow , AutoBorrowMutability } ;
13
14
use rustc_middle:: ty:: { self , EarlyBinder , Ty } ;
14
- use rustc_span:: sym;
15
15
16
16
pub ( super ) fn check (
17
17
cx : & LateContext < ' _ > ,
@@ -119,7 +119,7 @@ fn is_ref_iterable<'tcx>(
119
119
&& let typing_env = ty:: TypingEnv :: non_body_analysis ( cx. tcx , fn_id)
120
120
&& implements_trait_with_env ( cx. tcx , typing_env, req_self_ty, trait_id, Some ( fn_id) , & [ ] )
121
121
&& let Some ( into_iter_ty) =
122
- make_normalized_projection_with_regions ( cx. tcx , typing_env, trait_id, sym ! ( IntoIter ) , [ req_self_ty] )
122
+ make_normalized_projection_with_regions ( cx. tcx , typing_env, trait_id, sym:: IntoIter , [ req_self_ty] )
123
123
&& let req_res_ty = normalize_with_regions ( cx. tcx , typing_env, req_res_ty)
124
124
&& into_iter_ty == req_res_ty
125
125
{
@@ -152,7 +152,7 @@ fn is_ref_iterable<'tcx>(
152
152
// Using by value won't consume anything
153
153
if implements_trait ( cx, self_ty, trait_id, & [ ] )
154
154
&& let Some ( ty) =
155
- make_normalized_projection ( cx. tcx , cx. typing_env ( ) , trait_id, sym ! ( IntoIter ) , [ self_ty] )
155
+ make_normalized_projection ( cx. tcx , cx. typing_env ( ) , trait_id, sym:: IntoIter , [ self_ty] )
156
156
&& ty == res_ty
157
157
{
158
158
return Some ( ( AdjustKind :: None , self_ty) ) ;
@@ -169,7 +169,7 @@ fn is_ref_iterable<'tcx>(
169
169
} ;
170
170
if implements_trait ( cx, self_ty, trait_id, & [ ] )
171
171
&& let Some ( ty) =
172
- make_normalized_projection ( cx. tcx , cx. typing_env ( ) , trait_id, sym ! ( IntoIter ) , [ self_ty] )
172
+ make_normalized_projection ( cx. tcx , cx. typing_env ( ) , trait_id, sym:: IntoIter , [ self_ty] )
173
173
&& ty == res_ty
174
174
{
175
175
return Some ( ( AdjustKind :: reborrow ( mutbl) , self_ty) ) ;
@@ -183,7 +183,7 @@ fn is_ref_iterable<'tcx>(
183
183
let self_ty = Ty :: new_ref ( cx. tcx , cx. tcx . lifetimes . re_erased , self_ty, mutbl) ;
184
184
if implements_trait ( cx, self_ty, trait_id, & [ ] )
185
185
&& let Some ( ty) =
186
- make_normalized_projection ( cx. tcx , cx. typing_env ( ) , trait_id, sym ! ( IntoIter ) , [ self_ty] )
186
+ make_normalized_projection ( cx. tcx , cx. typing_env ( ) , trait_id, sym:: IntoIter , [ self_ty] )
187
187
&& ty == res_ty
188
188
{
189
189
return Some ( ( AdjustKind :: borrow ( mutbl) , self_ty) ) ;
@@ -206,7 +206,7 @@ fn is_ref_iterable<'tcx>(
206
206
&& target != self_ty
207
207
&& implements_trait ( cx, target, trait_id, & [ ] )
208
208
&& let Some ( ty) =
209
- make_normalized_projection ( cx. tcx , cx. typing_env ( ) , trait_id, sym ! ( IntoIter ) , [ target] )
209
+ make_normalized_projection ( cx. tcx , cx. typing_env ( ) , trait_id, sym:: IntoIter , [ target] )
210
210
&& ty == res_ty
211
211
{
212
212
Some ( ( AdjustKind :: auto_reborrow ( mutbl) , target) )
@@ -224,7 +224,7 @@ fn is_ref_iterable<'tcx>(
224
224
if is_copy ( cx, target)
225
225
&& implements_trait ( cx, target, trait_id, & [ ] )
226
226
&& let Some ( ty) =
227
- make_normalized_projection ( cx. tcx , cx. typing_env ( ) , trait_id, sym ! ( IntoIter ) , [ target] )
227
+ make_normalized_projection ( cx. tcx , cx. typing_env ( ) , trait_id, sym:: IntoIter , [ target] )
228
228
&& ty == res_ty
229
229
{
230
230
Some ( ( AdjustKind :: Deref , target) )
@@ -242,7 +242,7 @@ fn is_ref_iterable<'tcx>(
242
242
if self_ty. is_ref ( )
243
243
&& implements_trait ( cx, target, trait_id, & [ ] )
244
244
&& let Some ( ty) =
245
- make_normalized_projection ( cx. tcx , cx. typing_env ( ) , trait_id, sym ! ( IntoIter ) , [ target] )
245
+ make_normalized_projection ( cx. tcx , cx. typing_env ( ) , trait_id, sym:: IntoIter , [ target] )
246
246
&& ty == res_ty
247
247
{
248
248
Some ( ( AdjustKind :: auto_borrow ( mutbl) , target) )
0 commit comments