use syntax::parse::parser::emit_unclosed_delims;
use syntax::symbol::Symbol;
use syntax_pos::{Span, FileName};
-use rustc_data_structures::bit_set::BitSet;
+use rustc_index::bit_set::BitSet;
macro_rules! provide {
(<$lt:tt> $tcx:ident, $def_id:ident, $other:ident, $cdata:ident,
$tcx: TyCtxt<$lt>,
def_id_arg: T,
) -> <ty::queries::$name<$lt> as QueryConfig<$lt>>::Value {
+ let _prof_timer =
+ $tcx.prof.generic_activity("metadata_decode_entry");
+
#[allow(unused_variables)]
let ($def_id, $other) = def_id_arg.into_args();
assert!(!$def_id.is_local());
- let def_path_hash = $tcx.def_path_hash(DefId {
- krate: $def_id.krate,
- index: CRATE_DEF_INDEX
- });
- let dep_node = def_path_hash
- .to_dep_node(rustc::dep_graph::DepKind::CrateMetadata);
- // The DepNodeIndex of the DepNode::CrateMetadata should be
- // cached somewhere, so that we can use read_index().
- $tcx.dep_graph.read(dep_node);
-
let $cdata = $tcx.crate_data_as_rc_any($def_id.krate);
let $cdata = $cdata.downcast_ref::<cstore::CrateMetadata>()
.expect("CrateStore created data is not a CrateMetadata");
+
+ if $tcx.dep_graph.is_fully_enabled() {
+ let crate_dep_node_index = $cdata.get_crate_dep_node_index($tcx);
+ $tcx.dep_graph.read_index(crate_dep_node_index);
+ }
+
$compute
})*
rendered_const => { cdata.get_rendered_const(def_id.index) }
impl_parent => { cdata.get_parent_impl(def_id.index) }
trait_of_item => { cdata.get_trait_of_item(def_id.index) }
- const_is_rvalue_promotable_to_static => {
- cdata.const_is_rvalue_promotable_to_static(def_id.index)
- }
is_mir_available => { cdata.is_item_mir_available(def_id.index) }
dylib_dependency_formats => { cdata.get_dylib_dependency_formats(tcx) }
let r = *cdata.dep_kind.lock();
r
}
- crate_name => { cdata.name }
+ crate_name => { cdata.root.name }
item_children => {
let mut result = SmallVec::<[_; 8]>::new();
cdata.each_child_of_item(def_id.index, |child| result.push(child), tcx.sess);
// resolve! Does this work? Unsure! That's what the issue is about
*providers = Providers {
is_dllimport_foreign_item: |tcx, id| {
- tcx.native_library_kind(id) == Some(NativeLibraryKind::NativeUnknown)
+ match tcx.native_library_kind(id) {
+ Some(NativeLibraryKind::NativeUnknown) |
+ Some(NativeLibraryKind::NativeRawDylib) => true,
+ _ => false,
+ }
},
is_statically_included_foreign_item: |tcx, id| {
match tcx.native_library_kind(id) {
}
pub fn load_macro_untracked(&self, id: DefId, sess: &Session) -> LoadedMacro {
+ let _prof_timer = sess.prof.generic_activity("metadata_load_macro");
+
let data = self.get_crate_data(id.krate);
if data.is_proc_macro_crate() {
return LoadedMacro::ProcMacro(data.load_proc_macro(id.index, sess));
}
let def = data.get_macro(id.index);
- let macro_full_name = data.def_path(id.index)
- .to_string_friendly(|_| data.imported_name);
+ let macro_full_name = data.def_path(id.index).to_string_friendly(|_| data.root.name);
let source_name = FileName::Macros(macro_full_name);
let source_file = sess.parse_sess.source_map().new_source_file(source_name, def.body);
fn crate_name_untracked(&self, cnum: CrateNum) -> Symbol
{
- self.get_crate_data(cnum).name
+ self.get_crate_data(cnum).root.name
}
fn crate_is_private_dep_untracked(&self, cnum: CrateNum) -> bool {
/// parent `DefId` as well as some idea of what kind of data the
/// `DefId` refers to.
fn def_key(&self, def: DefId) -> DefKey {
- // Note: loading the def-key (or def-path) for a def-id is not
- // a *read* of its metadata. This is because the def-id is
- // really just an interned shorthand for a def-path, which is the
- // canonical name for an item.
- //
- // self.dep_graph.read(DepNode::MetaData(def));
self.get_crate_data(def.krate).def_key(def.index)
}
fn def_path(&self, def: DefId) -> DefPath {
- // See `Note` above in `def_key()` for why this read is
- // commented out:
- //
- // self.dep_graph.read(DepNode::MetaData(def));
self.get_crate_data(def.krate).def_path(def.index)
}