@@ -9,12 +9,13 @@ use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
9
9
use rustc_errors:: { pluralize, DelayDm } ;
10
10
use rustc_hir as hir;
11
11
use rustc_hir:: def:: { CtorKind , DefKind , Res } ;
12
- use rustc_hir:: def_id:: DefId ;
12
+ use rustc_hir:: def_id:: { DefId , LocalDefId } ;
13
13
use rustc_hir:: hir_id:: HirIdSet ;
14
14
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;
@@ -188,6 +189,7 @@ impl<'a, 'tcx> InteriorVisitor<'a, 'tcx> {
188
189
pub fn resolve_interior < ' a , ' tcx > (
189
190
fcx : & ' a FnCtxt < ' a , ' tcx > ,
190
191
def_id : DefId ,
192
+ generator_def_id : LocalDefId ,
191
193
body_id : hir:: BodyId ,
192
194
interior : Ty < ' tcx > ,
193
195
kind : hir:: GeneratorKind ,
@@ -214,6 +216,16 @@ pub fn resolve_interior<'a, 'tcx>(
214
216
// The types are already kept in insertion order.
215
217
let types = visitor. types ;
216
218
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
+
217
229
// The types in the generator interior contain lifetimes local to the generator itself,
218
230
// which should not be exposed outside of the generator. Therefore, we replace these
219
231
// lifetimes with existentially-bound lifetimes, which reflect the exact value of the
0 commit comments