Make univariant enums act like structs, so that they're aligned correctly.
Consts of such enums are aligned correctly, so we could either misalign them to match the type_of, or fix the type_of. The latter seems like a better idea.
This commit is contained in:
parent
9ea05a4d3e
commit
d009c6330b
2 changed files with 29 additions and 3 deletions
17
src/test/run-pass/const-enum-newtype-align.rs
Normal file
17
src/test/run-pass/const-enum-newtype-align.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
enum E = u32;
|
||||
struct S { a: u8, b: E }
|
||||
const C: S = S { a: 0xA5, b: E(0xDEADBEEF) };
|
||||
|
||||
fn main() {
|
||||
assert C.b == 0xDEADBEEF;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue