@@ -2994,10 +2994,29 @@ pub struct UnsafetyCheckResult {
29942994 pub unsafe_blocks : Lrc < [ ( hir:: HirId , bool ) ] > ,
29952995}
29962996
2997+ newtype_index ! {
2998+ pub struct GeneratorField {
2999+ derive [ HashStable ]
3000+ DEBUG_FORMAT = "_{}" ,
3001+ }
3002+ }
3003+
29973004/// The layout of generator state
29983005#[ derive( Clone , Debug , RustcEncodable , RustcDecodable , HashStable ) ]
29993006pub struct GeneratorLayout < ' tcx > {
3000- pub variant_fields : IndexVec < VariantIdx , IndexVec < Field , LocalDecl < ' tcx > > > ,
3007+ /// The type of every local stored inside the generator.
3008+ pub field_tys : IndexVec < GeneratorField , Ty < ' tcx > > ,
3009+
3010+ /// Which of the above fields are in each variant. Note that one field may
3011+ /// be stored in multiple variants.
3012+ pub variant_fields : IndexVec < VariantIdx , IndexVec < Field , GeneratorField > > ,
3013+
3014+ /// Names and scopes of all the stored generator locals.
3015+ /// NOTE(tmandry) This is *strictly* a temporary hack for codegen
3016+ /// debuginfo generation, and will be removed at some point.
3017+ /// Do **NOT** use it for anything else, local information should not be
3018+ /// in the MIR, please rely on local crate HIR or other side-channels.
3019+ pub __local_debuginfo_codegen_only_do_not_use : IndexVec < GeneratorField , LocalDecl < ' tcx > > ,
30013020}
30023021
30033022#[ derive( Clone , Debug , RustcEncodable , RustcDecodable , HashStable ) ]
@@ -3186,7 +3205,9 @@ BraceStructTypeFoldableImpl! {
31863205
31873206BraceStructTypeFoldableImpl ! {
31883207 impl <' tcx> TypeFoldable <' tcx> for GeneratorLayout <' tcx> {
3189- variant_fields
3208+ field_tys,
3209+ variant_fields,
3210+ __local_debuginfo_codegen_only_do_not_use,
31903211 }
31913212}
31923213
@@ -3561,6 +3582,15 @@ impl<'tcx> TypeFoldable<'tcx> for Field {
35613582 }
35623583}
35633584
3585+ impl < ' tcx > TypeFoldable < ' tcx > for GeneratorField {
3586+ fn super_fold_with < ' gcx : ' tcx , F : TypeFolder < ' gcx , ' tcx > > ( & self , _: & mut F ) -> Self {
3587+ * self
3588+ }
3589+ fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , _: & mut V ) -> bool {
3590+ false
3591+ }
3592+ }
3593+
35643594impl < ' tcx > TypeFoldable < ' tcx > for Constant < ' tcx > {
35653595 fn super_fold_with < ' gcx : ' tcx , F : TypeFolder < ' gcx , ' tcx > > ( & self , folder : & mut F ) -> Self {
35663596 Constant {
0 commit comments