@@ -9,12 +9,13 @@ use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
99use rustc_errors:: { pluralize, DelayDm } ;
1010use rustc_hir as hir;
1111use rustc_hir:: def:: { CtorKind , DefKind , Res } ;
12- use rustc_hir:: def_id:: DefId ;
12+ use rustc_hir:: def_id:: { DefId , LocalDefId } ;
1313use rustc_hir:: hir_id:: HirIdSet ;
1414use rustc_hir:: intravisit:: { self , Visitor } ;
1515use rustc_hir:: { Arm , Expr , ExprKind , Guard , HirId , Pat , PatKind } ;
1616use rustc_infer:: infer:: { DefineOpaqueTypes , RegionVariableOrigin } ;
1717use rustc_middle:: middle:: region:: { self , Scope , ScopeData , YieldData } ;
18+ use rustc_middle:: traits:: ObligationCauseCode ;
1819use rustc_middle:: ty:: fold:: FnMutDelegate ;
1920use rustc_middle:: ty:: { self , BoundVariableKind , RvalueScopes , Ty , TyCtxt , TypeVisitableExt } ;
2021use rustc_span:: symbol:: sym;
@@ -188,6 +189,7 @@ impl<'a, 'tcx> InteriorVisitor<'a, 'tcx> {
188189pub fn resolve_interior < ' a , ' tcx > (
189190 fcx : & ' a FnCtxt < ' a , ' tcx > ,
190191 def_id : DefId ,
192+ generator_def_id : LocalDefId ,
191193 body_id : hir:: BodyId ,
192194 interior : Ty < ' tcx > ,
193195 kind : hir:: GeneratorKind ,
@@ -214,6 +216,16 @@ pub fn resolve_interior<'a, 'tcx>(
214216 // The types are already kept in insertion order.
215217 let types = visitor. types ;
216218
219+ if fcx. tcx . features ( ) . unsized_locals || fcx. tcx . features ( ) . unsized_fn_params {
220+ for interior_ty in & types {
221+ fcx. require_type_is_sized (
222+ interior_ty. ty ,
223+ interior_ty. span ,
224+ ObligationCauseCode :: SizedGeneratorInterior ( generator_def_id) ,
225+ ) ;
226+ }
227+ }
228+
217229 // The types in the generator interior contain lifetimes local to the generator itself,
218230 // which should not be exposed outside of the generator. Therefore, we replace these
219231 // lifetimes with existentially-bound lifetimes, which reflect the exact value of the
0 commit comments