| 
1 |  | -// skip-filecheck  | 
 | 1 | +// Tests the correct handling of unnamed fields within structs and unions marked with #[repr(C)].  | 
 | 2 | + | 
2 | 3 | // EMIT_MIR field_access.foo.SimplifyCfg-initial.after.mir  | 
3 | 4 | // EMIT_MIR field_access.bar.SimplifyCfg-initial.after.mir  | 
4 | 5 | 
 
  | 
@@ -36,18 +37,36 @@ union Bar {  | 
36 | 37 | 
 
  | 
37 | 38 | fn access<T>(_: T) {}  | 
38 | 39 | 
 
  | 
 | 40 | +// CHECK-LABEL: fn foo(  | 
39 | 41 | fn foo(foo: Foo) {  | 
 | 42 | +    // CHECK [[a:_.*]] = (_1.0: u8);  | 
 | 43 | +    // CHECK _.* = access::<u8>(move [[a]]) -> [return: bb1, unwind: bb5];  | 
40 | 44 |     access(foo.a);  | 
 | 45 | +    // CHECK [[b:_.*]] = ((_1.1: Foo::{anon_adt#0}).0: i8);  | 
 | 46 | +    // CHECK _.* = access::<i8>(move [[b]]) -> [return: bb2, unwind: bb5];  | 
41 | 47 |     access(foo.b);  | 
 | 48 | +    // CHECK [[c:_.*]] = ((_1.1: Foo::{anon_adt#0}).1: bool);  | 
 | 49 | +    // CHECK _.* = access::<bool>(move [[c]]) -> [return: bb3, unwind: bb5];  | 
42 | 50 |     access(foo.c);  | 
 | 51 | +    // CHECK [[d:_.*]] = (((_1.2: Foo::{anon_adt#1}).0: Foo::{anon_adt#1}::{anon_adt#0}).0: [u8; 1]);  | 
 | 52 | +    // CHECK _.* = access::<[u8; 1]>(move [[d]]) -> [return: bb4, unwind: bb5];  | 
43 | 53 |     access(foo.d);  | 
44 | 54 | }  | 
45 | 55 | 
 
  | 
 | 56 | +// CHECK-LABEL: fn bar(  | 
46 | 57 | fn bar(bar: Bar) {  | 
47 | 58 |     unsafe {  | 
 | 59 | +        // CHECK [[a:_.*]] = (_1.0: u8);  | 
 | 60 | +        // CHECK _.* = access::<u8>(move [[a]]) -> [return: bb1, unwind: bb5];  | 
48 | 61 |         access(bar.a);  | 
 | 62 | +        // CHECK [[b:_.*]] = ((_1.1: Bar::{anon_adt#0}).0: i8);  | 
 | 63 | +        // CHECK _.* = access::<i8>(move [[b]]) -> [return: bb2, unwind: bb5];  | 
49 | 64 |         access(bar.b);  | 
 | 65 | +        // CHECK [[c:_.*]] = ((_1.1: Bar::{anon_adt#0}).1: bool);  | 
 | 66 | +        // CHECK _.* = access::<bool>(move [[c]]) -> [return: bb3, unwind: bb5];  | 
50 | 67 |         access(bar.c);  | 
 | 68 | +        // CHECK [[d:_.*]] = (((_1.2: Bar::{anon_adt#1}).0: Bar::{anon_adt#1}::{anon_adt#0}).0: [u8; 1]);  | 
 | 69 | +        // CHECK _.* = access::<[u8; 1]>(move [[d]]) -> [return: bb4, unwind: bb5];  | 
51 | 70 |         access(bar.d);  | 
52 | 71 |     }  | 
53 | 72 | }  | 
 | 
0 commit comments