Skip to content

Commit 51daa98

Browse files
committed
add the glob issue to unresolved Qs.
1 parent cd19173 commit 51daa98

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

text/0000-pub-restricted.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,9 @@ For example:
813813
`pub(restricted)` form does not have any variant where the
814814
restrction-specification denotes the whole universe.
815815
In other words, there's no current way to get the same effect
816-
as `pub item` via `pub(restricted) item`.
816+
as `pub item` via `pub(restricted) item`; you cannot say
817+
`pub(universe) item` (even though I do so in a tongue-in-cheek
818+
manner elsewhere in this RFC).
817819

818820
Some future syntaxes to support this have been proposed in the
819821
RFC comment thread, such as `pub(::)`. But this RFC is leaving the
@@ -906,6 +908,49 @@ even in the context of a non-pub module like `mod b`. In particular,
906908
`pub(super) use item` may be imposing a new restriction on the
907909
re-exported name that was not part of its original definition.)
908910

911+
## Interaction with Globs
912+
913+
Glob re-exports
914+
currently only re-export `pub` (as in `pub(universe)` items).
915+
916+
What should glob-reepxorts do with respect to `pub(restricted)`?
917+
918+
Here is an illustrating example pointed out by petrochenkov in the
919+
comment thread:
920+
921+
```rust
922+
mod m {
923+
/*priv*/ pub(m) struct S1;
924+
pub(super) S2;
925+
pub(foo::bar) S3;
926+
pub S4;
927+
928+
mod n {
929+
930+
// What is reexported here?
931+
// Just `S4`?
932+
// Anything in `m` visible
933+
// to `n` (which is not consisent with the current treatment of
934+
`pub` by globs).
935+
936+
pub use m::*;
937+
}
938+
}
939+
940+
// What is reexported here?
941+
pub use m::*;
942+
pub(baz::qux) use m::*;
943+
```
944+
945+
This remains an unresolved question, but my personal inclination, at
946+
least for the initial implementation, is to make globs only import
947+
purely `pub` items; no non-`pub`, and no `pub(restricted)`.
948+
949+
After we get more experience with `pub(restricted)` (and perhaps make
950+
other changes that may come in future RFCs), we will be in a better
951+
position to evaluate what to do here.
952+
953+
909954
# Appendices
910955

911956
## Associated Items Digression

0 commit comments

Comments
 (0)