diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index 57b8c7f8c16b1..08c0adf110a31 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -230,7 +230,7 @@ pub trait CrateStore { // item info fn visibility(&self, def: DefId) -> ty::Visibility; - fn visible_parent_map<'a>(&'a self) -> ::std::cell::Ref<'a, DefIdMap>; + fn visible_parent_map<'a>(&'a self, sess: &Session) -> ::std::cell::Ref<'a, DefIdMap>; fn item_generics_cloned(&self, def: DefId) -> ty::Generics; // trait info @@ -283,7 +283,7 @@ pub trait CrateStore { fn def_path_hash(&self, def: DefId) -> hir_map::DefPathHash; fn def_path_table(&self, cnum: CrateNum) -> Rc; fn struct_field_names(&self, def: DefId) -> Vec; - fn item_children(&self, did: DefId) -> Vec; + fn item_children(&self, did: DefId, sess: &Session) -> Vec; fn load_macro(&self, did: DefId, sess: &Session) -> LoadedMacro; // misc. metadata @@ -345,7 +345,9 @@ impl CrateStore for DummyCrateStore { { bug!("crate_data_as_rc_any") } // item info fn visibility(&self, def: DefId) -> ty::Visibility { bug!("visibility") } - fn visible_parent_map<'a>(&'a self) -> ::std::cell::Ref<'a, DefIdMap> { + fn visible_parent_map<'a>(&'a self, session: &Session) + -> ::std::cell::Ref<'a, DefIdMap> + { bug!("visible_parent_map") } fn item_generics_cloned(&self, def: DefId) -> ty::Generics @@ -419,7 +421,9 @@ impl CrateStore for DummyCrateStore { bug!("def_path_table") } fn struct_field_names(&self, def: DefId) -> Vec { bug!("struct_field_names") } - fn item_children(&self, did: DefId) -> Vec { bug!("item_children") } + fn item_children(&self, did: DefId, sess: &Session) -> Vec { + bug!("item_children") + } fn load_macro(&self, did: DefId, sess: &Session) -> LoadedMacro { bug!("load_macro") } // misc. metadata diff --git a/src/librustc/ty/item_path.rs b/src/librustc/ty/item_path.rs index 503177e437bef..30dcc3fc81096 100644 --- a/src/librustc/ty/item_path.rs +++ b/src/librustc/ty/item_path.rs @@ -129,7 +129,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn try_push_visible_item_path(self, buffer: &mut T, external_def_id: DefId) -> bool where T: ItemPathBuffer { - let visible_parent_map = self.sess.cstore.visible_parent_map(); + let visible_parent_map = self.sess.cstore.visible_parent_map(self.sess); let (mut cur_def, mut cur_path) = (external_def_id, Vec::::new()); loop { diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index 60cc03f7b7929..529f7613b05c4 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -80,7 +80,7 @@ provide! { <'tcx> tcx, def_id, cdata variances_of => { Rc::new(cdata.get_item_variances(def_id.index)) } associated_item_def_ids => { let mut result = vec![]; - cdata.each_child_of_item(def_id.index, |child| result.push(child.def.def_id())); + cdata.each_child_of_item(def_id.index, |child| result.push(child.def.def_id()), tcx.sess); Rc::new(result) } associated_item => { cdata.get_associated_item(def_id.index) } @@ -348,12 +348,12 @@ impl CrateStore for cstore::CStore { self.get_crate_data(def.krate).get_struct_field_names(def.index) } - fn item_children(&self, def_id: DefId) -> Vec + fn item_children(&self, def_id: DefId, sess: &Session) -> Vec { self.dep_graph.read(DepNode::MetaData(def_id)); let mut result = vec![]; self.get_crate_data(def_id.krate) - .each_child_of_item(def_id.index, |child| result.push(child)); + .each_child_of_item(def_id.index, |child| result.push(child), sess); result } @@ -456,7 +456,7 @@ impl CrateStore for cstore::CStore { /// Returns a map from a sufficiently visible external item (i.e. an external item that is /// visible from at least one local module) to a sufficiently visible parent (considering /// modules that re-export the external item to be parents). - fn visible_parent_map<'a>(&'a self) -> ::std::cell::Ref<'a, DefIdMap> { + fn visible_parent_map<'a>(&'a self, sess: &Session) -> ::std::cell::Ref<'a, DefIdMap> { { let visible_parent_map = self.visible_parent_map.borrow(); if !visible_parent_map.is_empty() { @@ -506,7 +506,7 @@ impl CrateStore for cstore::CStore { index: CRATE_DEF_INDEX }); while let Some(def) = bfs_queue.pop_front() { - for child in self.item_children(def) { + for child in self.item_children(def, sess) { add_child(bfs_queue, child, def); } } diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index a095fdd508417..d4baaa39d5d88 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -654,7 +654,7 @@ impl<'a, 'tcx> CrateMetadata { } /// Iterates over each child of the given item. - pub fn each_child_of_item(&self, id: DefIndex, mut callback: F) + pub fn each_child_of_item(&self, id: DefIndex, mut callback: F, sess: &Session) where F: FnMut(def::Export) { if let Some(ref proc_macros) = self.proc_macros { @@ -677,19 +677,19 @@ impl<'a, 'tcx> CrateMetadata { // Find the item. let item = match self.maybe_entry(id) { None => return, - Some(item) => item.decode(self), + Some(item) => item.decode((self, sess)), }; // Iterate over all children. let macros_only = self.dep_kind.get().macros_only(); - for child_index in item.children.decode(self) { + for child_index in item.children.decode((self, sess)) { if macros_only { continue } // Get the item. if let Some(child) = self.maybe_entry(child_index) { - let child = child.decode(self); + let child = child.decode((self, sess)); match child.kind { EntryKind::MacroDef(..) => {} _ if macros_only => continue, @@ -700,12 +700,12 @@ impl<'a, 'tcx> CrateMetadata { match child.kind { // FIXME(eddyb) Don't encode these in children. EntryKind::ForeignMod => { - for child_index in child.children.decode(self) { + for child_index in child.children.decode((self, sess)) { if let Some(def) = self.get_def(child_index) { callback(def::Export { def: def, ident: Ident::with_empty_ctxt(self.item_name(child_index)), - span: self.entry(child_index).span.decode(self), + span: self.entry(child_index).span.decode((self, sess)), }); } } @@ -718,7 +718,7 @@ impl<'a, 'tcx> CrateMetadata { } let def_key = self.def_key(child_index); - let span = child.span.decode(self); + let span = child.span.decode((self, sess)); if let (Some(def), Some(name)) = (self.get_def(child_index), def_key.disambiguated_data.data.get_opt_name()) { let ident = Ident::with_empty_ctxt(name); @@ -747,7 +747,7 @@ impl<'a, 'tcx> CrateMetadata { } if let EntryKind::Mod(data) = item.kind { - for exp in data.decode(self).reexports.decode(self) { + for exp in data.decode((self, sess)).reexports.decode((self, sess)) { match exp.def { Def::Macro(..) => {} _ if macros_only => continue, diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index 597a62f86884b..49fb44f9d3720 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -478,7 +478,7 @@ impl<'a> Resolver<'a> { span); self.define(parent, ident, TypeNS, (module, vis, DUMMY_SP, expansion)); - for child in self.session.cstore.item_children(def_id) { + for child in self.session.cstore.item_children(def_id, self.session) { let ns = if let Def::AssociatedTy(..) = child.def { TypeNS } else { ValueNS }; self.define(module, child.ident, ns, (child.def, ty::Visibility::Public, DUMMY_SP, expansion)); @@ -564,7 +564,7 @@ impl<'a> Resolver<'a> { /// is built, building it if it is not. pub fn populate_module_if_necessary(&mut self, module: Module<'a>) { if module.populated.get() { return } - for child in self.session.cstore.item_children(module.def_id().unwrap()) { + for child in self.session.cstore.item_children(module.def_id().unwrap(), self.session) { self.build_reduced_graph_for_external_crate_def(module, child); } module.populated.set(true) diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index f8dd5774793a3..4faf71e0cc945 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -526,7 +526,7 @@ pub fn all_traits<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> AllTraits<'a> if !external_mods.insert(def_id) { return; } - for child in tcx.sess.cstore.item_children(def_id) { + for child in tcx.sess.cstore.item_children(def_id, tcx.sess) { handle_external_def(tcx, traits, external_mods, child.def) } } diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 8f7add14d0a05..89c1bc99c2255 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -443,7 +443,7 @@ fn build_module(cx: &DocContext, did: DefId) -> clean::Module { // two namespaces, so the target may be listed twice. Make sure we only // visit each node at most once. let mut visited = FxHashSet(); - for item in cx.tcx.sess.cstore.item_children(did) { + for item in cx.tcx.sess.cstore.item_children(did, cx.tcx.sess) { let def_id = item.def.def_id(); if cx.tcx.sess.cstore.visibility(def_id) == ty::Visibility::Public { if !visited.insert(def_id) { continue } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 3db0e1444db77..8fc8ccd0cfd92 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -241,7 +241,7 @@ impl Clean for CrateNum { } }).collect() } else { - cx.tcx.sess.cstore.item_children(root).iter().map(|item| item.def) + cx.tcx.sess.cstore.item_children(root, cx.tcx.sess).iter().map(|item| item.def) .filter_map(as_primitive).collect() }; diff --git a/src/librustdoc/visit_lib.rs b/src/librustdoc/visit_lib.rs index 40a6ffe9505fd..5518d854348cd 100644 --- a/src/librustdoc/visit_lib.rs +++ b/src/librustdoc/visit_lib.rs @@ -70,7 +70,7 @@ impl<'a, 'b, 'tcx> LibEmbargoVisitor<'a, 'b, 'tcx> { return; } - for item in self.cstore.item_children(def_id) { + for item in self.cstore.item_children(def_id, self.cx.tcx.sess) { self.visit_item(item.def); } }