@@ -100,15 +100,19 @@ pub fn mplace_to_const<'tcx>(
100
100
ecx : & CompileTimeEvalContext < ' _ , ' _ , ' tcx > ,
101
101
mplace : MPlaceTy < ' tcx > ,
102
102
) -> EvalResult < ' tcx , & ' tcx ty:: Const < ' tcx > > {
103
- let MemPlace { ptr, align, meta } = * mplace;
104
103
// extract alloc-offset pair
105
- assert ! ( meta. is_none( ) ) ;
106
- let ptr = ptr. to_ptr ( ) ?;
104
+ assert ! ( mplace . meta. is_none( ) ) ;
105
+ let ptr = mplace . ptr . to_ptr ( ) ?;
107
106
let alloc = ecx. memory . get ( ptr. alloc_id ) ?;
108
- assert ! ( alloc. align. abi( ) >= align. abi( ) ) ;
107
+ assert ! ( alloc. align. abi( ) >= mplace . align. abi( ) ) ;
109
108
assert ! ( alloc. bytes. len( ) as u64 - ptr. offset. bytes( ) >= mplace. layout. size. bytes( ) ) ;
109
+ // FIXME: only clone the parts that interest us (starting at offset, going to offset + size)
110
110
let mut alloc = alloc. clone ( ) ;
111
- alloc. align = align;
111
+ // we take `mplace.layout.align` instead of `mplace.align`
112
+ // as this function is essentially copying the value
113
+ // out of the larger allocation, so we lose all information about
114
+ // potential surrounding types with different alignment.
115
+ alloc. align = mplace. layout . align ;
112
116
// FIXME shouldnt it be the case that `intern_static` has already
113
117
// interned this? I thought that is the entire point of that `FinishStatic` stuff?
114
118
let alloc = ecx. tcx . intern_const_alloc ( alloc) ;
0 commit comments