File tree Expand file tree Collapse file tree 2 files changed +1405
-0
lines changed Expand file tree Collapse file tree 2 files changed +1405
-0
lines changed Original file line number Diff line number Diff line change 1+ //@ compile-flags: -Zunpretty=thir-tree --crate-type=lib
2+ //@ normalize-stdout: "DefId\([^ ]* ~ (\w*)\[....\]" -> "DefId($1"
3+ //@ check-pass
4+
5+ #![ feature( offset_of_enum) ]
6+
7+ use std:: marker:: PhantomData ;
8+ use std:: mem:: offset_of;
9+
10+ struct Alpha {
11+ x : u8 ,
12+ y : u16 ,
13+ z : Beta ,
14+ }
15+
16+ struct Beta ( u8 , u8 ) ;
17+
18+ struct Gamma < T > {
19+ x : u8 ,
20+ y : u16 ,
21+ _t : T ,
22+ }
23+
24+ #[ repr( C ) ]
25+ struct Delta < T > {
26+ _phantom : PhantomData < T > ,
27+ x : u8 ,
28+ y : u16 ,
29+ }
30+
31+ enum Blah {
32+ A ,
33+ B { x : u8 , y : usize } ,
34+ }
35+
36+ pub fn concrete ( ) {
37+ let x = offset_of ! ( Alpha , x) ;
38+ let y = offset_of ! ( Alpha , y) ;
39+ let h = offset_of ! ( Blah , B . y) ;
40+ let z0 = offset_of ! ( Alpha , z. 0 ) ;
41+ let z1 = offset_of ! ( Alpha , z. 1 ) ;
42+ }
43+
44+ pub fn generic < T > ( ) {
45+ let gx = offset_of ! ( Gamma <T >, x) ;
46+ let gy = offset_of ! ( Gamma <T >, y) ;
47+ let dx = offset_of ! ( Delta <T >, x) ;
48+ let dy = offset_of ! ( Delta <T >, y) ;
49+ }
You can’t perform that action at this time.
0 commit comments