-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
rustc: Replace HirId
s with LocalDefId
s in AccessLevels
tables
#87568
Conversation
Some changes occurred in intra-doc-links. cc @jyn514 |
break; | ||
} | ||
module_id = self.tcx.hir().get_parent_node(module_id); | ||
module_def_id = | ||
ty::DefIdTree::parent(self.tcx, module_def_id.to_def_id()).unwrap().expect_local(); |
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 logic in this function was slightly changed to walk DefId
parents instead of HirId
parents, but the end result should be the same, I think.
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.
IIUC, this loop is only accessed when macro_module_def_id
point to a module that can be named from the outside. As a consequence, all its parents are modules. This is relied upon by update_macro_reachable
. All modules are HIR owners, so walking parents by def_key or through HIR is equivalent.
Do you agree with the explanation? Should there be a comment?
Can the loop be simplified using tcx.hir().parent_owner_iter()
?
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.
Added a comment.
parent_owner_iter
doesn't seem to make things simpler because it requires converting to HirId
s and back.
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 901e8567836f70407d55e924ecae35c822743b76 with merge 258b818d64e93a02410b9a5a79c00e11788dfdf6... |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit b639c36b9dad866d247c53f0053cb2105c84f27c with merge 0b23956c3baae739f7b14e136e301972fff31032... |
☀️ Try build successful - checks-actions |
Queued 0b23956c3baae739f7b14e136e301972fff31032 with parent b708886, future comparison URL. |
Finished benchmarking try commit (0b23956c3baae739f7b14e136e301972fff31032): comparison url. Summary: This benchmark run did not return any significant changes. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. @bors rollup=never |
@bors rollup=maybe |
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.
LGTM. I left a few questions.
break; | ||
} | ||
module_id = self.tcx.hir().get_parent_node(module_id); | ||
module_def_id = | ||
ty::DefIdTree::parent(self.tcx, module_def_id.to_def_id()).unwrap().expect_local(); |
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.
IIUC, this loop is only accessed when macro_module_def_id
point to a module that can be named from the outside. As a consequence, all its parents are modules. This is relied upon by update_macro_reachable
. All modules are HIR owners, so walking parents by def_key or through HIR is equivalent.
Do you agree with the explanation? Should there be a comment?
Can the loop be simplified using tcx.hir().parent_owner_iter()
?
#[derive(Clone)] | ||
pub struct AccessLevels<Id = HirId> { | ||
#[derive(Debug)] | ||
pub struct AccessLevels<Id = LocalDefId> { |
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.
Is this used somewhere with another 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.
Yes, rustdoc uses AccessLevels<DefId>
and actually adds foreign ids to the table as public or exported, I didn't investigate why exactly.
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.
IIRC it's because rustdoc needs to do its own privacy pass because rustc's is incorrect (#64762). It may be possible to remove when that's fixed, but don't quote me on that.
and passes using them - primarily privacy checking, stability checking and dead code checking. WIP
Updated. |
@bors r+ |
📌 Commit f921410 has been approved by |
⌛ Testing commit f921410 with merge 8f0efc93fd987665366d79b755a92641832ed0d1... |
💔 Test failed - checks-actions |
@bors retry |
☀️ Test successful - checks-actions |
rustc: Replace `HirId`s with `LocalDefId`s in `AccessLevels` tables and passes using those tables - primarily privacy checking, stability checking and dead code checking. All these passes work with definitions rather than with arbitrary HIR nodes. r? `@cjgillot` cc `@lambinoo` (rust-lang#87487)
rustc_privacy: Replace `HirId`s and `DefId`s with `LocalDefId`s where possible Follow up to rust-lang#87568
and passes using those tables - primarily privacy checking, stability checking and dead code checking.
All these passes work with definitions rather than with arbitrary HIR nodes.
r? @cjgillot
cc @lambinoo (#87487)