@@ -15,7 +15,7 @@ use rustc_middle::ty::visit::{TypeVisitable, TypeVisitableExt};
15
15
use rustc_middle:: ty:: GenericArgs ;
16
16
use rustc_middle:: ty:: { self , Ty , TyCtxt , TypeSuperVisitable , TypeVisitor } ;
17
17
use rustc_span:: def_id:: LocalDefId ;
18
- use rustc_span:: Span ;
18
+ use rustc_span:: { Span , DUMMY_SP } ;
19
19
use rustc_target:: spec:: abi:: Abi ;
20
20
use rustc_trait_selection:: error_reporting:: traits:: ArgKind ;
21
21
use rustc_trait_selection:: traits;
@@ -564,25 +564,27 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
564
564
return None ;
565
565
} ;
566
566
567
+ let mut return_ty = None ;
568
+
567
569
// FIXME: We may want to elaborate here, though I assume this will be exceedingly rare.
568
570
for bound in self . obligations_for_self_ty ( return_vid) {
569
571
if let Some ( ret_projection) = bound. predicate . as_projection_clause ( )
570
572
&& let Some ( ret_projection) = ret_projection. no_bound_vars ( )
571
573
&& self . tcx . is_lang_item ( ret_projection. def_id ( ) , LangItem :: FutureOutput )
572
574
{
573
- let sig = projection. rebind ( self . tcx . mk_fn_sig (
574
- input_tys,
575
- ret_projection. term . expect_type ( ) ,
576
- false ,
577
- hir:: Safety :: Safe ,
578
- Abi :: Rust ,
579
- ) ) ;
580
-
581
- return Some ( ExpectedSig { cause_span, sig } ) ;
575
+ return_ty = Some ( ret_projection. term . expect_type ( ) ) ;
582
576
}
583
577
}
584
578
585
- None
579
+ let sig = projection. rebind ( self . tcx . mk_fn_sig (
580
+ input_tys,
581
+ return_ty. unwrap_or_else ( || self . next_ty_var ( cause_span. unwrap_or ( DUMMY_SP ) ) ) ,
582
+ false ,
583
+ hir:: Safety :: Safe ,
584
+ Abi :: Rust ,
585
+ ) ) ;
586
+
587
+ return Some ( ExpectedSig { cause_span, sig } ) ;
586
588
}
587
589
588
590
fn sig_of_closure (
0 commit comments