@@ -45,3 +45,34 @@ macro_rules! assert {
45
45
kani:: assert( $cond, concat!( stringify!( $( $arg) +) ) ) ;
46
46
} ;
47
47
}
48
+
49
+ // Override the assert_eq and assert_ne macros to
50
+ // 1. Bypass the formatting-related code in the standard library implementation,
51
+ // which is not relevant for verification (see
52
+ // https://github.com/model-checking/kani/issues/14)
53
+ // 2. Generate a suitable message for the assert of the form:
54
+ // assertion failed: $left == $right
55
+ // instead of the uninformative:
56
+ // a panicking function core::panicking::assert_failed is invoked
57
+ // (see https://github.com/model-checking/kani/issues/13)
58
+ // 3. Call kani::assert so that any instrumentation that it does (e.g. injecting
59
+ // reachability checks) is done for assert_eq and assert_ne
60
+ #[ macro_export]
61
+ macro_rules! assert_eq {
62
+ ( $left: expr, $right: expr $( , ) ?) => ( {
63
+ assert!( $left == $right) ;
64
+ } ) ;
65
+ ( $left: expr, $right: expr, $( $arg: tt) +) => ( {
66
+ assert!( $left == $right, $( $arg) +) ;
67
+ } ) ;
68
+ }
69
+
70
+ #[ macro_export]
71
+ macro_rules! assert_ne {
72
+ ( $left: expr, $right: expr $( , ) ?) => ( {
73
+ assert!( $left != $right) ;
74
+ } ) ;
75
+ ( $left: expr, $right: expr, $( $arg: tt) +) => ( {
76
+ assert!( $left != $right, $( $arg) +) ;
77
+ } ) ;
78
+ }
0 commit comments