@@ -16,8 +16,8 @@ use rustc_middle::mir::interpret::{
16
16
ExpectedKind , InterpError , InvalidMetaKind , PointerKind , ValidationErrorInfo ,
17
17
ValidationErrorKind , ValidationErrorKind :: * ,
18
18
} ;
19
- use rustc_middle:: ty;
20
19
use rustc_middle:: ty:: layout:: { LayoutOf , TyAndLayout } ;
20
+ use rustc_middle:: ty:: { self , Ty } ;
21
21
use rustc_span:: symbol:: { sym, Symbol } ;
22
22
use rustc_target:: abi:: {
23
23
Abi , FieldIdx , Scalar as ScalarAbi , Size , VariantIdx , Variants , WrappingRange ,
@@ -950,4 +950,16 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
950
950
// recurse through references which, for now, we don't want here, either.
951
951
self . validate_operand_internal ( op, vec ! [ ] , None , None )
952
952
}
953
+
954
+ /// This function checks if the given `ty`'s layout depends on generators.
955
+ #[ inline( always) ]
956
+ pub fn validate_generator_layout_access ( & self , ty : Ty < ' tcx > ) -> InterpResult < ' tcx > {
957
+ if !M :: ACCESS_GENERATOR_LAYOUT {
958
+ let generators = self . tcx . layout_generators ( ty) ;
959
+ if !generators. is_empty ( ) {
960
+ throw_validation_failure ! ( Vec :: new( ) , GeneratorLayoutAccess { ty, generators } ) ;
961
+ }
962
+ }
963
+ Ok ( ( ) )
964
+ }
953
965
}
0 commit comments