@@ -158,7 +158,9 @@ macro_rules! unreachable {
158
158
) ;
159
159
// The first argument is the format and the rest contains tokens to be included in the msg.
160
160
// `unreachable!("Error: {}", code);`
161
- ( $fmt: literal, $( $arg: tt) * ) => (
161
+ // We have the same issue as with panic!() described bellow where we over-approx what we can
162
+ // handle.
163
+ ( $fmt: expr, $( $arg: tt) * ) => (
162
164
kani:: panic( concat!( "internal error: entered unreachable code: " ,
163
165
stringify!( $fmt, $( $arg) * ) ) ) ) ;
164
166
}
@@ -185,9 +187,19 @@ macro_rules! panic {
185
187
( $msg: expr $( , ) ?) => ( {
186
188
kani:: panic( stringify!( $msg) ) ;
187
189
} ) ;
188
- // The first argument is the format and the rest contains tokens to be included in the msg.
190
+ // The first argument is the message and the rest contains tokens to be included in the msg.
189
191
// `panic!("Error: {}", code);`
190
- ( $msg: literal, $( $arg: tt) +) => ( {
192
+ //
193
+ // Note: This macro may match things that wouldn't be accepted by the panic!() macro. we have
194
+ // decided to over-approximate the matching so we can deal with things like macro inside a macro
195
+ // E.g.:
196
+ // ```
197
+ // panic!(concat!("Message {}", " split in two"), argument);
198
+ // ```
199
+ // The std implementation of `panic!()` macro is implemented in the compiler and it seems to
200
+ // be able to do things that we cannot do here.
201
+ // https://github.com/rust-lang/rust/blob/dc2d232c7485c60dd856f8b9aee83426492d4661/compiler/rustc_expand/src/base.rs#L1197
202
+ ( $msg: expr, $( $arg: tt) +) => ( {
191
203
kani:: panic( stringify!( $msg, $( $arg) +) ) ;
192
204
} ) ;
193
205
}
0 commit comments