Skip to content

Commit 5f343a5

Browse files
committed
rustc: Move {plugin,derive}_registrar_fn to queries
1 parent 1eb49a9 commit 5f343a5

File tree

6 files changed

+29
-25
lines changed

6 files changed

+29
-25
lines changed

src/librustc/dep_graph/dep_node.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,8 @@ define_dep_nodes!( <'tcx>
533533
[] ImplDefaultness(DefId),
534534
[] ExportedSymbols(CrateNum),
535535
[] NativeLibraries(CrateNum),
536+
[] PluginRegistrarFn(CrateNum),
537+
[] DeriveRegistrarFn(CrateNum),
536538
);
537539

538540
trait DepNodeParams<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> : fmt::Debug {

src/librustc/middle/cstore.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,6 @@ pub trait CrateStore {
255255
fn original_crate_name(&self, cnum: CrateNum) -> Symbol;
256256
fn crate_hash(&self, cnum: CrateNum) -> Svh;
257257
fn crate_disambiguator(&self, cnum: CrateNum) -> Symbol;
258-
fn plugin_registrar_fn(&self, cnum: CrateNum) -> Option<DefId>;
259-
fn derive_registrar_fn(&self, cnum: CrateNum) -> Option<DefId>;
260258

261259
// resolve
262260
fn def_key(&self, def: DefId) -> DefKey;
@@ -359,10 +357,6 @@ impl CrateStore for DummyCrateStore {
359357
fn crate_hash(&self, cnum: CrateNum) -> Svh { bug!("crate_hash") }
360358
fn crate_disambiguator(&self, cnum: CrateNum)
361359
-> Symbol { bug!("crate_disambiguator") }
362-
fn plugin_registrar_fn(&self, cnum: CrateNum) -> Option<DefId>
363-
{ bug!("plugin_registrar_fn") }
364-
fn derive_registrar_fn(&self, cnum: CrateNum) -> Option<DefId>
365-
{ bug!("derive_registrar_fn") }
366360

367361
// resolve
368362
fn def_key(&self, def: DefId) -> DefKey { bug!("def_key") }

src/librustc/ty/maps.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,18 @@ impl<'tcx> QueryDescription for queries::native_libraries<'tcx> {
571571
}
572572
}
573573

574+
impl<'tcx> QueryDescription for queries::plugin_registrar_fn<'tcx> {
575+
fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
576+
format!("looking up the plugin registrar for a crate")
577+
}
578+
}
579+
580+
impl<'tcx> QueryDescription for queries::derive_registrar_fn<'tcx> {
581+
fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
582+
format!("looking up the derive registrar for a crate")
583+
}
584+
}
585+
574586
// If enabled, send a message to the profile-queries thread
575587
macro_rules! profq_msg {
576588
($tcx:expr, $msg:expr) => {
@@ -1146,6 +1158,8 @@ define_maps! { <'tcx>
11461158
[] impl_defaultness: ImplDefaultness(DefId) -> hir::Defaultness,
11471159
[] exported_symbols: ExportedSymbols(CrateNum) -> Rc<Vec<DefId>>,
11481160
[] native_libraries: NativeLibraries(CrateNum) -> Rc<Vec<NativeLibrary>>,
1161+
[] plugin_registrar_fn: PluginRegistrarFn(CrateNum) -> Option<DefId>,
1162+
[] derive_registrar_fn: DeriveRegistrarFn(CrateNum) -> Option<DefId>,
11491163
}
11501164

11511165
fn type_param_predicates<'tcx>((item_id, param_id): (DefId, DefId)) -> DepConstructor<'tcx> {

src/librustc_lint/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PluginAsLibrary {
10601060
};
10611061

10621062
let prfn = match cx.sess().cstore.extern_mod_stmt_cnum(it.id) {
1063-
Some(cnum) => cx.sess().cstore.plugin_registrar_fn(cnum),
1063+
Some(cnum) => cx.tcx.plugin_registrar_fn(cnum),
10641064
None => {
10651065
// Probably means we aren't linking the crate for some reason.
10661066
//

src/librustc_metadata/cstore_impl.rs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,16 @@ provide! { <'tcx> tcx, def_id, cdata,
162162
impl_defaultness => { cdata.get_impl_defaultness(def_id.index) }
163163
exported_symbols => { Rc::new(cdata.get_exported_symbols(&tcx.dep_graph)) }
164164
native_libraries => { Rc::new(cdata.get_native_libraries(&tcx.dep_graph)) }
165+
plugin_registrar_fn => {
166+
cdata.root.plugin_registrar_fn.map(|index| {
167+
DefId { krate: def_id.krate, index }
168+
})
169+
}
170+
derive_registrar_fn => {
171+
cdata.root.macro_derive_registrar.map(|index| {
172+
DefId { krate: def_id.krate, index }
173+
})
174+
}
165175
}
166176

167177
pub fn provide_local<'tcx>(providers: &mut Providers<'tcx>) {
@@ -280,22 +290,6 @@ impl CrateStore for cstore::CStore {
280290
self.get_crate_data(cnum).disambiguator()
281291
}
282292

283-
fn plugin_registrar_fn(&self, cnum: CrateNum) -> Option<DefId>
284-
{
285-
self.get_crate_data(cnum).root.plugin_registrar_fn.map(|index| DefId {
286-
krate: cnum,
287-
index,
288-
})
289-
}
290-
291-
fn derive_registrar_fn(&self, cnum: CrateNum) -> Option<DefId>
292-
{
293-
self.get_crate_data(cnum).root.macro_derive_registrar.map(|index| DefId {
294-
krate: cnum,
295-
index,
296-
})
297-
}
298-
299293
/// Returns the `DefKey` for a given `DefId`. This indicates the
300294
/// parent `DefId` as well as some idea of what kind of data the
301295
/// `DefId` refers to.

src/librustc_trans/back/symbol_export.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ impl ExportedSymbols {
115115

116116
// If this crate is a plugin and/or a custom derive crate, then
117117
// we're not even going to link those in so we skip those crates.
118-
if tcx.sess.cstore.plugin_registrar_fn(cnum).is_some() ||
119-
tcx.sess.cstore.derive_registrar_fn(cnum).is_some() {
118+
if tcx.plugin_registrar_fn(cnum).is_some() ||
119+
tcx.derive_registrar_fn(cnum).is_some() {
120120
continue;
121121
}
122122

0 commit comments

Comments
 (0)