Use () for proc_macro_decls_static.
This commit is contained in:
parent
e9e1900af7
commit
b7bf467fa3
7 changed files with 11 additions and 23 deletions
|
@ -133,8 +133,8 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, cnum: CrateNum) -> DefIdMap<
|
|||
})
|
||||
.collect();
|
||||
|
||||
if let Some(id) = tcx.proc_macro_decls_static(LOCAL_CRATE) {
|
||||
reachable_non_generics.insert(id, SymbolExportLevel::C);
|
||||
if let Some(id) = tcx.proc_macro_decls_static(()) {
|
||||
reachable_non_generics.insert(id.to_def_id(), SymbolExportLevel::C);
|
||||
}
|
||||
|
||||
if let Some(id) = tcx.plugin_registrar_fn(()) {
|
||||
|
|
|
@ -824,7 +824,9 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> {
|
|||
|
||||
sess.time("looking_for_plugin_registrar", || tcx.ensure().plugin_registrar_fn(()));
|
||||
|
||||
sess.time("looking_for_derive_registrar", || proc_macro_decls::find(tcx));
|
||||
sess.time("looking_for_derive_registrar", || {
|
||||
tcx.ensure().proc_macro_decls_static(())
|
||||
});
|
||||
|
||||
let cstore = tcx
|
||||
.cstore_as_any()
|
||||
|
|
|
@ -1,21 +1,15 @@
|
|||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
|
||||
use rustc_hir::def_id::LocalDefId;
|
||||
use rustc_hir::itemlikevisit::ItemLikeVisitor;
|
||||
use rustc_middle::ty::query::Providers;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_span::symbol::sym;
|
||||
|
||||
pub fn find(tcx: TyCtxt<'_>) -> Option<DefId> {
|
||||
tcx.proc_macro_decls_static(LOCAL_CRATE)
|
||||
}
|
||||
|
||||
fn proc_macro_decls_static(tcx: TyCtxt<'_>, cnum: CrateNum) -> Option<DefId> {
|
||||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
|
||||
fn proc_macro_decls_static(tcx: TyCtxt<'_>, (): ()) -> Option<LocalDefId> {
|
||||
let mut finder = Finder { tcx, decls: None };
|
||||
tcx.hir().krate().visit_all_item_likes(&mut finder);
|
||||
|
||||
finder.decls.map(|id| tcx.hir().local_def_id(id).to_def_id())
|
||||
finder.decls.map(|id| tcx.hir().local_def_id(id))
|
||||
}
|
||||
|
||||
struct Finder<'tcx> {
|
||||
|
|
|
@ -185,14 +185,6 @@ provide! { <'tcx> tcx, def_id, other, cdata,
|
|||
}
|
||||
native_libraries => { Lrc::new(cdata.get_native_libraries(tcx.sess)) }
|
||||
foreign_modules => { cdata.get_foreign_modules(tcx) }
|
||||
proc_macro_decls_static => {
|
||||
cdata.root.proc_macro_data.as_ref().map(|data| {
|
||||
DefId {
|
||||
krate: def_id.krate,
|
||||
index: data.proc_macro_decls_static,
|
||||
}
|
||||
})
|
||||
}
|
||||
crate_disambiguator => { cdata.root.disambiguator }
|
||||
crate_hash => { cdata.root.hash }
|
||||
crate_host_hash => { cdata.host_hash }
|
||||
|
|
|
@ -1575,7 +1575,7 @@ impl EncodeContext<'a, 'tcx> {
|
|||
let tcx = self.tcx;
|
||||
let hir = tcx.hir();
|
||||
|
||||
let proc_macro_decls_static = tcx.proc_macro_decls_static(LOCAL_CRATE).unwrap().index;
|
||||
let proc_macro_decls_static = tcx.proc_macro_decls_static(()).unwrap().local_def_index;
|
||||
let stability = tcx.lookup_stability(DefId::local(CRATE_DEF_INDEX)).copied();
|
||||
let macros = self.lazy(hir.krate().proc_macros.iter().map(|p| p.owner.local_def_index));
|
||||
let spans = self.tcx.sess.parse_sess.proc_macro_quoted_spans();
|
||||
|
|
|
@ -1207,7 +1207,7 @@ rustc_queries! {
|
|||
query plugin_registrar_fn(_: ()) -> Option<LocalDefId> {
|
||||
desc { "looking up the plugin registrar for a crate" }
|
||||
}
|
||||
query proc_macro_decls_static(_: CrateNum) -> Option<DefId> {
|
||||
query proc_macro_decls_static(_: ()) -> Option<LocalDefId> {
|
||||
desc { "looking up the derive registrar for a crate" }
|
||||
}
|
||||
query crate_disambiguator(_: CrateNum) -> CrateDisambiguator {
|
||||
|
|
|
@ -169,7 +169,7 @@ fn compute_symbol_name(
|
|||
let disambiguator = tcx.sess.local_crate_disambiguator();
|
||||
return tcx.sess.generate_plugin_registrar_symbol(disambiguator);
|
||||
}
|
||||
if tcx.proc_macro_decls_static(LOCAL_CRATE) == Some(def_id.to_def_id()) {
|
||||
if tcx.proc_macro_decls_static(()) == Some(def_id) {
|
||||
let disambiguator = tcx.sess.local_crate_disambiguator();
|
||||
return tcx.sess.generate_proc_macro_decls_symbol(disambiguator);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue