@@ -359,10 +359,10 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
359359 match allocator_kind {
360360 AllocatorKind :: Global => {
361361 // When `#[global_allocator]` is used, `__rust_*` is defined by the macro expansion
362- // of this attribute rather than generated by the allocator shim. As such we have
363- // to call the definition produced by `#[global_allocator]` instead of the shim like
364- // in the case of `#[global_allocator]` not existing. Somewhat unintuitively doing
365- // so is done by returning `NotSupported `.
362+ // of this attribute. As such we have to call an exported Rust function,
363+ // and not execute any Miri shim. Somewhat unintuitively doing so is done
364+ // by returning `NotSupported`, which triggers the `lookup_exported_symbol`
365+ // fallback case in `emulate_foreign_item `.
366366 return Ok ( EmulateByNameResult :: NotSupported ) ;
367367 }
368368 AllocatorKind :: Default => {
@@ -559,9 +559,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
559559 // Rust allocation
560560 "__rust_alloc" | "miri_alloc" => {
561561 let default = |this : & mut MiriInterpCx < ' mir , ' tcx > | {
562- // Only call `check_shim` when `#[global_allocator]` isn't used. The macro
563- // expansion of `#[global_allocator]` defines this symbol and `check_shim`
564- // checks that there exists no definition of a shim.
562+ // Only call `check_shim` when `#[global_allocator]` isn't used. When that
563+ // macro is used, we act like no shim exists, so that the exported function can run.
565564 let [ size, align] = this. check_shim ( abi, Abi :: Rust , link_name, args) ?;
566565 let size = this. read_target_usize ( size) ?;
567566 let align = this. read_target_usize ( align) ?;
0 commit comments