Simplify find_attr! for HirId usage#153582
Conversation
|
Some changes occurred to the CTFE machinery Some changes occurred in src/tools/clippy cc @rust-lang/clippy Some changes occurred in compiler/rustc_hir/src/attrs |
|
r? @mati865 rustbot has assigned @mati865. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
ff3c7f6 to
e9a9d24
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
r? JonathanBrouwer |
Sure Jonathan, I will do that tomorrow! |
e9a9d24 to
896da64
Compare
This comment has been minimized.
This comment has been minimized.
|
please remove issue links from commit message as warning above suggests |
|
@rustbot author |
|
Reminder, once the PR becomes ready for a review, use |
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.
896da64 to
858b82d
Compare
|
@rustbot ready |
…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 rust-lang#153103
…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 rust-lang#153103
Rollup of 9 pull requests Successful merges: - #122668 (Add APIs for dealing with titlecase) - #153312 (Packages as namespaces part 1) - #153534 (Remove a flaky `got_timeout` assert from two channel tests) - #153582 (Simplify find_attr! for HirId usage) - #154174 (allow `incomplete_features` in most UI tests) - #154175 (Add new alias for Guillaume Gomez email address) - #154182 (diagnostics: avoid ICE for undeclared generic parameter in impl) - #154188 (Update the tracking issue for #[diagnostic::on_move]) - #154201 (Use enums to clarify `DepNodeColorMap` color marking )
Add a
HasAttrs<'tcx, Tcx>trait torustc_hirthat allowsfind_attr!to acceptDefId,LocalDefId,OwnerId, andHirIddirectly, 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_hirwith a genericTcxparameter to avoid a dependency cycle (rustc_hircannot depend onrustc_middle). The four concrete impls forTyCtxtare inrustc_middle.Fixes #153103