9
9
// except according to those terms.
10
10
11
11
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
12
- // xfail-test broken in newrt?
13
12
14
13
// compile-flags:-Z extra-debug-info
15
14
// debugger:break zzz
25
24
// debugger:print full
26
25
// check:$3 = {454545, 0x87654321, 9988}
27
26
28
- // debugger:print empty
29
- // check:$4 = {0, 0x0, 0}
27
+ // debugger:print empty->discr
28
+ // check:$4 = (int *) 0x0
30
29
31
30
// debugger:print droid
32
31
// check:$5 = {id = 675675, range = 10000001, internals = 0x43218765}
33
32
34
- // debugger:print void_droid
35
- // check:$6 = {id = 0, range = 0, internals = 0x0}
33
+ // debugger:print void_droid->internals
34
+ // check:$6 = (int *) 0x0
36
35
36
+ // debugger:continue
37
37
38
38
// If a struct has exactly two variants, one of them is empty, and the other one
39
39
// contains a non-nullable pointer, then this value is used as the discriminator.
40
40
// The test cases in this file make sure that something readable is generated for
41
41
// this kind of types.
42
+ // Unfortunately (for these test cases) the content of the non-discriminant fields
43
+ // in the null-case is not defined. So we just read the discriminator field in
44
+ // this case (by casting the value to a memory-equivalent struct).
42
45
43
46
enum MoreFields < ' self > {
44
47
Full ( u32 , & ' self int , i16 ) ,
45
48
Empty
46
49
}
47
50
51
+ struct MoreFieldsRepr < ' self > {
52
+ a : u32 ,
53
+ discr : & ' self int ,
54
+ b : i16
55
+ }
56
+
48
57
enum NamedFields < ' self > {
49
58
Droid { id : i32 , range : i64 , internals : & ' self int } ,
50
59
Void
51
60
}
52
61
62
+ struct NamedFieldsRepr < ' self > {
63
+ id : i32 ,
64
+ range : i64 ,
65
+ internals : & ' self int
66
+ }
67
+
53
68
fn main ( ) {
54
69
55
70
let some: Option < & u32 > = Some ( unsafe { std:: cast:: transmute ( 0x12345678 ) } ) ;
@@ -58,15 +73,17 @@ fn main() {
58
73
let full = Full ( 454545 , unsafe { std:: cast:: transmute ( 0x87654321 ) } , 9988 ) ;
59
74
60
75
let int_val = 0 ;
61
- let mut empty = Full ( 0 , & int_val, 0 ) ;
62
- empty = Empty ;
76
+ let empty: & MoreFieldsRepr = unsafe { std:: cast:: transmute ( & Empty ) } ;
63
77
64
- let droid = Droid { id : 675675 , range : 10000001 , internals : unsafe { std:: cast:: transmute ( 0x43218765 ) } } ;
78
+ let droid = Droid {
79
+ id : 675675 ,
80
+ range : 10000001 ,
81
+ internals : unsafe { std:: cast:: transmute ( 0x43218765 ) }
82
+ } ;
65
83
66
- let mut void_droid = Droid { id : 0 , range : 0 , internals : & int_val } ;
67
- void_droid = Void ;
84
+ let void_droid: & NamedFieldsRepr = unsafe { std:: cast:: transmute ( & Void ) } ;
68
85
69
86
zzz ( ) ;
70
87
}
71
88
72
- fn zzz ( ) { ( ) }
89
+ fn zzz ( ) { ( ) }
0 commit comments