Files
rust/compiler/rustc_hir
Jonathan Brouwer 49e2983d6d Rollup merge of #153582 - mehdiakiki:simplify-find-attr-hir-id, r=JonathanBrouwer
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.

Before:
  `find_attr!(tcx.hir_attrs(hir_id), SomeAttr)`

After:
  `find_attr!(tcx, hir_id, SomeAttr)`

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`.

Fixes https://github.com/rust-lang/rust/issues/153103
2026-03-23 12:14:56 +01:00
..
2025-12-05 14:22:52 +01:00