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.

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

@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 rustbot assigned cjgillot and unassigned jackh726 Oct 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants