]> git.lizzy.rs Git - rust.git/commitdiff
rustc: Move {plugin,derive}_registrar_fn to queries
authorAlex Crichton <alex@alexcrichton.com>
Tue, 29 Aug 2017 00:30:27 +0000 (17:30 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Tue, 5 Sep 2017 14:37:11 +0000 (07:37 -0700)
src/librustc/dep_graph/dep_node.rs
src/librustc/middle/cstore.rs
src/librustc/ty/maps.rs
src/librustc_lint/builtin.rs
src/librustc_metadata/cstore_impl.rs
src/librustc_trans/back/symbol_export.rs

index cb5680956bbda8dc6eea9e6f51a17373d2aa4e0d..76f31eb5596e2a26e2d636d616c5ef3f6e0fd490 100644 (file)
@@ -537,6 +537,8 @@ pub fn to_dep_node(self, tcx: TyCtxt, kind: DepKind) -> DepNode {
     [] ImplDefaultness(DefId),
     [] ExportedSymbols(CrateNum),
     [] NativeLibraries(CrateNum),
+    [] PluginRegistrarFn(CrateNum),
+    [] DeriveRegistrarFn(CrateNum),
 );
 
 trait DepNodeParams<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> : fmt::Debug {
index edc046a1225078da48ebdd6e219b08747e182eeb..9294530f5152ef994367c767d2d99e8454c1bb14 100644 (file)
@@ -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 @@ fn original_crate_name(&self, cnum: CrateNum) -> Symbol {
     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") }
index c8ec111828e3a50aae545eb93b317716bbb85d30..31a1f9aee4e3d35525b6d7e3c31d323720966393 100644 (file)
@@ -599,6 +599,18 @@ fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
     }
 }
 
+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 @@ fn default() -> Self {
     [] 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> {
index 780d34d570170247f5faf8ffb64114afa02f52cd..27ee8fd5cddba796038ae849b329d8caed84f710 100644 (file)
@@ -1064,7 +1064,7 @@ fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
         };
 
         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.
                 //
index 537154b4a4cac30354aa590767f3235d3d3577f1..842335212eed60e216e3d364ae4c4590cecebedb 100644 (file)
@@ -165,6 +165,16 @@ fn into_def_id(self) -> DefId { self.as_def_id() }
     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 @@ fn crate_disambiguator(&self, cnum: CrateNum) -> Symbol
         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.
index f1b18c64dcb94ef46947434d331f93f63e8f55d3..68f30b589c2c504f29fa7976b00cd4d5ab16870a 100644 (file)
@@ -115,8 +115,8 @@ pub fn compute<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 
             // 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;
             }