Skip to content

Commit 9a054f2

Browse files
committed
Fix translation of external spans.
1 parent f73f675 commit 9a054f2

File tree

9 files changed

+28
-24
lines changed

9 files changed

+28
-24
lines changed

src/librustc/middle/cstore.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ pub trait CrateStore {
232232

233233
// item info
234234
fn visibility(&self, def: DefId) -> ty::Visibility;
235-
fn visible_parent_map<'a>(&'a self) -> ::std::cell::Ref<'a, DefIdMap<DefId>>;
235+
fn visible_parent_map<'a>(&'a self, sess: &Session) -> ::std::cell::Ref<'a, DefIdMap<DefId>>;
236236
fn item_generics_cloned(&self, def: DefId) -> ty::Generics;
237237

238238
// trait info
@@ -285,7 +285,7 @@ pub trait CrateStore {
285285
fn def_path_hash(&self, def: DefId) -> hir_map::DefPathHash;
286286
fn def_path_table(&self, cnum: CrateNum) -> Rc<DefPathTable>;
287287
fn struct_field_names(&self, def: DefId) -> Vec<ast::Name>;
288-
fn item_children(&self, did: DefId) -> Vec<def::Export>;
288+
fn item_children(&self, did: DefId, sess: &Session) -> Vec<def::Export>;
289289
fn load_macro(&self, did: DefId, sess: &Session) -> LoadedMacro;
290290

291291
// misc. metadata
@@ -347,7 +347,9 @@ impl CrateStore for DummyCrateStore {
347347
{ bug!("crate_data_as_rc_any") }
348348
// item info
349349
fn visibility(&self, def: DefId) -> ty::Visibility { bug!("visibility") }
350-
fn visible_parent_map<'a>(&'a self) -> ::std::cell::Ref<'a, DefIdMap<DefId>> {
350+
fn visible_parent_map<'a>(&'a self, session: &Session)
351+
-> ::std::cell::Ref<'a, DefIdMap<DefId>>
352+
{
351353
bug!("visible_parent_map")
352354
}
353355
fn item_generics_cloned(&self, def: DefId) -> ty::Generics
@@ -421,7 +423,9 @@ impl CrateStore for DummyCrateStore {
421423
bug!("def_path_table")
422424
}
423425
fn struct_field_names(&self, def: DefId) -> Vec<ast::Name> { bug!("struct_field_names") }
424-
fn item_children(&self, did: DefId) -> Vec<def::Export> { bug!("item_children") }
426+
fn item_children(&self, did: DefId, sess: &Session) -> Vec<def::Export> {
427+
bug!("item_children")
428+
}
425429
fn load_macro(&self, did: DefId, sess: &Session) -> LoadedMacro { bug!("load_macro") }
426430

427431
// misc. metadata

