diff --git a/src/helpers.rs b/src/helpers.rs index a7a6f8cfd8..590e8984e9 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -24,7 +24,7 @@ use rustc_middle::ty::{ FloatTy, IntTy, Ty, TyCtxt, UintTy, }; use rustc_session::config::CrateType; -use rustc_span::{sym, Span, Symbol}; +use rustc_span::{Span, Symbol}; use rustc_target::abi::{Align, FieldIdx, FieldsShape, Size, Variants}; use rustc_target::spec::abi::Abi; @@ -1182,14 +1182,6 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { this.alloc_mark_immutable(provenance.get_alloc_id().unwrap()).unwrap(); } - fn item_link_name(&self, def_id: DefId) -> Symbol { - let tcx = self.eval_context_ref().tcx; - match tcx.get_attrs(def_id, sym::link_name).filter_map(|a| a.value_str()).next() { - Some(name) => name, - None => tcx.item_name(def_id), - } - } - /// Converts `src` from floating point to integer type `dest_ty` /// after rounding with mode `round`. /// Returns `None` if `f` is NaN or out of range. diff --git a/src/machine.rs b/src/machine.rs index 0d91279f9f..e321237bb4 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -954,7 +954,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> { // foreign function // Any needed call to `goto_block` will be performed by `emulate_foreign_item`. let args = ecx.copy_fn_args(args); // FIXME: Should `InPlace` arguments be reset to uninit? - let link_name = ecx.item_link_name(instance.def_id()); + let link_name = Symbol::intern(ecx.tcx.symbol_name(instance).name); return ecx.emulate_foreign_item(link_name, abi, &args, dest, ret, unwind); } @@ -1050,7 +1050,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> { ecx: &MiriInterpCx<'tcx>, def_id: DefId, ) -> InterpResult<'tcx, StrictPointer> { - let link_name = ecx.item_link_name(def_id); + let link_name = Symbol::intern(ecx.tcx.symbol_name(Instance::mono(*ecx.tcx, def_id)).name); if let Some(&ptr) = ecx.machine.extern_statics.get(&link_name) { // Various parts of the engine rely on `get_alloc_info` for size and alignment // information. That uses the type information of this static. diff --git a/src/shims/foreign_items.rs b/src/shims/foreign_items.rs index f9ccc6ad4d..9004f7efc8 100644 --- a/src/shims/foreign_items.rs +++ b/src/shims/foreign_items.rs @@ -46,24 +46,9 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { unwind: mir::UnwindAction, ) -> InterpResult<'tcx, Option<(&'tcx mir::Body<'tcx>, ty::Instance<'tcx>)>> { let this = self.eval_context_mut(); - let tcx = this.tcx.tcx; // Some shims forward to other MIR bodies. match link_name.as_str() { - // This matches calls to the foreign item `panic_impl`. - // The implementation is provided by the function with the `#[panic_handler]` attribute. - "panic_impl" => { - // We don't use `check_shim` here because we are just forwarding to the lang - // item. Argument count checking will be performed when the returned `Body` is - // called. - this.check_abi_and_shim_symbol_clash(abi, Abi::Rust, link_name)?; - let panic_impl_id = tcx.lang_items().panic_impl().unwrap(); - let panic_impl_instance = ty::Instance::mono(tcx, panic_impl_id); - return Ok(Some(( - this.load_mir(panic_impl_instance.def, None)?, - panic_impl_instance, - ))); - } "__rust_alloc_error_handler" => { // Forward to the right symbol that implements this function. let Some(handler_kind) = this.tcx.alloc_error_handler_kind(()) else {