@@ -907,14 +907,21 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
907
907
] )
908
908
} ) ;
909
909
910
- // We must additionally check that the return type impls `Future`.
910
+ // We must additionally check that the return type impls `Future + Sized `.
911
911
let future_trait_def_id = tcx. require_lang_item ( LangItem :: Future , None ) ;
912
912
nested. push ( obligation. with (
913
913
tcx,
914
914
sig. output ( ) . map_bound ( |output_ty| {
915
915
ty:: TraitRef :: new ( tcx, future_trait_def_id, [ output_ty] )
916
916
} ) ,
917
917
) ) ;
918
+ let sized_trait_def_id = tcx. require_lang_item ( LangItem :: Sized , None ) ;
919
+ nested. push ( obligation. with (
920
+ tcx,
921
+ sig. output ( ) . map_bound ( |output_ty| {
922
+ ty:: TraitRef :: new ( tcx, sized_trait_def_id, [ output_ty] )
923
+ } ) ,
924
+ ) ) ;
918
925
919
926
( trait_ref, Ty :: from_closure_kind ( tcx, ty:: ClosureKind :: Fn ) )
920
927
}
@@ -928,14 +935,20 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
928
935
] )
929
936
} ) ;
930
937
931
- // We must additionally check that the return type impls `Future`.
932
- // See FIXME in last branch for why we instantiate the binder eagerly.
938
+ // We must additionally check that the return type impls `Future + Sized`.
933
939
let future_trait_def_id = tcx. require_lang_item ( LangItem :: Future , None ) ;
934
940
let placeholder_output_ty = self . infcx . enter_forall_and_leak_universe ( sig. output ( ) ) ;
935
941
nested. push ( obligation. with (
936
942
tcx,
937
943
ty:: TraitRef :: new ( tcx, future_trait_def_id, [ placeholder_output_ty] ) ,
938
944
) ) ;
945
+ let sized_trait_def_id = tcx. require_lang_item ( LangItem :: Sized , None ) ;
946
+ nested. push ( obligation. with (
947
+ tcx,
948
+ sig. output ( ) . map_bound ( |output_ty| {
949
+ ty:: TraitRef :: new ( tcx, sized_trait_def_id, [ output_ty] )
950
+ } ) ,
951
+ ) ) ;
939
952
940
953
( trait_ref, args. kind_ty ( ) )
941
954
}
0 commit comments