src/librustc/ty/item_path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
129129
pub fn try_push_visible_item_path<T>(self, buffer: &mut T, external_def_id: DefId) -> bool
130130
where T: ItemPathBuffer
131131
{
132-
let visible_parent_map = self.sess.cstore.visible_parent_map();
132+
let visible_parent_map = self.sess.cstore.visible_parent_map(self.sess);
133133

134134
let (mut cur_def, mut cur_path) = (external_def_id, Vec::<ast::Name>::new());
135135
loop {

src/librustc_metadata/cstore_impl.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ provide! { <'tcx> tcx, def_id, cdata
8080
variances_of => { Rc::new(cdata.get_item_variances(def_id.index)) }
8181
associated_item_def_ids => {
8282
let mut result = vec![];
83-
cdata.each_child_of_item(def_id.index, |child| result.push(child.def.def_id()));
83+
cdata.each_child_of_item(def_id.index, |child| result.push(child.def.def_id()), tcx.sess);
8484
Rc::new(result)
8585
}
8686
associated_item => { cdata.get_associated_item(def_id.index) }
@@ -348,12 +348,12 @@ impl CrateStore for cstore::CStore {
348348
self.get_crate_data(def.krate).get_struct_field_names(def.index)
349349
}
350350

351-
fn item_children(&self, def_id: DefId) -> Vec<def::Export>
351+
fn item_children(&self, def_id: DefId, sess: &Session) -> Vec<def::Export>
352352
{
353353
self.dep_graph.read(DepNode::MetaData(def_id));
354354
let mut result = vec![];
355355
self.get_crate_data(def_id.krate)
356-
.each_child_of_item(def_id.index, |child| result.push(child));
356+
.each_child_of_item(def_id.index, |child| result.push(child), sess);
357357
result
358358
}
359359

@@ -456,7 +456,7 @@ impl CrateStore for cstore::CStore {
456456
/// Returns a map from a sufficiently visible external item (i.e. an external item that is
457457
/// visible from at least one local module) to a sufficiently visible parent (considering
458458
/// modules that re-export the external item to be parents).
459-
fn visible_parent_map<'a>(&'a self) -> ::std::cell::Ref<'a, DefIdMap<DefId>> {
459+
fn visible_parent_map<'a>(&'a self, sess: &Session) -> ::std::cell::Ref<'a, DefIdMap<DefId>> {
460460
{
461461
let visible_parent_map = self.visible_parent_map.borrow();
462462
if !visible_parent_map.is_empty() {
@@ -506,7 +506,7 @@ impl CrateStore for cstore::CStore {
506506
index: CRATE_DEF_INDEX
507507
});
508508
while let Some(def) = bfs_queue.pop_front() {
509-
for child in self.item_children(def) {
509+
for child in self.item_children(def, sess) {
510510
add_child(bfs_queue, child, def);
511511
}
512512
}

src/librustc_metadata/decoder.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ impl<'a, 'tcx> CrateMetadata {
653653
}
654654

655655
/// Iterates over each child of the given item.
656-
pub fn each_child_of_item<F>(&self, id: DefIndex, mut callback: F)
656+
pub fn each_child_of_item<F>(&self, id: DefIndex, mut callback: F, sess: &Session)
657657
where F: FnMut(def::Export)
658658
{
659659
if let Some(ref proc_macros) = self.proc_macros {
@@ -676,19 +676,19 @@ impl<'a, 'tcx> CrateMetadata {
676676
// Find the item.
677677
let item = match self.maybe_entry(id) {
678678
None => return,
679-
Some(item) => item.decode(self),
679+
Some(item) => item.decode((self, sess)),
680680
};
681681

682682
// Iterate over all children.
683683
let macros_only = self.dep_kind.get().macros_only();
684-
for child_index in item.children.decode(self) {
684+
for child_index in item.children.decode((self, sess)) {
685685
if macros_only {
686686
continue
687687
}
688688

689689
// Get the item.
690690
if let Some(child) = self.maybe_entry(child_index) {
691-
let child = child.decode(self);
691+
let child = child.decode((self, sess));
692692
match child.kind {
693693
EntryKind::MacroDef(..) => {}
694694
_ if macros_only => continue,
@@ -699,12 +699,12 @@ impl<'a, 'tcx> CrateMetadata {
699699
match child.kind {
700700
// FIXME(eddyb) Don't encode these in children.
701701
EntryKind::ForeignMod => {
702-
for child_index in child.children.decode(self) {
702+
for child_index in child.children.decode((self, sess)) {
703703
if let Some(def) = self.get_def(child_index) {
704704
callback(def::Export {
705705
def: def,
706706
ident: Ident::with_empty_ctxt(self.item_name(child_index)),
707-
span: self.entry(child_index).span.decode(self),
707+
span: self.entry(child_index).span.decode((self, sess)),
708708
});
709709
}
710710
}
@@ -717,7 +717,7 @@ impl<'a, 'tcx> CrateMetadata {
717717
}
718718

719719
let def_key = self.def_key(child_index);
720-
let span = child.span.decode(self);
720+
let span = child.span.decode((self, sess));
721721
if let (Some(def), Some(name)) =
722722
(self.get_def(child_index), def_key.disambiguated_data.data.get_opt_name()) {
723723
let ident = Ident::with_empty_ctxt(name);
@@ -746,7 +746,7 @@ impl<'a, 'tcx> CrateMetadata {
746746
}
747747

748748
if let EntryKind::Mod(data) = item.kind {
749-
for exp in data.decode(self).reexports.decode(self) {
749+
for exp in data.decode((self, sess)).reexports.decode((self, sess)) {
750750
match exp.def {
751751
Def::Macro(..) => {}
752752
_ if macros_only => continue,

src/librustc_resolve/build_reduced_graph.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ impl<'a> Resolver<'a> {
478478
span);
479479
self.define(parent, ident, TypeNS, (module, vis, DUMMY_SP, expansion));
480480

481-
for child in self.session.cstore.item_children(def_id) {
481+
for child in self.session.cstore.item_children(def_id, self.session) {
482482
let ns = if let Def::AssociatedTy(..) = child.def { TypeNS } else { ValueNS };
483483
self.define(module, child.ident, ns,
484484
(child.def, ty::Visibility::Public, DUMMY_SP, expansion));
@@ -564,7 +564,7 @@ impl<'a> Resolver<'a> {
564564
/// is built, building it if it is not.
565565
pub fn populate_module_if_necessary(&mut self, module: Module<'a>) {
566566
if module.populated.get() { return }
567-
for child in self.session.cstore.item_children(module.def_id().unwrap()) {
567+
for child in self.session.cstore.item_children(module.def_id().unwrap(), self.session) {
568568
self.build_reduced_graph_for_external_crate_def(module, child);
569569
}
570570
module.populated.set(true)

src/librustc_typeck/check/method/suggest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ pub fn all_traits<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> AllTraits<'a>
526526
if !external_mods.insert(def_id) {
527527
return;
528528
}
529-
for child in tcx.sess.cstore.item_children(def_id) {
529+
for child in tcx.sess.cstore.item_children(def_id, tcx.sess) {
530530
handle_external_def(tcx, traits, external_mods, child.def)
531531
}
532532
}

src/librustdoc/clean/inline.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ fn build_module(cx: &DocContext, did: DefId) -> clean::Module {
443443
// two namespaces, so the target may be listed twice. Make sure we only
444444
// visit each node at most once.
445445
let mut visited = FxHashSet();
446-
for item in cx.tcx.sess.cstore.item_children(did) {
446+
for item in cx.tcx.sess.cstore.item_children(did, cx.tcx.sess) {
447447
let def_id = item.def.def_id();
448448
if cx.tcx.sess.cstore.visibility(def_id) == ty::Visibility::Public {
449449
if !visited.insert(def_id) { continue }

src/librustdoc/clean/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ impl Clean<ExternalCrate> for CrateNum {
241241
}
242242
}).collect()
243243
} else {
244-
cx.tcx.sess.cstore.item_children(root).iter().map(|item| item.def)
244+
cx.tcx.sess.cstore.item_children(root, cx.tcx.sess).iter().map(|item| item.def)
245245
.filter_map(as_primitive).collect()
246246
};
247247

src/librustdoc/visit_lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl<'a, 'b, 'tcx> LibEmbargoVisitor<'a, 'b, 'tcx> {
7070
return;
7171
}
7272

73-
for item in self.cstore.item_children(def_id) {
73+
for item in self.cstore.item_children(def_id, self.cx.tcx.sess) {
7474
self.visit_item(item.def);
7575
}
7676
}

0 commit comments

Comments
 (0)