@@ -767,25 +767,11 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
767
767
let operand_ty = self . operand_ty ( operand) ;
768
768
assert_eq ! ( self . type_size( operand_ty) ?, Some ( 0 ) ) ;
769
769
}
770
- let ( offset, TyAndPacked { ty, packed : _ } ) =
771
- self . nonnull_offset_and_ty (
772
- dest_ty,
773
- nndiscr,
774
- discrfield_source,
775
- ) ?;
776
- // TODO: The packed flag is ignored
777
-
778
- // FIXME(solson)
779
- let dest = self . force_allocation ( dest) ?. to_ptr ( ) ?;
780
-
781
- let dest = dest. offset ( offset. bytes ( ) , & self ) ?;
782
- let dest_size = self . type_size ( ty) ?. expect (
783
- "bad StructWrappedNullablePointer discrfield" ,
784
- ) ;
785
- self . memory . write_maybe_aligned_mut (
786
- !nonnull. packed ,
787
- // The sign does not matter for 0
788
- |mem| mem. write_primval ( dest, PrimVal :: Bytes ( 0 ) , dest_size, false ) ,
770
+ self . write_struct_wrapped_null_pointer (
771
+ dest_ty,
772
+ nndiscr,
773
+ discrfield_source,
774
+ dest,
789
775
) ?;
790
776
}
791
777
} else {
@@ -1021,6 +1007,33 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
1021
1007
Ok ( ( ) )
1022
1008
}
1023
1009
1010
+ pub ( crate ) fn write_struct_wrapped_null_pointer (
1011
+ & mut self ,
1012
+ dest_ty : ty:: Ty < ' tcx > ,
1013
+ nndiscr : u64 ,
1014
+ discrfield_source : & layout:: FieldPath ,
1015
+ dest : Lvalue ,
1016
+ ) -> EvalResult < ' tcx > {
1017
+ let ( offset, TyAndPacked { ty, packed } ) = self . nonnull_offset_and_ty (
1018
+ dest_ty,
1019
+ nndiscr,
1020
+ discrfield_source,
1021
+ ) ?;
1022
+ let nonnull = self . force_allocation ( dest) ?. to_ptr ( ) ?. offset (
1023
+ offset. bytes ( ) ,
1024
+ & self ,
1025
+ ) ?;
1026
+ trace ! ( "struct wrapped nullable pointer type: {}" , ty) ;
1027
+ // only the pointer part of a fat pointer is used for this space optimization
1028
+ let discr_size = self . type_size ( ty) ?. expect (
1029
+ "bad StructWrappedNullablePointer discrfield" ,
1030
+ ) ;
1031
+ self . memory . write_maybe_aligned_mut ( !packed, |mem| {
1032
+ // We're writing 0, signedness does not matter
1033
+ mem. write_primval ( nonnull, PrimVal :: Bytes ( 0 ) , discr_size, false )
1034
+ } )
1035
+ }
1036
+
1024
1037
pub ( super ) fn type_is_fat_ptr ( & self , ty : Ty < ' tcx > ) -> bool {
1025
1038
match ty. sty {
1026
1039
ty:: TyRawPtr ( ref tam) |
0 commit comments