File tree Expand file tree Collapse file tree 2 files changed +43
-2
lines changed
run-make/extern-fn-with-packed-struct Expand file tree Collapse file tree 2 files changed +43
-2
lines changed Original file line number Diff line number Diff line change 88// option. This file may not be copied, modified, or distributed
99// except according to those terms.
1010
11+ use std:: fmt;
12+
1113#[ repr( packed) ]
12- #[ derive( Copy , Clone , PartialEq , Debug ) ]
14+ #[ derive( Copy , Clone ) ]
1315struct Foo {
1416 a : i8 ,
1517 b : i16 ,
1618 c : i8
1719}
1820
21+ impl PartialEq for Foo {
22+ fn eq ( & self , other : & Foo ) -> bool {
23+ self . a == other. a && self . b == other. b && self . c == other. c
24+ }
25+ }
26+
27+ impl fmt:: Debug for Foo {
28+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
29+ let a = self . a ;
30+ let b = self . b ;
31+ let c = self . c ;
32+
33+ f. debug_struct ( "Foo" )
34+ . field ( "a" , & a)
35+ . field ( "b" , & b)
36+ . field ( "c" , & c)
37+ . finish ( )
38+ }
39+ }
40+
1941#[ link( name = "test" , kind = "static" ) ]
2042extern {
2143 fn foo ( f : Foo ) -> Foo ;
Original file line number Diff line number Diff line change 88// option. This file may not be copied, modified, or distributed
99// except according to those terms.
1010
11+ use std:: fmt;
1112use std:: mem;
1213
1314#[ repr( packed) ]
14- #[ derive( Copy , Clone , PartialEq , Debug ) ]
15+ #[ derive( Copy , Clone ) ]
1516struct Foo {
1617 bar : u8 ,
1718 baz : u64
1819}
1920
21+ impl PartialEq for Foo {
22+ fn eq ( & self , other : & Foo ) -> bool {
23+ self . bar == other. bar && self . baz == other. baz
24+ }
25+ }
26+
27+ impl fmt:: Debug for Foo {
28+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
29+ let bar = self . bar ;
30+ let baz = self . baz ;
31+
32+ f. debug_struct ( "Foo" )
33+ . field ( "bar" , & bar)
34+ . field ( "baz" , & baz)
35+ . finish ( )
36+ }
37+ }
38+
2039pub fn main ( ) {
2140 let foos = [ Foo { bar : 1 , baz : 2 } ; 10 ] ;
2241
You can’t perform that action at this time.
0 commit comments