-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Tracking issue for pub(restricted)
privacy (RFC #1422)
#32409
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
You probably meant rust-lang/rfcs#1422 |
@jonas-schievink indeed. :) |
How to parse If we try to parse Similar cases with simpler disambiguation:
Note that I suppose everything here can be disambiguated, but I'm concerned about the conflict |
@petrochenkov sigh. a very good point. @pnkfelix and I were chatting-- one obvious (but not particularly appealing) option would be to say that tuple structs just can't use We considered various other synaxes one could use:
One consideration is that I expect most people will want to either make fields |
For reference, @nikomatsakis is referring to #1506. |
On Sun, Apr 3, 2016 at 5:52 AM, Vadim Petrochenkov <notifications@github.com
|
[breaking-batch] Add support for `pub(restricted)` syntax in the AST This PR allows the AST to represent the `pub(restricted)` syntax from RFC 1422 (cc #32409). More specifically, it makes `ast::Visibility` non-`Copy` and adds two new variants, `Visibility::Crate` for `pub(crate)` and `Visitibility::Restricted { path: P<Path>, id: NodeId }` for `pub(path)`. plugin-[breaking-change] cc #31645 r? @pnkfelix
…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 fixes rust-lang#30079 but doesn't change any other behavior. r? @nikomatsakis
Implement `pub(restricted)` privacy (RFC 1422) This implements `pub(restricted)` privacy from RFC 1422 (cc #32409) behind a feature gate. `pub(restricted)` paths currently cannot use re-exported modules both for simplicity of implementation and for future compatibility with RFC 1560 (cf #31783). r? @nikomatsakis
So in the @rust-lang/lang meeting we discussed this problem, as well as the solution implemented in #33100. Our conclusion was that we really ought to explore the cover grammar approach described earlier by @petrochenkov here:
It is basically the only approach that lets restricted paths and tuple structs be fully integrated, without any artificial restrictions (like needing to convert to |
…matsakis Parse `pub(restricted)` visibilities on tuple struct fields Parse `pub(restricted)` on tuple struct fields (cc #32409). r? @nikomatsakis
The ambiguous syntax has come up some more on rust-lang/rfcs#1575, where it interferes with the idea of having a "visibility matcher". Some proposals were made for alternative syntax options there:
Most of these were covered (and rejected) in my prior comment, but it is true that the lookahead requirement is onerous. |
We could always just use another keyword (
And all related variants... |
Just to clarify with everyone: |
Yes |
…r=petrochenkov Stabilize pub(restricted) Fix rust-lang#32409
This probably shouldn't have been closed since the documentation hasn't landed yet. |
…nkov Add diagnostic for incorrect `pub (restriction)` Given the following statement ```rust pub (a) fn afn() {} ``` Provide the following diagnostic: ```rust error: incorrect restriction in `pub` --> file.rs:15:1 | 15 | pub (a) fn afn() {} | ^^^ | = help: some valid visibility restrictions are: `pub(crate)`: visible only on the current crate `pub(super)`: visible only in the current module's parent `pub(in path::to::module)`: visible only on the specified path help: to make this visible only to module `a`, add `in` before the path: | pub (in a) fn afn() {} ``` Follow up to rust-lang#40340, fix rust-lang#40599, cc rust-lang#32409.
…enkov Stabilize pub(restricted) Fix rust-lang/rust#32409
I believe this is only waiting on docs, and I believe all the docs have made it. Can this be stabilized? |
This was stabilized a month ago, the only remaining bit is the Rust-by-example PR that's not merged yet. |
Ah excellent; I was going to say, sad if it had just missed a release. |
I thought it did miss the release-- it was beta nominated for a bit, but that got cancelled IIRC. |
Just checked in the playground-- it stabilizes in 1.18. |
Uh oh!
There was an error while loading. Please reload this page.
Tracking issue for rust-lang/rfcs#1422
RFC text
Milestones:
pub(restricted)
privacy (RFC 1422) #32875)pub(restricted)
#40340pub(restricted)
syntax #40334The text was updated successfully, but these errors were encountered: