Rollup merge of #143339 - 1c3t3a:issue-143332, r=RalfJung
Respect endianness correctly in CheckEnums test suite The endianness can change the test expectation for the enum check. This change is fixing the failing tests on big endian by changing the tests so that they behave the same as on little endian. Fixes rust-lang/rust#143332.
This commit is contained in:
commit
3940dc7eb4
6 changed files with 14 additions and 15 deletions
|
|
@ -1,6 +1,6 @@
|
|||
//@ run-fail
|
||||
//@ compile-flags: -C debug-assertions
|
||||
//@ error-pattern: trying to construct an enum from an invalid value 0x10000
|
||||
//@ error-pattern: trying to construct an enum from an invalid value
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[repr(u32)]
|
||||
|
|
@ -11,10 +11,9 @@ enum Foo {
|
|||
|
||||
#[allow(dead_code)]
|
||||
struct Bar {
|
||||
a: u16,
|
||||
b: u16,
|
||||
a: u32,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _val: Foo = unsafe { std::mem::transmute::<_, Foo>(Bar { a: 0, b: 1 }) };
|
||||
let _val: Foo = unsafe { std::mem::transmute::<_, Foo>(Bar { a: 3 }) };
|
||||
}
|
||||
|
|
@ -10,11 +10,10 @@ enum Foo {
|
|||
|
||||
#[allow(dead_code)]
|
||||
struct Bar {
|
||||
a: u16,
|
||||
b: u16,
|
||||
a: u32,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _val: Foo = unsafe { std::mem::transmute::<_, Foo>(Bar { a: 0, b: 0 }) };
|
||||
let _val: Foo = unsafe { std::mem::transmute::<_, Foo>(Bar { a: 1, b: 0 }) };
|
||||
let _val: Foo = unsafe { std::mem::transmute::<_, Foo>(Bar { a: 0 }) };
|
||||
let _val: Foo = unsafe { std::mem::transmute::<_, Foo>(Bar { a: 1 }) };
|
||||
}
|
||||
|
|
@ -1,8 +1,9 @@
|
|||
//@ run-fail
|
||||
//@ compile-flags: -C debug-assertions
|
||||
//@ error-pattern: trying to construct an enum from an invalid value 0x3
|
||||
//@ error-pattern: trying to construct an enum from an invalid value
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[repr(u32)]
|
||||
enum Foo {
|
||||
A,
|
||||
B,
|
||||
|
|
@ -10,11 +11,11 @@ enum Foo {
|
|||
|
||||
#[allow(dead_code)]
|
||||
struct Bar {
|
||||
a: usize,
|
||||
b: usize,
|
||||
a: u32,
|
||||
b: u32,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _val: Option<(usize, Foo)> =
|
||||
unsafe { std::mem::transmute::<_, Option<(usize, Foo)>>(Bar { a: 3, b: 3 }) };
|
||||
let _val: Option<(u32, Foo)> =
|
||||
unsafe { std::mem::transmute::<_, Option<(u32, Foo)>>(Bar { a: 3, b: 3 }) };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//@ run-fail
|
||||
//@ compile-flags: -C debug-assertions
|
||||
//@ error-pattern: trying to construct an enum from an invalid value 0x4
|
||||
//@ error-pattern: trying to construct an enum from an invalid value
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[repr(u16)]
|
||||
|
|
@ -17,5 +17,5 @@ enum Nested {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let _val: Nested = unsafe { std::mem::transmute::<u32, Nested>(4) };
|
||||
let _val: Nested = unsafe { std::mem::transmute::<u32, Nested>(u32::MAX) };
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue