Skip to content

Commit 2d4445f

Browse files
committed
rustc: Move {plugin,derive}_registrar_fn to queries
1 parent 205bc9a commit 2d4445f

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
@@ -537,6 +537,8 @@ define_dep_nodes!( <'tcx>
537537
[] ImplDefaultness(DefId),
538538
[] ExportedSymbols(CrateNum),
539539
[] NativeLibraries(CrateNum),
540+
[] PluginRegistrarFn(CrateNum),
541+
[] DeriveRegistrarFn(CrateNum),
540542
);
541543

542544
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
@@ -599,6 +599,18 @@ impl<'tcx> QueryDescription for queries::native_libraries<'tcx> {
599599
}
600600
}
601601

602+
impl<'tcx> QueryDescription for queries::plugin_registrar_fn<'tcx> {
603+
fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
604+
format!("looking up the plugin registrar for a crate")
605+
}
606+
}
607+
608+
impl<'tcx> QueryDescription for queries::derive_registrar_fn<'tcx> {
609+
fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
610+
format!("looking up the derive registrar for a crate")
611+
}
612+
}
613+
602614
// If enabled, send a message to the profile-queries thread
603615
macro_rules! profq_msg {
604616
($tcx:expr, $msg:expr) => {
@@ -1177,6 +1189,8 @@ define_maps! { <'tcx>
11771189
[] fn impl_defaultness: ImplDefaultness(DefId) -> hir::Defaultness,
11781190
[] fn exported_symbols: ExportedSymbols(CrateNum) -> Rc<Vec<DefId>>,
11791191
[] fn native_libraries: NativeLibraries(CrateNum) -> Rc<Vec<NativeLibrary>>,
1192+
[] fn plugin_registrar_fn: PluginRegistrarFn(CrateNum) -> Option<DefId>,
1193+
[] fn derive_registrar_fn: DeriveRegistrarFn(CrateNum) -> Option<DefId>,
11801194
}
11811195

11821196
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
@@ -1064,7 +1064,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PluginAsLibrary {
10641064
};
10651065

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

src/librustc_metadata/cstore_impl.rs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,16 @@ provide! { <'tcx> tcx, def_id, cdata,
165165
impl_defaultness => { cdata.get_impl_defaultness(def_id.index) }
166166
exported_symbols => { Rc::new(cdata.get_exported_symbols(&tcx.dep_graph)) }
167167
native_libraries => { Rc::new(cdata.get_native_libraries(&tcx.dep_graph)) }
168+
plugin_registrar_fn => {
169+
cdata.root.plugin_registrar_fn.map(|index| {
170+
DefId { krate: def_id.krate, index }
171+
})
172+
}
173+
derive_registrar_fn => {
174+
cdata.root.macro_derive_registrar.map(|index| {
175+
DefId { krate: def_id.krate, index }
176+
})
177+
}
168178
}
169179

170180
pub fn provide_local<'tcx>(providers: &mut Providers<'tcx>) {
@@ -283,22 +293,6 @@ impl CrateStore for cstore::CStore {
283293
self.get_crate_data(cnum).disambiguator()
284294
}
285295

286-
fn plugin_registrar_fn(&self, cnum: CrateNum) -> Option<DefId>
287-
{
288-
self.get_crate_data(cnum).root.plugin_registrar_fn.map(|index| DefId {
289-
krate: cnum,
290-
index,
291-
})
292-
}
293-
294-
fn derive_registrar_fn(&self, cnum: CrateNum) -> Option<DefId>
295-
{
296-
self.get_crate_data(cnum).root.macro_derive_registrar.map(|index| DefId {
297-
krate: cnum,
298-
index,
299-
})
300-
}
301-
302296
/// Returns the `DefKey` for a given `DefId`. This indicates the
303297
/// parent `DefId` as well as some idea of what kind of data the
304298
/// `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)