@@ -9,7 +9,7 @@ use rustc_middle::mir::{
9
9
FakeReadCause , LocalDecl , LocalInfo , LocalKind , Location , Operand , Place , PlaceRef ,
10
10
ProjectionElem , Rvalue , Statement , StatementKind , Terminator , TerminatorKind , VarBindingForm ,
11
11
} ;
12
- use rustc_middle:: ty:: { self , suggest_constraining_type_param, Ty , TypeFoldable } ;
12
+ use rustc_middle:: ty:: { self , suggest_constraining_type_param, Ty } ;
13
13
use rustc_span:: source_map:: DesugaringKind ;
14
14
use rustc_span:: symbol:: sym;
15
15
use rustc_span:: { Span , DUMMY_SP } ;
@@ -1329,20 +1329,18 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1329
1329
let return_ty = tcx. erase_regions ( return_ty) ;
1330
1330
1331
1331
// to avoid panics
1332
- if !return_ty. has_infer_types ( ) {
1333
- if let Some ( iter_trait) = tcx. get_diagnostic_item ( sym:: Iterator ) {
1334
- if tcx
1335
- . type_implements_trait ( ( iter_trait, return_ty, ty_params, self . param_env ) )
1336
- . must_apply_modulo_regions ( )
1337
- {
1338
- if let Ok ( snippet) = tcx. sess . source_map ( ) . span_to_snippet ( return_span) {
1339
- err. span_suggestion_hidden (
1340
- return_span,
1341
- "use `.collect()` to allocate the iterator" ,
1342
- format ! ( "{}{}" , snippet, ".collect::<Vec<_>>()" ) ,
1343
- Applicability :: MaybeIncorrect ,
1344
- ) ;
1345
- }
1332
+ if let Some ( iter_trait) = tcx. get_diagnostic_item ( sym:: Iterator ) {
1333
+ if tcx
1334
+ . type_implements_trait ( ( iter_trait, return_ty, ty_params, self . param_env ) )
1335
+ . must_apply_modulo_regions ( )
1336
+ {
1337
+ if let Ok ( snippet) = tcx. sess . source_map ( ) . span_to_snippet ( return_span) {
1338
+ err. span_suggestion_hidden (
1339
+ return_span,
1340
+ "use `.collect()` to allocate the iterator" ,
1341
+ format ! ( "{}{}" , snippet, ".collect::<Vec<_>>()" ) ,
1342
+ Applicability :: MaybeIncorrect ,
1343
+ ) ;
1346
1344
}
1347
1345
}
1348
1346
}
0 commit comments