]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_metadata/csearch.rs
Only retain external static symbols across LTO
[rust.git] / src / librustc_metadata / csearch.rs
index ecbc84023309105f9953e0a7babf1a36c43e79d5..5eade3bc0a54ed7c82152832cccac8bad11fb60f 100644 (file)
 use middle::cstore::{NativeLibraryKind, LinkMeta, LinkagePreference};
 use middle::def;
 use middle::lang_items;
-use middle::ty::{self, Ty};
+use middle::ty::{self, Ty, VariantKind};
 use middle::def_id::{DefId, DefIndex};
 
 use rustc::front::map as hir_map;
 use rustc::mir::repr::Mir;
+use rustc::mir::mir_map::MirMap;
 use rustc::util::nodemap::{FnvHashMap, NodeMap, NodeSet};
 
 use std::cell::RefCell;
@@ -259,16 +260,9 @@ fn is_default_impl(&self, impl_did: DefId) -> bool {
         decoder::is_default_impl(&*cdata, impl_did.index)
     }
 
-    fn is_extern_fn(&self, tcx: &ty::ctxt<'tcx>, did: DefId) -> bool
-    {
+    fn is_extern_item(&self, tcx: &ty::ctxt<'tcx>, did: DefId) -> bool {
         let cdata = self.get_crate_data(did.krate);
-        decoder::is_extern_fn(&*cdata, did.index, tcx)
-    }
-
-    fn is_static(&self, did: DefId) -> bool
-    {
-        let cdata = self.get_crate_data(did.krate);
-        decoder::is_static(&*cdata, did.index)
+        decoder::is_extern_item(&*cdata, did.index, tcx)
     }
 
     fn is_static_method(&self, def: DefId) -> bool
@@ -377,6 +371,17 @@ fn def_path(&self, def: DefId) -> hir_map::DefPath
         local_path.into_iter().chain(path).collect()
     }
 
+    fn variant_kind(&self, def_id: DefId) -> Option<VariantKind> {
+        let cdata = self.get_crate_data(def_id.krate);
+        decoder::get_variant_kind(&cdata, def_id.index)
+    }
+
+    fn struct_ctor_def_id(&self, struct_def_id: DefId) -> Option<DefId>
+    {
+        let cdata = self.get_crate_data(struct_def_id.krate);
+        decoder::get_struct_ctor_def_id(&cdata, struct_def_id.index)
+    }
+
     fn tuple_struct_definition_if_ctor(&self, did: DefId) -> Option<DefId>
     {
         let cdata = self.get_crate_data(did.krate);
@@ -434,6 +439,11 @@ fn maybe_get_item_mir(&self, tcx: &ty::ctxt<'tcx>, def: DefId)
         decoder::maybe_get_item_mir(&*cdata, tcx, def.index)
     }
 
+    fn is_item_mir_available(&self, def: DefId) -> bool {
+        let cdata = self.get_crate_data(def.krate);
+        decoder::is_item_mir_available(&*cdata, def.index)
+    }
+
     fn crates(&self) -> Vec<ast::CrateNum>
     {
         let mut result = vec![];
@@ -486,7 +496,7 @@ fn encode_metadata(&self,
                        item_symbols: &RefCell<NodeMap<String>>,
                        link_meta: &LinkMeta,
                        reachable: &NodeSet,
-                       mir_map: &NodeMap<Mir<'tcx>>,
+                       mir_map: &MirMap<'tcx>,
                        krate: &hir::Crate) -> Vec<u8>
     {
         let encode_inlined_item: encoder::EncodeInlinedItem =