rustc: Flag some CrateStore methods as "untracked"
The main use of `CrateStore` *before* the `TyCtxt` is created is during
resolution, but we want to be sure that any methods used before resolution are
not used after the `TyCtxt` is created. This commit starts moving the methods
used by resolve to all be named `{name}_untracked` where the rest of the
compiler uses just `{name}` as a query.
During this transition a number of new queries were added to account for
post-resolve usage of these methods.
This commit is contained in:
parent
fd61fa5aef
commit
43ae380191
27 changed files with 152 additions and 99 deletions
|
|
@ -120,7 +120,7 @@ pub fn load_attrs(cx: &DocContext, did: DefId) -> clean::Attributes {
|
|||
/// These names are used later on by HTML rendering to generate things like
|
||||
/// source links back to the original item.
|
||||
pub fn record_extern_fqn(cx: &DocContext, did: DefId, kind: clean::TypeKind) {
|
||||
let crate_name = cx.tcx.sess.cstore.crate_name(did.krate).to_string();
|
||||
let crate_name = cx.tcx.crate_name(did.krate).to_string();
|
||||
let relative = cx.tcx.def_path(did).data.into_iter().filter_map(|elem| {
|
||||
// extern blocks have an empty name
|
||||
let s = elem.data.to_string();
|
||||
|
|
@ -445,9 +445,9 @@ 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, cx.tcx.sess) {
|
||||
for &item in cx.tcx.item_children(did).iter() {
|
||||
let def_id = item.def.def_id();
|
||||
if cx.tcx.sess.cstore.visibility(def_id) == ty::Visibility::Public {
|
||||
if cx.tcx.visibility(def_id) == ty::Visibility::Public {
|
||||
if !visited.insert(def_id) { continue }
|
||||
if let Some(i) = try_inline(cx, item.def, item.ident.name) {
|
||||
items.extend(i)
|
||||
|
|
|
|||
|
|
@ -244,7 +244,7 @@ impl Clean<ExternalCrate> for CrateNum {
|
|||
}
|
||||
}).collect()
|
||||
} else {
|
||||
cx.tcx.sess.cstore.item_children(root, cx.tcx.sess).iter().map(|item| item.def)
|
||||
cx.tcx.item_children(root).iter().map(|item| item.def)
|
||||
.filter_map(as_primitive).collect()
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -208,7 +208,8 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
}
|
||||
|
||||
let imported_from = self.cx.tcx.original_crate_name(def_id.krate);
|
||||
let def = match self.cx.sess().cstore.load_macro(def_id, self.cx.sess()) {
|
||||
let cstore = &self.cx.sess().cstore;
|
||||
let def = match cstore.load_macro_untracked(def_id, self.cx.sess()) {
|
||||
LoadedMacro::MacroDef(macro_def) => macro_def,
|
||||
// FIXME(jseyfried): document proc macro reexports
|
||||
LoadedMacro::ProcMacro(..) => continue,
|
||||
|
|
@ -371,9 +372,9 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
_ if self.inlining && item.vis != hir::Public => {}
|
||||
hir::ItemGlobalAsm(..) => {}
|
||||
hir::ItemExternCrate(ref p) => {
|
||||
let cstore = &self.cx.sess().cstore;
|
||||
let hir_id = self.cx.tcx.hir.node_to_hir_id(item.id);
|
||||
om.extern_crates.push(ExternCrate {
|
||||
cnum: cstore.extern_mod_stmt_cnum(item.id)
|
||||
cnum: self.cx.tcx.extern_mod_stmt_cnum(hir_id)
|
||||
.unwrap_or(LOCAL_CRATE),
|
||||
name,
|
||||
path: p.map(|x|x.to_string()),
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use rustc::middle::cstore::CrateStore;
|
||||
use rustc::middle::privacy::{AccessLevels, AccessLevel};
|
||||
use rustc::hir::def::Def;
|
||||
use rustc::hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefId};
|
||||
|
|
@ -25,7 +24,6 @@ use clean::{AttributesExt, NestedAttributesExt};
|
|||
/// specific rustdoc annotations into account (i.e. `doc(hidden)`)
|
||||
pub struct LibEmbargoVisitor<'a, 'b: 'a, 'tcx: 'b> {
|
||||
cx: &'a ::core::DocContext<'b, 'tcx>,
|
||||
cstore: &'a CrateStore,
|
||||
// Accessibility levels for reachable nodes
|
||||
access_levels: RefMut<'a, AccessLevels<DefId>>,
|
||||
// Previous accessibility level, None means unreachable
|
||||
|
|
@ -38,7 +36,6 @@ impl<'a, 'b, 'tcx> LibEmbargoVisitor<'a, 'b, 'tcx> {
|
|||
pub fn new(cx: &'a ::core::DocContext<'b, 'tcx>) -> LibEmbargoVisitor<'a, 'b, 'tcx> {
|
||||
LibEmbargoVisitor {
|
||||
cx,
|
||||
cstore: &*cx.sess().cstore,
|
||||
access_levels: cx.access_levels.borrow_mut(),
|
||||
prev_level: Some(AccessLevel::Public),
|
||||
visited_mods: FxHashSet()
|
||||
|
|
@ -70,14 +67,14 @@ impl<'a, 'b, 'tcx> LibEmbargoVisitor<'a, 'b, 'tcx> {
|
|||
return;
|
||||
}
|
||||
|
||||
for item in self.cstore.item_children(def_id, self.cx.tcx.sess) {
|
||||
for item in self.cx.tcx.item_children(def_id).iter() {
|
||||
self.visit_item(item.def);
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, def: Def) {
|
||||
let def_id = def.def_id();
|
||||
let vis = self.cstore.visibility(def_id);
|
||||
let vis = self.cx.tcx.visibility(def_id);
|
||||
let inherited_item_level = if vis == Visibility::Public {
|
||||
self.prev_level
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue