Skip to content

Commit 517c45a

Browse files
committed
"fix" breakage from rust-lang/rust#46436
1 parent 8ee83a8 commit 517c45a

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

src/eval_context.rs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,17 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
714714
}
715715
}
716716

717+
pub fn layout_is_packed(&self, layout: TyLayout<'tcx>) -> bool {
718+
// TODO. See https://github.com/rust-lang/rust/pull/46436
719+
// for i in layout.fields.index_by_increasing_offset() {
720+
// let field = layout.field(ccx, i);
721+
// if layout.align.abi() < field.align.abi() {
722+
// return true;
723+
// }
724+
// }
725+
return false
726+
}
727+
717728
/// Returns the field type and whether the field is packed
718729
pub fn get_field_ty(
719730
&self,
@@ -723,7 +734,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
723734
let layout = self.type_layout(ty)?.field(self, field_index)?;
724735
Ok(TyAndPacked {
725736
ty: layout.ty,
726-
packed: layout.is_packed()
737+
packed: self.layout_is_packed(layout)
727738
})
728739
}
729740

@@ -1087,25 +1098,25 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
10871098
ty: Ty<'tcx>
10881099
) -> EvalResult<'tcx> {
10891100
let mut layout = self.type_layout(ty)?;
1090-
let mut _packed = layout.is_packed();
1101+
let mut _packed = self.layout_is_packed(layout);
10911102

10921103
// er, this is kinda fishy
10931104
while layout.fields.count() != 2
10941105
|| layout.field(&self, 0)?.size.bytes() == 0
10951106
|| layout.field(&self, 1)?.size.bytes() == 0 {
10961107
layout = layout.field(&self, 0)?;
1097-
_packed |= layout.is_packed();
1108+
_packed |= self.layout_is_packed(layout);
10981109
}
10991110

11001111
assert_eq!(layout.fields.count(), 2);
11011112
let field_0 = layout.field(&self, 0)?;
11021113
let field_1 = layout.field(&self, 1)?;
1103-
assert_eq!(
1104-
field_0.is_packed(),
1105-
field_1.is_packed(),
1106-
"the two fields must agree on being packed"
1107-
);
1108-
_packed |= field_0.is_packed();
1114+
// assert_eq!(
1115+
// field_0.is_packed(),
1116+
// field_1.is_packed(),
1117+
// "the two fields must agree on being packed"
1118+
// );
1119+
// _packed |= field_0.is_packed();
11091120
let field_0_ptr = ptr.offset(layout.fields.offset(0).bytes(), (&self).data_layout())?.into();
11101121
let field_1_ptr = ptr.offset(layout.fields.offset(1).bytes(), (&self).data_layout())?.into();
11111122

0 commit comments

Comments
 (0)