Skip to content

Commit d33e7fc

Browse files
committed
Auto merge of #2117 - RalfJung:rustup, r=RalfJung
rustup Cc rust-lang/rust#96975
2 parents 5887b2b + 19e1c72 commit d33e7fc

File tree

4 files changed

+14
-15
lines changed

4 files changed

+14
-15
lines changed

rust-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8fbd92d0b95d847c68948d8dbbfaccb470db4f92
1+
481db40311cdd241ae4d33f34f2f75732e44d8e8

src/helpers.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_middle::ty::{
1313
layout::{LayoutOf, TyAndLayout},
1414
List, TyCtxt,
1515
};
16-
use rustc_span::{def_id::CrateNum, Symbol};
16+
use rustc_span::{def_id::CrateNum, sym, Symbol};
1717
use rustc_target::abi::{Align, FieldsShape, Size, Variants};
1818
use rustc_target::spec::abi::Abi;
1919

@@ -775,6 +775,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
775775
this.alloc_mark_immutable(mplace.ptr.into_pointer_or_addr().unwrap().provenance.alloc_id)
776776
.unwrap();
777777
}
778+
779+
fn item_link_name(&self, def_id: DefId) -> Symbol {
780+
let tcx = self.eval_context_ref().tcx;
781+
match tcx.get_attrs(def_id, sym::link_name).filter_map(|a| a.value_str()).next() {
782+
Some(name) => name,
783+
None => tcx.item_name(def_id),
784+
}
785+
}
778786
}
779787

780788
/// Check that the number of args is what we expect.

src/machine.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use rustc_middle::{
2424
},
2525
};
2626
use rustc_span::def_id::{CrateNum, DefId};
27-
use rustc_span::symbol::{sym, Symbol};
27+
use rustc_span::Symbol;
2828
use rustc_target::abi::Size;
2929
use rustc_target::spec::abi::Abi;
3030

@@ -548,11 +548,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
548548
ecx: &MiriEvalContext<'mir, 'tcx>,
549549
def_id: DefId,
550550
) -> InterpResult<'tcx, Pointer<Tag>> {
551-
let attrs = ecx.tcx.get_attrs(def_id);
552-
let link_name = match ecx.tcx.sess.first_attr_value_str_by_name(attrs, sym::link_name) {
553-
Some(name) => name,
554-
None => ecx.tcx.item_name(def_id),
555-
};
551+
let link_name = ecx.item_link_name(def_id);
556552
if let Some(&ptr) = ecx.machine.extern_statics.get(&link_name) {
557553
Ok(ptr)
558554
} else {

src/shims/foreign_items.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rustc_middle::middle::{
1515
use rustc_middle::mir;
1616
use rustc_middle::ty;
1717
use rustc_session::config::CrateType;
18-
use rustc_span::{symbol::sym, Symbol};
18+
use rustc_span::Symbol;
1919
use rustc_target::{
2020
abi::{Align, Size},
2121
spec::abi::Abi,
@@ -236,12 +236,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
236236
unwind: StackPopUnwind,
237237
) -> InterpResult<'tcx, Option<(&'mir mir::Body<'tcx>, ty::Instance<'tcx>)>> {
238238
let this = self.eval_context_mut();
239-
let attrs = this.tcx.get_attrs(def_id);
240-
let link_name = this
241-
.tcx
242-
.sess
243-
.first_attr_value_str_by_name(attrs, sym::link_name)
244-
.unwrap_or_else(|| this.tcx.item_name(def_id));
239+
let link_name = this.item_link_name(def_id);
245240
let tcx = this.tcx.tcx;
246241

247242
// First: functions that diverge.

0 commit comments

Comments
 (0)