rust/compiler/rustc_interface/src/proc_macro_decls.rs
Nicholas Nethercote 256c27e748 Move methods from Map to TyCtxt, part 4.
Continuing the work from #137350.

Removes the unused methods: `expect_variant`, `expect_field`,
`expect_foreign_item`.

Every method gains a `hir_` prefix.
2025-03-12 08:55:37 +11:00

23 lines
600 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 };
}