]> git.lizzy.rs Git - rust.git/commitdiff
rustup
authorRalf Jung <post@ralfj.de>
Thu, 12 May 2022 17:01:04 +0000 (19:01 +0200)
committerRalf Jung <post@ralfj.de>
Thu, 12 May 2022 17:01:04 +0000 (19:01 +0200)
rust-version
src/helpers.rs
src/machine.rs
src/shims/foreign_items.rs

index 8a247d5ab69bdd1f4f6347175d380fe7a58b819d..630aee6793f38da24de0c91a95f396b4613a1ee5 100644 (file)
@@ -1 +1 @@
-8fbd92d0b95d847c68948d8dbbfaccb470db4f92
+481db40311cdd241ae4d33f34f2f75732e44d8e8
index 5b820218a9dd7a2068a65b5d942c8643ef98657a..30fb28436298800db5edcf33f83e4f53c7554a7b 100644 (file)
@@ -13,7 +13,7 @@
     layout::{LayoutOf, TyAndLayout},
     List, TyCtxt,
 };
-use rustc_span::{def_id::CrateNum, Symbol};
+use rustc_span::{def_id::CrateNum, sym, Symbol};
 use rustc_target::abi::{Align, FieldsShape, Size, Variants};
 use rustc_target::spec::abi::Abi;
 
@@ -775,6 +775,14 @@ fn mark_immutable(&mut self, mplace: &MemPlace<Tag>) {
         this.alloc_mark_immutable(mplace.ptr.into_pointer_or_addr().unwrap().provenance.alloc_id)
             .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),
+        }
+    }
 }
 
 /// Check that the number of args is what we expect.
index 2ecb583abb2c4b118ad7b6236707d33ffa8a4321..5facc5327d3fd74e20c3cf4625861260a34b17ff 100644 (file)
@@ -24,7 +24,7 @@
     },
 };
 use rustc_span::def_id::{CrateNum, DefId};
-use rustc_span::symbol::{sym, Symbol};
+use rustc_span::Symbol;
 use rustc_target::abi::Size;
 use rustc_target::spec::abi::Abi;
 
@@ -548,11 +548,7 @@ fn extern_static_base_pointer(
         ecx: &MiriEvalContext<'mir, 'tcx>,
         def_id: DefId,
     ) -> InterpResult<'tcx, Pointer<Tag>> {
-        let attrs = ecx.tcx.get_attrs(def_id);
-        let link_name = match ecx.tcx.sess.first_attr_value_str_by_name(attrs, sym::link_name) {
-            Some(name) => name,
-            None => ecx.tcx.item_name(def_id),
-        };
+        let link_name = ecx.item_link_name(def_id);
         if let Some(&ptr) = ecx.machine.extern_statics.get(&link_name) {
             Ok(ptr)
         } else {
index e9845c53766377d291398d9abfb8bbaefb502ee8..bebe77a02194c8a366f9f776d53666e355ba5f37 100644 (file)
@@ -15,7 +15,7 @@
 use rustc_middle::mir;
 use rustc_middle::ty;
 use rustc_session::config::CrateType;
-use rustc_span::{symbol::sym, Symbol};
+use rustc_span::Symbol;
 use rustc_target::{
     abi::{Align, Size},
     spec::abi::Abi,
@@ -235,12 +235,7 @@ fn emulate_foreign_item(
         unwind: StackPopUnwind,
     ) -> InterpResult<'tcx, Option<(&'mir mir::Body<'tcx>, ty::Instance<'tcx>)>> {
         let this = self.eval_context_mut();
-        let attrs = this.tcx.get_attrs(def_id);
-        let link_name = this
-            .tcx
-            .sess
-            .first_attr_value_str_by_name(attrs, sym::link_name)
-            .unwrap_or_else(|| this.tcx.item_name(def_id));
+        let link_name = this.item_link_name(def_id);
         let tcx = this.tcx.tcx;
 
         // First: functions that diverge.