@@ -9,7 +9,7 @@ use rustc_middle::mir::{
99 FakeReadCause , LocalDecl , LocalInfo , LocalKind , Location , Operand , Place , PlaceRef ,
1010 ProjectionElem , Rvalue , Statement , StatementKind , Terminator , TerminatorKind , VarBindingForm ,
1111} ;
12- use rustc_middle:: ty:: { self , suggest_constraining_type_param, Ty , TypeFoldable } ;
12+ use rustc_middle:: ty:: { self , suggest_constraining_type_param, Ty } ;
1313use rustc_span:: source_map:: DesugaringKind ;
1414use rustc_span:: symbol:: sym;
1515use rustc_span:: { Span , DUMMY_SP } ;
@@ -1329,20 +1329,18 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
13291329 let return_ty = tcx. erase_regions ( return_ty) ;
13301330
13311331 // 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+ ) ;
13461344 }
13471345 }
13481346 }
0 commit comments