@@ -15,6 +15,7 @@ use rustc_hir::intravisit::{self, Visitor};
15
15
use rustc_hir:: { Arm , Expr , ExprKind , Guard , HirId , Pat , PatKind } ;
16
16
use rustc_infer:: infer:: { DefineOpaqueTypes , RegionVariableOrigin } ;
17
17
use rustc_middle:: middle:: region:: { self , Scope , ScopeData , YieldData } ;
18
+ use rustc_middle:: traits:: ObligationCauseCode ;
18
19
use rustc_middle:: ty:: fold:: FnMutDelegate ;
19
20
use rustc_middle:: ty:: { self , BoundVariableKind , RvalueScopes , Ty , TyCtxt , TypeVisitableExt } ;
20
21
use rustc_span:: symbol:: sym;
@@ -214,6 +215,16 @@ pub fn resolve_interior<'a, 'tcx>(
214
215
// The types are already kept in insertion order.
215
216
let types = visitor. types ;
216
217
218
+ if fcx. tcx . features ( ) . unsized_locals || fcx. tcx . features ( ) . unsized_fn_params {
219
+ for interior_ty in & types {
220
+ fcx. require_type_is_sized (
221
+ interior_ty. ty ,
222
+ interior_ty. span ,
223
+ ObligationCauseCode :: SizedGeneratorInterior ( def_id. expect_local ( ) ) ,
224
+ ) ;
225
+ }
226
+ }
227
+
217
228
// The types in the generator interior contain lifetimes local to the generator itself,
218
229
// which should not be exposed outside of the generator. Therefore, we replace these
219
230
// lifetimes with existentially-bound lifetimes, which reflect the exact value of the
0 commit comments