This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +19
-19
lines changed Expand file tree Collapse file tree 1 file changed +19
-19
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,22 @@ unsafe extern "C" fn my_puts(s: *const i8) {
11
11
puts ( s) ;
12
12
}
13
13
14
+ macro_rules! assert {
15
+ ( $e: expr) => {
16
+ if !$e {
17
+ panic( stringify!( ! $e) ) ;
18
+ }
19
+ } ;
20
+ }
21
+
22
+ macro_rules! assert_eq {
23
+ ( $l: expr, $r: expr) => {
24
+ if $l != $r {
25
+ panic( stringify!( $l != $r) ) ;
26
+ }
27
+ }
28
+ }
29
+
14
30
#[ lang = "termination" ]
15
31
trait Termination {
16
32
fn report ( self ) -> i32 ;
@@ -20,8 +36,9 @@ impl Termination for () {
20
36
fn report ( self ) -> i32 {
21
37
unsafe {
22
38
NUM = 6 * 7 + 1 + ( 1u8 == 1u8 ) as u8 ; // 44
23
- * NUM_REF as i32
39
+ assert_eq ! ( * NUM_REF as i32 , 44 ) ;
24
40
}
41
+ 0
25
42
}
26
43
}
27
44
@@ -82,29 +99,12 @@ fn start<T: Termination + 'static>(
82
99
unsafe { puts ( * ( ( argv as usize + 2 * intrinsics:: size_of :: < * const u8 > ( ) ) as * const * const i8 ) ) ; }
83
100
}
84
101
85
- main ( ) . report ( ) ;
86
- 0
102
+ main ( ) . report ( ) as isize
87
103
}
88
104
89
105
static mut NUM : u8 = 6 * 7 ;
90
106
static NUM_REF : & ' static u8 = unsafe { & NUM } ;
91
107
92
- macro_rules! assert {
93
- ( $e: expr) => {
94
- if !$e {
95
- panic( stringify!( ! $e) ) ;
96
- }
97
- } ;
98
- }
99
-
100
- macro_rules! assert_eq {
101
- ( $l: expr, $r: expr) => {
102
- if $l != $r {
103
- panic( stringify!( $l != $r) ) ;
104
- }
105
- }
106
- }
107
-
108
108
struct Unique < T : ?Sized > {
109
109
pointer : * const T ,
110
110
_marker : PhantomData < T > ,
You can’t perform that action at this time.
0 commit comments