@@ -688,8 +688,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
688
688
span_bug ! ( self . tcx. def_span( expr_def_id) , "async fn generator outside of a fn" )
689
689
} ) ;
690
690
691
+ let closure_span = self . tcx . def_span ( expr_def_id) ;
691
692
let ret_ty = ret_coercion. borrow ( ) . expected_ty ( ) ;
692
- let ret_ty = self . inh . infcx . shallow_resolve ( ret_ty) ;
693
+ let ret_ty = self . try_structurally_resolve_type ( closure_span , ret_ty) ;
693
694
694
695
let get_future_output = |predicate : ty:: Predicate < ' tcx > , span| {
695
696
// Search for a pending obligation like
@@ -711,8 +712,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
711
712
}
712
713
} ;
713
714
714
- let span = self . tcx . def_span ( expr_def_id) ;
715
-
716
715
let output_ty = match * ret_ty. kind ( ) {
717
716
ty:: Infer ( ty:: TyVar ( ret_vid) ) => {
718
717
self . obligations_for_self_ty ( ret_vid) . find_map ( |obligation| {
@@ -726,17 +725,22 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
726
725
. find_map ( |( p, s) | get_future_output ( p. as_predicate ( ) , s) ) ?,
727
726
ty:: Error ( _) => return None ,
728
727
_ => span_bug ! (
729
- span ,
728
+ closure_span ,
730
729
"async fn generator return type not an inference variable: {ret_ty}"
731
730
) ,
732
731
} ;
733
732
734
- let output_ty = self . normalize ( span , output_ty) ;
733
+ let output_ty = self . normalize ( closure_span , output_ty) ;
735
734
736
735
// async fn that have opaque types in their return type need to redo the conversion to inference variables
737
736
// as they fetch the still opaque version from the signature.
738
737
let InferOk { value : output_ty, obligations } = self
739
- . replace_opaque_types_with_inference_vars ( output_ty, body_def_id, span, self . param_env ) ;
738
+ . replace_opaque_types_with_inference_vars (
739
+ output_ty,
740
+ body_def_id,
741
+ closure_span,
742
+ self . param_env ,
743
+ ) ;
740
744
self . register_predicates ( obligations) ;
741
745
742
746
Some ( output_ty)
0 commit comments