Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Comment on lines -698 to -699
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would have been good to at least leave a FIXME in place here so that future readers of this code know there should be an assertion. I just had to rediscover this by browsing the rustc source starting somewhere in codegen.

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();
}