c9c80d2c5f
The only non-obvious changes: - `building/storage_live_dead_in_statics.rs` has a `#[rustfmt::skip]` attribute to avoid reformating a table of data. - Two `.mir` files have slight changes involving line numbers. - In `unusual_item_types.rs` an `EMIT_MIR` annotation is moved to outside a function, which is the usual spot, because `tidy` complains if such a comment is indented. The commit also tweaks the comments in `rustfmt.toml`.
74 lines
2.0 KiB
Rust
74 lines
2.0 KiB
Rust
// Tests the correct handling of unnamed fields within structs and unions marked with #[repr(C)].
|
|
|
|
// EMIT_MIR field_access.foo.SimplifyCfg-initial.after.mir
|
|
// EMIT_MIR field_access.bar.SimplifyCfg-initial.after.mir
|
|
|
|
#![allow(incomplete_features)]
|
|
#![feature(unnamed_fields)]
|
|
|
|
#[repr(C)]
|
|
struct Foo {
|
|
a: u8,
|
|
_: struct {
|
|
b: i8,
|
|
c: bool,
|
|
},
|
|
_: struct {
|
|
_: struct {
|
|
d: [u8; 1],
|
|
}
|
|
},
|
|
}
|
|
|
|
#[repr(C)]
|
|
union Bar {
|
|
a: u8,
|
|
_: union {
|
|
b: i8,
|
|
c: bool,
|
|
},
|
|
_: union {
|
|
_: union {
|
|
d: [u8; 1],
|
|
}
|
|
},
|
|
}
|
|
|
|
fn access<T>(_: T) {}
|
|
|
|
// CHECK-LABEL: fn foo(
|
|
fn foo(foo: Foo) {
|
|
// CHECK [[a:_.*]] = (_1.0: u8);
|
|
// CHECK _.* = access::<u8>(move [[a]]) -> [return: bb1, unwind: bb5];
|
|
access(foo.a);
|
|
// CHECK [[b:_.*]] = ((_1.1: Foo::{anon_adt#0}).0: i8);
|
|
// CHECK _.* = access::<i8>(move [[b]]) -> [return: bb2, unwind: bb5];
|
|
access(foo.b);
|
|
// CHECK [[c:_.*]] = ((_1.1: Foo::{anon_adt#0}).1: bool);
|
|
// CHECK _.* = access::<bool>(move [[c]]) -> [return: bb3, unwind: bb5];
|
|
access(foo.c);
|
|
// CHECK [[d:_.*]] = (((_1.2: Foo::{anon_adt#1}).0: Foo::{anon_adt#1}::{anon_adt#0}).0: [u8; 1]);
|
|
// CHECK _.* = access::<[u8; 1]>(move [[d]]) -> [return: bb4, unwind: bb5];
|
|
access(foo.d);
|
|
}
|
|
|
|
// CHECK-LABEL: fn bar(
|
|
fn bar(bar: Bar) {
|
|
unsafe {
|
|
// CHECK [[a:_.*]] = (_1.0: u8);
|
|
// CHECK _.* = access::<u8>(move [[a]]) -> [return: bb1, unwind: bb5];
|
|
access(bar.a);
|
|
// CHECK [[b:_.*]] = ((_1.1: Bar::{anon_adt#0}).0: i8);
|
|
// CHECK _.* = access::<i8>(move [[b]]) -> [return: bb2, unwind: bb5];
|
|
access(bar.b);
|
|
// CHECK [[c:_.*]] = ((_1.1: Bar::{anon_adt#0}).1: bool);
|
|
// CHECK _.* = access::<bool>(move [[c]]) -> [return: bb3, unwind: bb5];
|
|
access(bar.c);
|
|
// CHECK [[d:_.*]] = (((_1.2: Bar::{anon_adt#1}).0: Bar::{anon_adt#1}::{anon_adt#0}).0: [u8; 1]);
|
|
// CHECK _.* = access::<[u8; 1]>(move [[d]]) -> [return: bb4, unwind: bb5];
|
|
access(bar.d);
|
|
}
|
|
}
|
|
|
|
fn main() {}
|