Skip to content

Conversation

Zalathar
Copy link
Contributor

@Zalathar Zalathar commented Oct 6, 2025

This PR extracts most of the non-trivial code from the define_feedable! macro (which defines the TyCtxtFeed::$query methods), and moves it to a helper function query_feed_inner written in ordinary non-macro code.

Doing so should make that code easier to read and modify, because it now gets proper IDE support and has explicit trait bounds.


There should be no change in compiler behaviour.

I've structured the commits so that the actual extraction part is mostly just whitespace changes, making it easier to review individually with whitespace changes hidden.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 6, 2025
@rustbot
Copy link
Collaborator

rustbot commented Oct 6, 2025

r? @jackh726

rustbot has assigned @jackh726.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@Zalathar Zalathar changed the title Extract most code from define_feedable! Extract most code from define_feedable! Oct 6, 2025
@Zalathar
Copy link
Contributor Author

Zalathar commented Oct 6, 2025

No perf changes intended, but let's check:

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Oct 6, 2025
Extract most code from `define_feedable!`
@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 6, 2025
@rust-bors
Copy link

rust-bors bot commented Oct 6, 2025

☀️ Try build successful (CI)
Build commit: b135ecc (b135ecc5b5ca9773965d5c7368568e9fe2f0f49c, parent: 1a3cdd34629306fa67624eaa60d73687e7fcf855)

@rust-timer

This comment has been minimized.

}

/// Common implementation of query feeding, used by `define_feedable!`.
pub(crate) fn query_feed_inner<'tcx, Cache, Value>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you put this closer to query_get_at and co? It serves a similar purpose.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, the downside would be that it's no longer adjacent to the calling code in define_feedable!, so coordinated changes to both would be much less convenient.

I can move it if you want, but to me it seems better off here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another approach would be to move the entire family of query-method-inner functions into their own file.

That would allow them to be kept together, without getting lost in a sea of boilerplate macros in query::plumbing.

/// Common implementation of query feeding, used by `define_feedable!`.
pub(crate) fn query_feed_inner<'tcx, Cache, Value>(
tcx: TyCtxt<'tcx>,
name: &'static str,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be recoverable from dep_kind in a panic message.

Copy link
Contributor Author

@Zalathar Zalathar Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, via tcx.dep_kind_info(dep_kind).name? That should be easy enough.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Or using Debug for DepKind which uses it internally. It's for ICEs anyway.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (b135ecc): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results (primary -7.0%, secondary -5.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-7.0% [-8.3%, -5.6%] 2
Improvements ✅
(secondary)
-5.7% [-5.7%, -5.7%] 1
All ❌✅ (primary) -7.0% [-8.3%, -5.6%] 2

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 471.633s -> 471.589s (-0.01%)
Artifact size: 388.34 MiB -> 388.35 MiB (0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 6, 2025
@jackh726
Copy link
Member

jackh726 commented Oct 6, 2025

r? @cjgillot

Seems you probably are a better reviewer for this PR.

@rustbot
Copy link
Collaborator

rustbot commented Oct 8, 2025

This PR was rebased onto a different master 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.

@cjgillot
Copy link
Contributor

Thanks!
@bors r+

@bors
Copy link
Collaborator

bors commented Oct 11, 2025

📌 Commit a282336 has been approved by cjgillot

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 11, 2025
@Zalathar
Copy link
Contributor Author

Perf results were neutral, so this should be fine for rollup.

@bors rollup=maybe

Zalathar added a commit to Zalathar/rust that referenced this pull request Oct 12, 2025
Extract most code from `define_feedable!`

This PR extracts most of the non-trivial code from the `define_feedable!` macro (which defines the `TyCtxtFeed::$query` methods), and moves it to a helper function `query_feed_inner` written in ordinary non-macro code.

Doing so should make that code easier to read and modify, because it now gets proper IDE support and has explicit trait bounds.

---

There should be no change in compiler behaviour.

I've structured the commits so that the actual extraction part is mostly just whitespace changes, making it easier to review individually with whitespace changes hidden.
bors added a commit that referenced this pull request Oct 12, 2025
Rollup of 12 pull requests

Successful merges:

 - #138799 (core: simplify `Extend` for tuples)
 - #146692 (Save x.py's help text for saving output time)
 - #147168 (Don't unconditionally build alloc for `no-std` targets)
 - #147178 ([DebugInfo] Improve formatting of MSVC enum struct variants)
 - #147240 (Add an ACP list item to the library tracking issue template)
 - #147246 (Explain not existed key in BTreeMap::split_off)
 - #147393 (Extract most code from `define_feedable!`)
 - #147495 (Update wasm-component-ld to 0.5.18)
 - #147503 (Fix documentation of Instant::now on mac)
 - #147541 (Change int-to-ptr transmute lowering back to inttoptr)
 - #147549 (Replace `LLVMRustContextCreate` with normal LLVM-C API calls)
 - #147596 (Adjust the Arm targets in CI to reflect latest changes)

r? `@ghost`
`@rustbot` modify labels: rollup
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 12, 2025
Extract most code from `define_feedable!`

This PR extracts most of the non-trivial code from the `define_feedable!` macro (which defines the `TyCtxtFeed::$query` methods), and moves it to a helper function `query_feed_inner` written in ordinary non-macro code.

Doing so should make that code easier to read and modify, because it now gets proper IDE support and has explicit trait bounds.

---

There should be no change in compiler behaviour.

I've structured the commits so that the actual extraction part is mostly just whitespace changes, making it easier to review individually with whitespace changes hidden.
bors added a commit that referenced this pull request Oct 12, 2025
Rollup of 8 pull requests

Successful merges:

 - #138799 (core: simplify `Extend` for tuples)
 - #145897 (Rehome 30 `tests/ui/issues/` tests to other subdirectories under `tests/ui/` [#4 of Batch #2])
 - #146692 (Save x.py's help text for saving output time)
 - #147240 (Add an ACP list item to the library tracking issue template)
 - #147246 (Explain not existed key in BTreeMap::split_off)
 - #147393 (Extract most code from `define_feedable!`)
 - #147503 (Fix documentation of Instant::now on mac)
 - #147549 (Replace `LLVMRustContextCreate` with normal LLVM-C API calls)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants