-
Notifications
You must be signed in to change notification settings - Fork 13.5k
compiler: Document and reduce fn provide
s in hir crates
#143394
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
base: master
Are you sure you want to change the base?
compiler: Document and reduce fn provide
s in hir crates
#143394
Conversation
r? @spastorino rustbot has assigned @spastorino. Use |
It might also be the case that the inlining should be reversed until there are no more individual queries being assigned in the root |
0bcd31a
to
1ac1d83
Compare
fn provide
sfn provide
s in hir crates
fn provide
s in hir cratesfn provide
s in hir crates
There was one other one in |
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.
should probably pluralize the direct object in "Adds query fn to the [...]", since rn is a bit awkward, but I prefer "query implementations" bc that's more descriptive.
Update the comments, then r=me |
Also please squash all the inlining commits, since they kinda all do the same thing |
Many small indirections with 1-2 items actively hinders understanding. Inlines various tiny submodule provides into - hir_analysis::provide - hir_analysis::check::provide - hir_typeck::provide
1ac1d83
to
3b7f9f9
Compare
Done~ |
thanks @bors r+ rollup |
I found it hard to follow all these tiny micro-indirections. Much like you shouldn't pass around
&u32
if you can help it, you probably shouldn't use an indirection if the indirection overhead itself is literally bigger than the amount of data you are organizing. Generally a newfn provide
amounts to around 3 LOC:rustc_middle::query::Providers
importI am not even counting the cost in time and thought to go find the other
provide
, read it, understand, "Ah, yes, these functions", and then go to those. Thus I say we should collapse indirections ofprovide
for modules that only export 1~2 queries. For higher-count indirections, I left them as-is, as I don't understand the crate well enough to judge their worth.Then I dropped a pointer to the actual module of interest for all these instances of the same function. I think documenting them is important because the comment that it relates to the query system makes it obvious that they have nothing to do with the rest of the module's logic and I can carry on ignoring them. Actively doing so is another cognitive cost, but much more minimal.
There is also a small correctness issue in that all of these functions are technically mutating state. It's not a huge deal, but it's still easier to check all these mutations do not overlap if we have less instances of
fn provide
to check.