Skip to content

Commit 19e1c72

Browse files
committed
rustup
1 parent f84a976 commit 19e1c72

File tree

4 files changed

+14
-15
lines changed

4 files changed

+14
-15
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8fbd92d0b95d847c68948d8dbbfaccb470db4f92
1+
481db40311cdd241ae4d33f34f2f75732e44d8e8

src/helpers.rs

Lines changed: 9 additions & 1 deletion
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

Lines changed: 2 additions & 6 deletions
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

Lines changed: 2 additions & 7 deletions
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,
@@ -235,12 +235,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
235235
unwind: StackPopUnwind,
236236
) -> InterpResult<'tcx, Option<(&'mir mir::Body<'tcx>, ty::Instance<'tcx>)>> {
237237
let this = self.eval_context_mut();
238-
let attrs = this.tcx.get_attrs(def_id);
239-
let link_name = this
240-
.tcx
241-
.sess
242-
.first_attr_value_str_by_name(attrs, sym::link_name)
243-
.unwrap_or_else(|| this.tcx.item_name(def_id));
238+
let link_name = this.item_link_name(def_id);
244239
let tcx = this.tcx.tcx;
245240

246241
// First: functions that diverge.

0 commit comments

Comments
 (0)