Skip to content

Commit

Permalink
Auto merge of #66250 - oli-obk:no_fields_in_empty_unions, r=eddyb
Browse files Browse the repository at this point in the history
Undo an assert causing an ICE until we fix the underlying problem

r? @eddyb

fixes #65462
  • Loading branch information
bors committed Nov 11, 2019
2 parents e2fa952 + 39fb820 commit 1062b69
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
6 changes: 1 addition & 5 deletions src/librustc_target/abi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,11 +694,7 @@ impl FieldPlacement {

pub fn offset(&self, i: usize) -> Size {
match *self {
FieldPlacement::Union(count) => {
assert!(i < count,
"Tried to access field {} of union with {} fields", i, count);
Size::ZERO
},
FieldPlacement::Union(_) => Size::ZERO,
FieldPlacement::Array { stride, count } => {
let i = i as u64;
assert!(i < count);
Expand Down
15 changes: 15 additions & 0 deletions src/test/ui/issues/issue-65462.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// build-pass

enum Empty {}
enum Enum {
Empty( Empty )
}

fn foobar() -> Option< Enum > {
let value: Option< Empty > = None;
Some( Enum::Empty( value? ) )
}

fn main() {
foobar();
}

0 comments on commit 1062b69

Please sign in to comment.