-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Allow to feed a value in another query's cache #104940
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
(rustbot has picked a reviewer for you, use r? to override) |
r? rust-lang/compiler |
bb97d32
to
984620e
Compare
This comment was marked as outdated.
This comment was marked as outdated.
debug_assert_eq!( | ||
old_hash, new_hash, | ||
"Computed query value for {:?}({:?}) is inconsistent with fed value,\ncomputed={:#?}\nfed={:#?}", | ||
query.dep_kind, key, result, cached_result, | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still convinced it should be an ICE to be able to compute the value of a query that is also fed for that key.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a priority, so if it is hard to check properly, don't.
Overall design lgtm. r=me with at least the |
908577a
to
6477fd8
Compare
@bors r+ |
☀️ Test successful - checks-actions |
Finished benchmarking commit (c97b539): comparison URL. Overall result: ❌ regressions - ACTION NEEDEDNext Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. |
The regression seems to be entirely covered by
everything else is just inlining back and forth Here's a second one with different magnitude but same relative regression:
|
Visiting for weekly perf triage
@rustbot label: +perf-regression-triaged |
👋 Could this be used to inject custom trait impls in a custom driver? Specifically, I'm looking to add impls to anonymous types like closures. I was thinking of doing it by creating a fresh defid and using it to manually build a trait impl for the relevant trait and closure. I'm not sure if there are any limitations to |
Only the query creating a new DefId is allowed to feed other queries on the DefId. In addition only queries explicitly marked as feedable are feedable. And finally there are some other restrictions to prevent miscompilations I believe. Adding impls requires manipulating the HIR afaik, which is supposed to be immutable. There is also the complication that adding a trait impl requires knowing the closure type, which requires running typeck, which requires knowing all trait impls I believe. I think you would be able to implement it using a rustc fork. I'm not sure a custom driver is enough. |
Thanks for the explanation, that's disappointing to hear, I don't have the manpower to maintain a fork and keep it up to date, my driver is already enough work. I'll just keep all my ugly special-casing hacks and impls instead. |
Maybe overriding some of the queries related to trait selection like |
Restricted version of #96840
A query can create new definitions.
If those definitions are created after HIR lowering, they do not appear in the initial HIR map, and information for them cannot be provided in the normal pull-based way.
In order to make those definitions useful, we allow to feed values as query results for the newly created definition.
The API is as follows:
This PR keeps the consistency checks introduced by #96840, even if they are not reachable. This allows to extend the behaviour later without forgetting them.
cc @oli-obk @spastorino