mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Simplify find_attr! for HirId usage
Add a HasAttrs<'tcx, Tcx> trait to rustc_hir that allows find_attr! to accept DefId, LocalDefId, OwnerId, and HirId directly, instead of requiring callers to manually fetch the attribute slice first. The trait is defined in rustc_hir with a generic Tcx parameter to avoid a dependency cycle (rustc_hir cannot depend on rustc_middle). The four concrete impls for TyCtxt are in rustc_middle.
This commit is contained in:
@@ -7,7 +7,7 @@ fn proc_macro_decls_static(tcx: TyCtxt<'_>, (): ()) -> Option<LocalDefId> {
|
||||
let mut decls = None;
|
||||
|
||||
for id in tcx.hir_free_items() {
|
||||
if find_attr!(tcx.hir_attrs(id.hir_id()), RustcProcMacroDecls) {
|
||||
if find_attr!(tcx, id.hir_id(), RustcProcMacroDecls) {
|
||||
decls = Some(id.owner_id.def_id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user