@@ -209,20 +209,19 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
209
209
) -> InterpResult < ' tcx , Option < & ' mir mir:: Body < ' tcx > > > {
210
210
let this = self . eval_context_mut ( ) ;
211
211
let attrs = this. tcx . get_attrs ( def_id) ;
212
- let link_name_sym = this
212
+ let link_name = this
213
213
. tcx
214
214
. sess
215
215
. first_attr_value_str_by_name ( & attrs, sym:: link_name)
216
216
. unwrap_or_else ( || this. tcx . item_name ( def_id) ) ;
217
- let link_name = link_name_sym. as_str ( ) ;
218
217
let tcx = this. tcx . tcx ;
219
218
220
219
// First: functions that diverge.
221
220
let ( dest, ret) = match ret {
222
- None => match & * link_name {
221
+ None => match & * link_name. as_str ( ) {
223
222
"miri_start_panic" => {
224
223
// `check_shim` happens inside `handle_miri_start_panic`.
225
- this. handle_miri_start_panic ( abi, link_name_sym , args, unwind) ?;
224
+ this. handle_miri_start_panic ( abi, link_name , args, unwind) ?;
226
225
return Ok ( None ) ;
227
226
}
228
227
// This matches calls to the foreign item `panic_impl`.
@@ -231,7 +230,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
231
230
// We don't use `check_shim` here because we are just forwarding to the lang
232
231
// item. Argument count checking will be performed when the returned `Body` is
233
232
// called.
234
- this. check_abi_and_shim_symbol_clash ( abi, Abi :: Rust , link_name_sym ) ?;
233
+ this. check_abi_and_shim_symbol_clash ( abi, Abi :: Rust , link_name ) ?;
235
234
let panic_impl_id = tcx. lang_items ( ) . panic_impl ( ) . unwrap ( ) ;
236
235
let panic_impl_instance = ty:: Instance :: mono ( tcx, panic_impl_id) ;
237
236
return Ok ( Some ( & * this. load_mir ( panic_impl_instance. def , None ) ?) ) ;
@@ -240,25 +239,24 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
240
239
| "exit"
241
240
| "ExitProcess"
242
241
=> {
243
- let exp_abi = if link_name == "exit" {
242
+ let exp_abi = if link_name. as_str ( ) == "exit" {
244
243
Abi :: C { unwind : false }
245
244
} else {
246
245
Abi :: System { unwind : false }
247
246
} ;
248
- let & [ ref code] = this. check_shim ( abi, exp_abi, link_name_sym , args) ?;
247
+ let & [ ref code] = this. check_shim ( abi, exp_abi, link_name , args) ?;
249
248
// it's really u32 for ExitProcess, but we have to put it into the `Exit` variant anyway
250
249
let code = this. read_scalar ( code) ?. to_i32 ( ) ?;
251
250
throw_machine_stop ! ( TerminationInfo :: Exit ( code. into( ) ) ) ;
252
251
}
253
252
"abort" => {
254
- let & [ ] =
255
- this. check_shim ( abi, Abi :: C { unwind : false } , link_name_sym, args) ?;
253
+ let & [ ] = this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
256
254
throw_machine_stop ! ( TerminationInfo :: Abort (
257
255
"the program aborted execution" . to_owned( )
258
256
) )
259
257
}
260
258
_ => {
261
- if let Some ( body) = this. lookup_exported_symbol ( link_name_sym ) ? {
259
+ if let Some ( body) = this. lookup_exported_symbol ( link_name ) ? {
262
260
return Ok ( Some ( body) ) ;
263
261
}
264
262
this. handle_unsupported ( format ! (
@@ -272,14 +270,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
272
270
} ;
273
271
274
272
// Second: functions that return.
275
- match this. emulate_foreign_item_by_name ( link_name_sym , abi, args, dest, ret) ? {
273
+ match this. emulate_foreign_item_by_name ( link_name , abi, args, dest, ret) ? {
276
274
EmulateByNameResult :: NeedsJumping => {
277
275
trace ! ( "{:?}" , this. dump_place( * * dest) ) ;
278
276
this. go_to_block ( ret) ;
279
277
}
280
278
EmulateByNameResult :: AlreadyJumped => ( ) ,
281
279
EmulateByNameResult :: NotSupported => {
282
- if let Some ( body) = this. lookup_exported_symbol ( link_name_sym ) ? {
280
+ if let Some ( body) = this. lookup_exported_symbol ( link_name ) ? {
283
281
return Ok ( Some ( body) ) ;
284
282
}
285
283
0 commit comments