-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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_privacy: Expand public node set, build exported node set more correctly #29291
Conversation
self.reexports.contains(&foreign_item.id); | ||
|
||
if public { self.public_items.insert(foreign_item.id); } | ||
if exported { self.exported_items.insert(foreign_item.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.
I think stylistically in rustfmt it never formats if
statements on one line, so to head off the churn could this go ahead and move to lines after braces?
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.
Okay (although I'm a fan of one-liners for short blocks)
Updated with comments and formatting |
Carrying over from a collapsed comment Should the checks in |
@alexcrichton |
In `middle::reachable` mark default impl of a trait method as reachable if this trait method is used from inlinable code
@alexcrichton
r? |
Updated with fixed FIXMEs |
hir::ItemForeignMod(ref foreign_mod) => { | ||
for foreign_item in &foreign_mod.items { | ||
let public = self.prev_public && foreign_item.vis == hir::Public; | ||
let exported = self.prev_exported && foreign_item.vis == hir::Public || |
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.
Could you add parens around one of the clauses here? I always forget the precedence of &&
and ||
...
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.
Yep.
Thanks @petrochenkov! Just one last nit and otherwise r=me |
@alexcrichton |
@bors: r+ 2a6f51b8bf8bb8ed6178e262698462cab4a694f3 Thanks again @petrochenkov! |
Oh, no, I fixed a typo after r+ |
⌛ Testing commit ab7b345 with merge e2bb53c... |
The public set is expanded with trait items, impls and their items, foreign items, exported macros, variant fields, i.e. all the missing parts. Now it's a subset of the exported set. This is needed for #29083 because stability annotation pass uses the public set and all things listed above need to be annotated. Rustdoc can now be migrated to the public set as well, I guess. Exported set is now slightly more correct with regard to exported items in blocks - 1) blocks in foreign items are considered and 2) publicity is not inherited from the block's parent - if a function is public it doesn't mean structures defined in its body are public. r? @alexcrichton or maybe someone else
Handle them in `middle::reachable` instead (no optimizations so far, just drop all trait impl items into the reachable set, as before). Addresses the concerns from #29291 (comment) \+ In `middle::reachable` don't treat impls of `Drop` specially, they are subsumed by the general impl treatment. \+ Add some tests checking reachability of trait methods written in UFCS form \+ Minor refactoring in the second commit r? @alexcrichton
The public set is expanded with trait items, impls and their items, foreign items, exported macros, variant fields, i.e. all the missing parts. Now it's a subset of the exported set.
This is needed for #29083 because stability annotation pass uses the public set and all things listed above need to be annotated.
Rustdoc can now be migrated to the public set as well, I guess.
Exported set is now slightly more correct with regard to exported items in blocks - 1) blocks in foreign items are considered and 2) publicity is not inherited from the block's parent - if a function is public it doesn't mean structures defined in its body are public.
r? @alexcrichton or maybe someone else