-
Notifications
You must be signed in to change notification settings - Fork 13k
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
resolve: Querify most cstore access methods (subset) #108992
Conversation
r? @wesleywiser (rustbot has picked a reviewer for you, use r? to override) |
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit 609146135ed161149f162055ff123870fd593b26 with merge 09e4d7a44bc9c01eb4c5317d4aa7b60877e4aa78... |
☀️ Try build successful - checks-actions |
1 similar comment
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (09e4d7a44bc9c01eb4c5317d4aa7b60877e4aa78): comparison URL. Overall result: ❌✅ regressions and improvements - ACTION NEEDEDBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never 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. |
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.
What a cleanup!
fn associated_item_def_ids(&self, def_id: DefId) -> Option<&'tcx [DefId]> { | ||
match def_id.as_local() { | ||
Some(def_id) => self.associated_item_def_ids.get(&def_id).copied(), | ||
None => Some(self.tcx.associated_item_def_ids(def_id)), |
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.
The naming here is off.
The associated_item_def_ids
query is only supposed to work on traits and impl blocks, to return the def-ids of the contained items. Using it to access an ADT's fields is a quirk of metadata decoding, which stores both information in the same children
table and does not validate the parent before answering.
The "proper" way to access the information would use the tcx.adt_def
query.
In the same idea, this method and the field in the first branch would be better named field_def_ids
, as that's what they are.
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.
The
associated_item_def_ids
query is only supposed to work on traits and impl blocks, to return the def-ids of the contained items.
I'd say that fields are close enough to bless this use.
Previously associated_item_def_ids
was certainly used for fields in rustdoc (until #94857 nuked all the relevant code) and maybe in rustc too.
The "proper" way to access the information would use the
tcx.adt_def
query.
adt_def
query cannot be used in resolve because it create cycles (it needs lang items).
Also it decodes much more information than necessary in our case, but it doesn't matter much because all its uses would be in diagnostics (but in general associated_item_def_ids
relates to the adt_def
query in the same way as to associated_item
, i.e. minimizing decoding and dependencies).
In the same idea, this method and the field in the first branch would be better named
field_def_ids
, as that's what they are.
Yeah, I'll rename.
I used the current naming to maybe extend it to other associated items in the future, but now I agree that it only brings confusion.
LL | XE::XEmpty5(/* fields */) => (), | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
LL | XE::XEmpty5() => (), | ||
| ~~~~~~~~~~~~~ |
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.
Where does the diagnostic change come from?
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.
Previosly insert_field_names_extern
wasn't called for enum variant fields, but now fields for extern variants are successfully retrieved, this is a correct fix.
@rustbot ready |
@bors r+ |
☀️ Test successful - checks-actions |
Finished benchmarking commit (bd43458): comparison URL. Overall result: ✅ improvements - no action needed@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.
CyclesResultsThis 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.
|
A subset of #108346 that is not on a hot path in any way.