@@ -223,54 +223,56 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
223
223
224
224
// First: functions that diverge.
225
225
let ( dest, ret) = match ret {
226
- None => match & * link_name. as_str ( ) {
227
- "miri_start_panic" => {
228
- // `check_shim` happens inside `handle_miri_start_panic`.
229
- this. handle_miri_start_panic ( abi, link_name, args, unwind) ?;
230
- return Ok ( None ) ;
231
- }
232
- // This matches calls to the foreign item `panic_impl`.
233
- // The implementation is provided by the function with the `#[panic_handler]` attribute.
234
- "panic_impl" => {
235
- // We don't use `check_shim` here because we are just forwarding to the lang
236
- // item. Argument count checking will be performed when the returned `Body` is
237
- // called.
238
- this. check_abi_and_shim_symbol_clash ( abi, Abi :: Rust , link_name) ?;
239
- let panic_impl_id = tcx. lang_items ( ) . panic_impl ( ) . unwrap ( ) ;
240
- let panic_impl_instance = ty:: Instance :: mono ( tcx, panic_impl_id) ;
241
- return Ok ( Some ( & * this. load_mir ( panic_impl_instance. def , None ) ?) ) ;
242
- }
243
- #[ rustfmt:: skip]
244
- | "exit"
245
- | "ExitProcess"
246
- => {
247
- let exp_abi = if link_name. as_str ( ) == "exit" {
248
- Abi :: C { unwind : false }
249
- } else {
250
- Abi :: System { unwind : false }
251
- } ;
252
- let & [ ref code] = this. check_shim ( abi, exp_abi, link_name, args) ?;
253
- // it's really u32 for ExitProcess, but we have to put it into the `Exit` variant anyway
254
- let code = this. read_scalar ( code) ?. to_i32 ( ) ?;
255
- throw_machine_stop ! ( TerminationInfo :: Exit ( code. into( ) ) ) ;
256
- }
257
- "abort" => {
258
- let & [ ] = this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
259
- throw_machine_stop ! ( TerminationInfo :: Abort (
260
- "the program aborted execution" . to_owned( )
261
- ) )
262
- }
263
- _ => {
264
- if let Some ( body) = this. lookup_exported_symbol ( link_name) ? {
265
- return Ok ( Some ( body) ) ;
226
+ None =>
227
+ match & * link_name. as_str ( ) {
228
+ "miri_start_panic" => {
229
+ // `check_shim` happens inside `handle_miri_start_panic`.
230
+ this. handle_miri_start_panic ( abi, link_name, args, unwind) ?;
231
+ return Ok ( None ) ;
266
232
}
267
- this. handle_unsupported ( format ! (
268
- "can't call (diverging) foreign function: {}" ,
269
- link_name
270
- ) ) ?;
271
- return Ok ( None ) ;
272
- }
273
- } ,
233
+ // This matches calls to the foreign item `panic_impl`.
234
+ // The implementation is provided by the function with the `#[panic_handler]` attribute.
235
+ "panic_impl" => {
236
+ // We don't use `check_shim` here because we are just forwarding to the lang
237
+ // item. Argument count checking will be performed when the returned `Body` is
238
+ // called.
239
+ this. check_abi_and_shim_symbol_clash ( abi, Abi :: Rust , link_name) ?;
240
+ let panic_impl_id = tcx. lang_items ( ) . panic_impl ( ) . unwrap ( ) ;
241
+ let panic_impl_instance = ty:: Instance :: mono ( tcx, panic_impl_id) ;
242
+ return Ok ( Some ( & * this. load_mir ( panic_impl_instance. def , None ) ?) ) ;
243
+ }
244
+ #[ rustfmt:: skip]
245
+ | "exit"
246
+ | "ExitProcess"
247
+ => {
248
+ let exp_abi = if link_name. as_str ( ) == "exit" {
249
+ Abi :: C { unwind : false }
250
+ } else {
251
+ Abi :: System { unwind : false }
252
+ } ;
253
+ let & [ ref code] = this. check_shim ( abi, exp_abi, link_name, args) ?;
254
+ // it's really u32 for ExitProcess, but we have to put it into the `Exit` variant anyway
255
+ let code = this. read_scalar ( code) ?. to_i32 ( ) ?;
256
+ throw_machine_stop ! ( TerminationInfo :: Exit ( code. into( ) ) ) ;
257
+ }
258
+ "abort" => {
259
+ let & [ ] =
260
+ this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
261
+ throw_machine_stop ! ( TerminationInfo :: Abort (
262
+ "the program aborted execution" . to_owned( )
263
+ ) )
264
+ }
265
+ _ => {
266
+ if let Some ( body) = this. lookup_exported_symbol ( link_name) ? {
267
+ return Ok ( Some ( body) ) ;
268
+ }
269
+ this. handle_unsupported ( format ! (
270
+ "can't call (diverging) foreign function: {}" ,
271
+ link_name
272
+ ) ) ?;
273
+ return Ok ( None ) ;
274
+ }
275
+ } ,
274
276
Some ( p) => p,
275
277
} ;
276
278
0 commit comments