rustc: Move {plugin,derive}_registrar_fn to queries
This commit is contained in:
parent
205bc9a80a
commit
2d4445f784
6 changed files with 29 additions and 25 deletions
|
|
@ -537,6 +537,8 @@ define_dep_nodes!( <'tcx>
|
|||
[] ImplDefaultness(DefId),
|
||||
[] ExportedSymbols(CrateNum),
|
||||
[] NativeLibraries(CrateNum),
|
||||
[] PluginRegistrarFn(CrateNum),
|
||||
[] DeriveRegistrarFn(CrateNum),
|
||||
);
|
||||
|
||||
trait DepNodeParams<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> : fmt::Debug {
|
||||
|
|
|
|||
|
|
@ -255,8 +255,6 @@ pub trait CrateStore {
|
|||
fn original_crate_name(&self, cnum: CrateNum) -> Symbol;
|
||||
fn crate_hash(&self, cnum: CrateNum) -> Svh;
|
||||
fn crate_disambiguator(&self, cnum: CrateNum) -> Symbol;
|
||||
fn plugin_registrar_fn(&self, cnum: CrateNum) -> Option<DefId>;
|
||||
fn derive_registrar_fn(&self, cnum: CrateNum) -> Option<DefId>;
|
||||
|
||||
// resolve
|
||||
fn def_key(&self, def: DefId) -> DefKey;
|
||||
|
|
@ -359,10 +357,6 @@ impl CrateStore for DummyCrateStore {
|
|||
fn crate_hash(&self, cnum: CrateNum) -> Svh { bug!("crate_hash") }
|
||||
fn crate_disambiguator(&self, cnum: CrateNum)
|
||||
-> Symbol { bug!("crate_disambiguator") }
|
||||
fn plugin_registrar_fn(&self, cnum: CrateNum) -> Option<DefId>
|
||||
{ bug!("plugin_registrar_fn") }
|
||||
fn derive_registrar_fn(&self, cnum: CrateNum) -> Option<DefId>
|
||||
{ bug!("derive_registrar_fn") }
|
||||
|
||||
// resolve
|
||||
fn def_key(&self, def: DefId) -> DefKey { bug!("def_key") }
|
||||
|
|
|
|||
|
|
@ -599,6 +599,18 @@ impl<'tcx> QueryDescription for queries::native_libraries<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> QueryDescription for queries::plugin_registrar_fn<'tcx> {
|
||||
fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
|
||||
format!("looking up the plugin registrar for a crate")
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> QueryDescription for queries::derive_registrar_fn<'tcx> {
|
||||
fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
|
||||
format!("looking up the derive registrar for a crate")
|
||||
}
|
||||
}
|
||||
|
||||
// If enabled, send a message to the profile-queries thread
|
||||
macro_rules! profq_msg {
|
||||
($tcx:expr, $msg:expr) => {
|
||||
|
|
@ -1177,6 +1189,8 @@ define_maps! { <'tcx>
|
|||
[] fn impl_defaultness: ImplDefaultness(DefId) -> hir::Defaultness,
|
||||
[] fn exported_symbols: ExportedSymbols(CrateNum) -> Rc<Vec<DefId>>,
|
||||
[] fn native_libraries: NativeLibraries(CrateNum) -> Rc<Vec<NativeLibrary>>,
|
||||
[] fn plugin_registrar_fn: PluginRegistrarFn(CrateNum) -> Option<DefId>,
|
||||
[] fn derive_registrar_fn: DeriveRegistrarFn(CrateNum) -> Option<DefId>,
|
||||
}
|
||||
|
||||
fn type_param_predicates<'tcx>((item_id, param_id): (DefId, DefId)) -> DepConstructor<'tcx> {
|
||||
|
|
|
|||
|
|
@ -1064,7 +1064,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PluginAsLibrary {
|
|||
};
|
||||
|
||||
let prfn = match cx.sess().cstore.extern_mod_stmt_cnum(it.id) {
|
||||
Some(cnum) => cx.sess().cstore.plugin_registrar_fn(cnum),
|
||||
Some(cnum) => cx.tcx.plugin_registrar_fn(cnum),
|
||||
None => {
|
||||
// Probably means we aren't linking the crate for some reason.
|
||||
//
|
||||
|
|
|
|||
|
|
@ -165,6 +165,16 @@ provide! { <'tcx> tcx, def_id, cdata,
|
|||
impl_defaultness => { cdata.get_impl_defaultness(def_id.index) }
|
||||
exported_symbols => { Rc::new(cdata.get_exported_symbols(&tcx.dep_graph)) }
|
||||
native_libraries => { Rc::new(cdata.get_native_libraries(&tcx.dep_graph)) }
|
||||
plugin_registrar_fn => {
|
||||
cdata.root.plugin_registrar_fn.map(|index| {
|
||||
DefId { krate: def_id.krate, index }
|
||||
})
|
||||
}
|
||||
derive_registrar_fn => {
|
||||
cdata.root.macro_derive_registrar.map(|index| {
|
||||
DefId { krate: def_id.krate, index }
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub fn provide_local<'tcx>(providers: &mut Providers<'tcx>) {
|
||||
|
|
@ -283,22 +293,6 @@ impl CrateStore for cstore::CStore {
|
|||
self.get_crate_data(cnum).disambiguator()
|
||||
}
|
||||
|
||||
fn plugin_registrar_fn(&self, cnum: CrateNum) -> Option<DefId>
|
||||
{
|
||||
self.get_crate_data(cnum).root.plugin_registrar_fn.map(|index| DefId {
|
||||
krate: cnum,
|
||||
index,
|
||||
})
|
||||
}
|
||||
|
||||
fn derive_registrar_fn(&self, cnum: CrateNum) -> Option<DefId>
|
||||
{
|
||||
self.get_crate_data(cnum).root.macro_derive_registrar.map(|index| DefId {
|
||||
krate: cnum,
|
||||
index,
|
||||
})
|
||||
}
|
||||
|
||||
/// 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.
|
||||
|
|
|
|||
|
|
@ -115,8 +115,8 @@ impl ExportedSymbols {
|
|||
|
||||
// If this crate is a plugin and/or a custom derive crate, then
|
||||
// we're not even going to link those in so we skip those crates.
|
||||
if tcx.sess.cstore.plugin_registrar_fn(cnum).is_some() ||
|
||||
tcx.sess.cstore.derive_registrar_fn(cnum).is_some() {
|
||||
if tcx.plugin_registrar_fn(cnum).is_some() ||
|
||||
tcx.derive_registrar_fn(cnum).is_some() {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue