
The end goal is to eliminate `Map` altogether. I added a `hir_` prefix to all of them, that seemed simplest. The exceptions are `module_items` which became `hir_module_free_items` because there was already a `hir_module_items`, and `items` which became `hir_free_items` for consistency with `hir_module_free_items`.
22 lines
602 B
Rust
22 lines
602 B
Rust
use rustc_ast::attr;
|
|
use rustc_hir::def_id::LocalDefId;
|
|
use rustc_middle::query::Providers;
|
|
use rustc_middle::ty::TyCtxt;
|
|
use rustc_span::sym;
|
|
|
|
fn proc_macro_decls_static(tcx: TyCtxt<'_>, (): ()) -> Option<LocalDefId> {
|
|
let mut decls = None;
|
|
|
|
for id in tcx.hir_free_items() {
|
|
let attrs = tcx.hir().attrs(id.hir_id());
|
|
if attr::contains_name(attrs, sym::rustc_proc_macro_decls) {
|
|
decls = Some(id.owner_id.def_id);
|
|
}
|
|
}
|
|
|
|
decls
|
|
}
|
|
|
|
pub(crate) fn provide(providers: &mut Providers) {
|
|
*providers = Providers { proc_macro_decls_static, ..*providers };
|
|
}
|