Uh oh!
There was an error while loading. Please reload this page.
groundwork for RFC 1422, improve PrivateItemsInPublicInterfacesVisitor - #32674
Conversation
jseyfried
commented
Apr 2, 2016
There was a problem hiding this comment.
required_visibility and min_visibility generalize is_quiet and is_public (respectively)
There was a problem hiding this comment.
is_quiet is kind of a hack, I intended to split this visitor into two visitors (for checking T and Tr in impl Tr for T {....} and for everything else) and also harmonize it with some stuff in EmbargoVisitor...
Well, I guess I'll still do it, someday.
There was a problem hiding this comment.
I think there's enough similarity to justify having just one visitor. Regardless, hack or not it generalizes well :)
There was a problem hiding this comment.
//< doesn't work with rustdoc
There was a problem hiding this comment.
That's unfortunate, I'll make these preceding /// comments then
petrochenkov
commented
Apr 2, 2016
Reviewed, LGTM. |
petrochenkov
commented
Apr 2, 2016
This is also a plugin-[breaking-change] due to the changes to AST |
jseyfried
commented
Apr 2, 2016
@petrochenkov thanks!
Ok, I'll change this to not break the AST and then do a separate PR that future proofs the AST wrt 1422 (i.e. makes |
bors
commented
Apr 2, 2016
☔ The latest upstream changes (presumably #32562) made this pull request unmergeable. Please resolve the merge conflicts. |
622d906 to
bb47000Comparejseyfried
commented
Apr 2, 2016
I addressed @petrochenkov's comments, changed this PR to not break the AST, and rebased. |
nikomatsakis
commented
Apr 5, 2016
@bors r+ |
bors
commented
Apr 5, 2016
📌 Commit bb47000 has been approved by |
…lity in `typeck` and in `privacy::PrivacyVisitor`.
jseyfried
commented
Apr 7, 2016
rebased |
bors
commented
Apr 7, 2016
📌 Commit dcd4621 has been approved by |
bors
commented
Apr 7, 2016
⌛ Testing commit dcd4621 with merge a9fd0c5... |
…tsakis Lay groundwork for RFC 1422 and improve `PrivateItemsInPublicInterfacesVisitor` This PR lays groundwork for RFC 1422 (cc rust-lang#32409) and improves `PrivateItemsInPublicInterfacesVisitor`. More specifically, it - Refactors away `hir::Visibility::inherit_from`, the semantics of which are obsolete. - Makes `hir::Visibility` non-`Copy` so that we will be able to add new variants to represent `pub(restricted)` (for example, `Visibility::Restricted(Path)`). - Adds a new `Copy` type `ty::Visibility` that represents a visibility value, i.e. a characterization of where an item is accessible. This is able to represent `pub(restricted)` visibilities. - Improves `PrivateItemsInPublicInterfacesVisitor` so that it checks for items in an interface that are less visible than the interface. This fixesrust-lang#30079 but doesn't change any other behavior. r? @nikomatsakis
bors
commented
Apr 7, 2016
⛄ The build was interrupted to prioritize another pull request. |
PrivateItemsInPublicInterfacesVisitorPrivateItemsInPublicInterfacesVisitorprivacy: Use common `DefId` visiting infrastructure for all privacy visitors One repeating pattern in privacy checking is going through a type, visiting all `DefId`s inside it and doing something with them. This is the case because visibilities and reachabilities are attached to `DefId`s. Previously various privacy visitors visited types slightly differently using their own methods, with most recently written `TypePrivacyVisitor` being the "gold standard". This mostly worked okay, but differences could manifest in overly conservative reachability analysis, some errors being reported twice, some private-in-public lints (not errors) being wrongly reported or not reported. This PR does something that I wanted to do since #32674 (comment) - factoring out the common visiting logic! Now all the common logic is contained in `struct DefIdVisitorSkeleton`, with specific privacy visitors deciding only what to do with visited `DefId`s (via `trait DefIdVisitor`). A bunch of cleanups is also applied in the process. This area is somewhat tricky due to lots of easily miss-able details, but thankfully it's was well covered by tests in #46083 and previous PRs, so I'm relatively sure in the refactoring correctness. Fixes#56837 (comment) in particular. Also this will help with implementing #48054.
This PR lays groundwork for RFC 1422 (cc #32409) and improves
PrivateItemsInPublicInterfacesVisitor. More specifically, ithir::Visibility::inherit_from, the semantics of which are obsolete.hir::Visibilitynon-Copyso that we will be able to add new variants to representpub(restricted)(for example,Visibility::Restricted(Path)).Copytypety::Visibilitythat represents a visibility value, i.e. a characterization of where an item is accessible. This is able to representpub(restricted)visibilities.PrivateItemsInPublicInterfacesVisitorso that it checks for items in an interface that are less visible than the interface. This fixesPrivate structure can escape from its module through impl for another private structure #30079 but doesn't change any other behavior.r? @nikomatsakis