Skip to content

Commit

Permalink
test for offset and alignment of the sized part, instead of field count
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Nov 4, 2018
1 parent e753d21 commit aca76d4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/librustc_mir/interpret/eval_context.rs
Expand Up @@ -374,13 +374,13 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc
let (unsized_size, unsized_align) = match self.size_and_align_of(metadata, field)? {
Some(size_and_align) => size_and_align,
None => {
// A field with extern type. If this is the only field,
// we treat this struct just the same. Else, this is an error
// (for now).
if layout.fields.count() == 1 {
// A field with extern type. If this field is at offset 0 and the sized
// part makes no alignment constraints, we behave like the underlying
// extern type.
if sized_size == Size::ZERO && sized_align.abi() == 1 {
return Ok(None)
} else {
bug!("Fields cannot be extern types, unless they are the only field")
bug!("Fields cannot be extern types, unless they are at offset 0")
}
}
};
Expand Down

0 comments on commit aca76d4

Please sign in to comment.