rustc: Move original_crate_name to a query
This commit is contained in:
parent
d6c88f4936
commit
52b67f988d
8 changed files with 19 additions and 21 deletions
|
|
@ -541,6 +541,7 @@ define_dep_nodes!( <'tcx>
|
|||
[] DeriveRegistrarFn(CrateNum),
|
||||
[] CrateDisambiguator(CrateNum),
|
||||
[] CrateHash(CrateNum),
|
||||
[] OriginalCrateName(CrateNum),
|
||||
);
|
||||
|
||||
trait DepNodeParams<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> : fmt::Debug {
|
||||
|
|
|
|||
|
|
@ -251,8 +251,6 @@ pub trait CrateStore {
|
|||
/// The name of the crate as it is referred to in source code of the current
|
||||
/// crate.
|
||||
fn crate_name(&self, cnum: CrateNum) -> Symbol;
|
||||
/// The name of the crate as it is stored in the crate's metadata.
|
||||
fn original_crate_name(&self, cnum: CrateNum) -> Symbol;
|
||||
|
||||
// resolve
|
||||
fn def_key(&self, def: DefId) -> DefKey;
|
||||
|
|
@ -349,9 +347,6 @@ impl CrateStore for DummyCrateStore {
|
|||
fn dep_kind(&self, cnum: CrateNum) -> DepKind { bug!("is_explicitly_linked") }
|
||||
fn export_macros(&self, cnum: CrateNum) { bug!("export_macros") }
|
||||
fn crate_name(&self, cnum: CrateNum) -> Symbol { bug!("crate_name") }
|
||||
fn original_crate_name(&self, cnum: CrateNum) -> Symbol {
|
||||
bug!("original_crate_name")
|
||||
}
|
||||
|
||||
// resolve
|
||||
fn def_key(&self, def: DefId) -> DefKey { bug!("def_key") }
|
||||
|
|
|
|||
|
|
@ -917,14 +917,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn original_crate_name(self, cnum: CrateNum) -> Symbol {
|
||||
if cnum == LOCAL_CRATE {
|
||||
self.crate_name.clone()
|
||||
} else {
|
||||
self.sess.cstore.original_crate_name(cnum)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn alloc_generics(self, generics: ty::Generics) -> &'gcx ty::Generics {
|
||||
self.global_arenas.generics.alloc(generics)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -624,6 +624,12 @@ impl<'tcx> QueryDescription for queries::crate_hash<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> QueryDescription for queries::original_crate_name<'tcx> {
|
||||
fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
|
||||
format!("looking up the original name a crate")
|
||||
}
|
||||
}
|
||||
|
||||
// If enabled, send a message to the profile-queries thread
|
||||
macro_rules! profq_msg {
|
||||
($tcx:expr, $msg:expr) => {
|
||||
|
|
@ -1206,6 +1212,7 @@ define_maps! { <'tcx>
|
|||
[] fn derive_registrar_fn: DeriveRegistrarFn(CrateNum) -> Option<DefId>,
|
||||
[] fn crate_disambiguator: CrateDisambiguator(CrateNum) -> Symbol,
|
||||
[] fn crate_hash: CrateHash(CrateNum) -> Svh,
|
||||
[] fn original_crate_name: OriginalCrateName(CrateNum) -> Symbol,
|
||||
}
|
||||
|
||||
fn type_param_predicates<'tcx>((item_id, param_id): (DefId, DefId)) -> DepConstructor<'tcx> {
|
||||
|
|
|
|||
|
|
@ -2210,7 +2210,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
if let Some(id) = self.hir.as_local_node_id(id) {
|
||||
self.hir.name(id)
|
||||
} else if id.index == CRATE_DEF_INDEX {
|
||||
self.sess.cstore.original_crate_name(id.krate)
|
||||
self.original_crate_name(id.krate)
|
||||
} else {
|
||||
let def_key = self.sess.cstore.def_key(id);
|
||||
// The name of a StructCtor is that of its struct parent.
|
||||
|
|
@ -2516,6 +2516,12 @@ fn crate_disambiguator<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
tcx.sess.local_crate_disambiguator()
|
||||
}
|
||||
|
||||
fn original_crate_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
crate_num: CrateNum) -> Symbol {
|
||||
assert_eq!(crate_num, LOCAL_CRATE);
|
||||
tcx.crate_name.clone()
|
||||
}
|
||||
|
||||
pub fn provide(providers: &mut ty::maps::Providers) {
|
||||
util::provide(providers);
|
||||
context::provide(providers);
|
||||
|
|
@ -2528,6 +2534,7 @@ pub fn provide(providers: &mut ty::maps::Providers) {
|
|||
param_env,
|
||||
trait_of_item,
|
||||
crate_disambiguator,
|
||||
original_crate_name,
|
||||
trait_impls_of: trait_def::trait_impls_of_provider,
|
||||
..*providers
|
||||
};
|
||||
|
|
|
|||
|
|
@ -177,6 +177,7 @@ provide! { <'tcx> tcx, def_id, cdata,
|
|||
}
|
||||
crate_disambiguator => { cdata.disambiguator() }
|
||||
crate_hash => { cdata.hash() }
|
||||
original_crate_name => { cdata.name() }
|
||||
}
|
||||
|
||||
pub fn provide_local<'tcx>(providers: &mut Providers<'tcx>) {
|
||||
|
|
@ -280,11 +281,6 @@ impl CrateStore for cstore::CStore {
|
|||
self.get_crate_data(cnum).name
|
||||
}
|
||||
|
||||
fn original_crate_name(&self, cnum: CrateNum) -> Symbol
|
||||
{
|
||||
self.get_crate_data(cnum).name()
|
||||
}
|
||||
|
||||
/// Returns the `DefKey` for a given `DefId`. This indicates the
|
||||
/// parent `DefId` as well as some idea of what kind of data the
|
||||
/// `DefId` refers to.
|
||||
|
|
|
|||
|
|
@ -1295,7 +1295,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
|
|||
.iter()
|
||||
.map(|&cnum| {
|
||||
let dep = CrateDep {
|
||||
name: cstore.original_crate_name(cnum),
|
||||
name: self.tcx.original_crate_name(cnum),
|
||||
hash: self.tcx.crate_hash(cnum),
|
||||
kind: cstore.dep_kind(cnum),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
continue // These are `krate.exported_macros`, handled in `self.visit()`.
|
||||
}
|
||||
|
||||
let imported_from = self.cx.sess().cstore.original_crate_name(def_id.krate);
|
||||
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()) {
|
||||
LoadedMacro::MacroDef(macro_def) => macro_def,
|
||||
// FIXME(jseyfried): document proc macro reexports
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue