]> git.lizzy.rs Git - rust.git/commitdiff
Correections due to refactoring .
authorNiko Matsakis <niko@alum.mit.edu>
Mon, 21 Mar 2016 17:11:42 +0000 (13:11 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Fri, 25 Mar 2016 18:07:20 +0000 (14:07 -0400)
src/librustc_metadata/decoder.rs
src/librustc_trans/trans/link_guard.rs
src/librustc_trans/trans/symbol_names_test.rs

index 561248fc703f3fc01b55860ecb38851560efd01b..a4eeee44fb718a5a242fbae72531d8494aedcd58 100644 (file)
@@ -810,7 +810,7 @@ pub fn maybe_get_item_ast<'tcx>(cdata: Cmd, tcx: &TyCtxt<'tcx>, id: DefIndex)
     let mut parent_path = item_path(item_doc);
     parent_path.pop();
     let mut parent_def_path = def_path(cdata, id);
-    parent_def_path.pop();
+    parent_def_path.data.pop();
     if let Some(ast_doc) = reader::maybe_get_doc(item_doc, tag_ast as usize) {
         let ii = decode_inlined_item(cdata,
                                      tcx,
@@ -830,7 +830,7 @@ pub fn maybe_get_item_ast<'tcx>(cdata: Cmd, tcx: &TyCtxt<'tcx>, id: DefIndex)
         let mut grandparent_path = parent_path;
         grandparent_path.pop();
         let mut grandparent_def_path = parent_def_path;
-        grandparent_def_path.pop();
+        grandparent_def_path.data.pop();
         let parent_doc = cdata.lookup_item(parent_did.index);
         if let Some(ast_doc) = reader::maybe_get_doc(parent_doc, tag_ast as usize) {
             let ii = decode_inlined_item(cdata,
index 94606cafce5de25b2c319c6f757b7ebbf1de7d0c..453afa827e8f12218d2892076ab5b052c0140404 100644 (file)
@@ -49,12 +49,11 @@ pub fn get_or_insert_link_guard<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>)
     }
 
     let llfty = Type::func(&[], &Type::void(ccx));
-    let guard_function = declare::define_cfn(ccx,
-                                             &guard_name[..],
-                                             llfty,
-                                             ccx.tcx().mk_nil()).unwrap_or_else(|| {
-        ccx.sess().bug("Link guard already defined.");
-    });
+    if declare::get_defined_value(ccx, &guard_name[..]).is_some() {
+        ccx.sess().bug(
+            &format!("Link guard already defined"));
+    }
+    let guard_function = declare::declare_cfn(ccx, &guard_name[..], llfty);
 
     attributes::emit_uwtable(guard_function, true);
     attributes::unwind(guard_function, false);
@@ -76,10 +75,12 @@ pub fn get_or_insert_link_guard<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>)
 
             let dependency_guard_name = link_guard_name(&crate_name[..], &svh);
 
-            let decl = declare::declare_cfn(ccx,
-                                            &dependency_guard_name[..],
-                                            llfty,
-                                            ccx.tcx().mk_nil());
+            if declare::get_defined_value(ccx, &dependency_guard_name[..]).is_some() {
+                ccx.sess().bug(
+                    &format!("Link guard already defined for dependency `{}`",
+                             crate_name));
+            }
+            let decl = declare::declare_cfn(ccx, &dependency_guard_name[..], llfty);
             attributes::unwind(decl, false);
 
             llvm::LLVMPositionBuilderAtEnd(bld, llbb);
index 2b3faa3786e3585fc1f3df6469be80e5dfff18a8..63abbfd53b6fa9e31c8ad9e5e2c8441d05625494 100644 (file)
@@ -21,6 +21,7 @@
 use syntax::ast;
 use syntax::attr::AttrMetaMethods;
 use trans::common::CrateContext;
+use trans::monomorphize::Instance;
 
 const SYMBOL_NAME: &'static str = "rustc_symbol_name";
 const ITEM_PATH: &'static str = "rustc_item_path";
@@ -50,8 +51,9 @@ fn process_attrs(&mut self,
         let def_id = self.tcx.map.local_def_id(node_id);
         for attr in self.tcx.get_attrs(def_id).iter() {
             if attr.check_name(SYMBOL_NAME) {
-                // for now, just monomorphic names
-                let name = symbol_names::exported_name(self.ccx, def_id, &[]);
+                // for now, can only use on monomorphic names
+                let instance = Instance::mono(self.tcx, def_id);
+                let name = symbol_names::exported_name(self.ccx, &instance);
                 self.tcx.sess.span_err(attr.span, &format!("symbol-name({})", name));
             } else if attr.check_name(ITEM_PATH) {
                 let path = self.tcx.item_path_str(def_id);