Skip to content

Commit 6098278

Browse files
committed
More changes
HT @jseyfried
1 parent 7d89142 commit 6098278

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

text/0000-name-resolution.md

+18-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
- Feature Name: N/A
1+
- Feature Name: item_like_imports
22
- Start Date: 2016-02-09
33
- RFC PR: (leave this empty)
44
- Rust Issue: (leave this empty)
@@ -310,7 +310,7 @@ mod boz {
310310
```
311311

312312
Caveat: an explicit name which is defined by the expansion of a macro does **not**
313-
shadow glob imports. Example:
313+
shadow implicit names. Example:
314314

315315
```
316316
macro_rules! foo {
@@ -332,10 +332,10 @@ mod b {
332332
```
333333

334334
The rationale for this caveat is so that during import resolution, if we have a
335-
glob import we can be sure that any imported names will not be shadowed, either
336-
the name will continue to be valid, or there will be an error. Without this
337-
caveat, a name could be valid, and then after further expansion, become shadowed
338-
by a higher priority name.
335+
glob import (or other implicit name) we can be sure that any imported names will
336+
not be shadowed, either the name will continue to be valid, or there will be an
337+
error. Without this caveat, a name could be valid, and then after further
338+
expansion, become shadowed by a higher priority name.
339339

340340
An error is reported if there is an ambiguity between names due to the lack of
341341
shadowing, e.g., (this example assumes modularised macros),
@@ -393,6 +393,9 @@ following behaviour should be followed for a re-export of `foo`:
393393
it is declared publicly and imported but not re-exported in namespaces in which
394394
it is declared privately.
395395

396+
For a glob re-export, there is an error if there are no public items in any
397+
namespace. Otherwise private names are imported and public names are re-exported
398+
on a per-namespace basis (i.e., following the above rules).
396399

397400
## Changes to the implementation
398401

@@ -433,8 +436,7 @@ in the same way as we parsed the original program. We add new names to the
433436
binding table, and expand any new macro uses.
434437

435438
If we add names for a module which has back links, we must follow them and add
436-
these names to the importing module (if they are accessible). When following
437-
these back links, we check for cycles, signaling an error if one is found.
439+
these names to the importing module (if they are accessible).
438440

439441
In pseudo-code:
440442

@@ -520,7 +522,7 @@ use a::foo; // foo exists in the value namespace of a.
520522
use b::*; // foo exists in the type namespace of b.
521523
```
522524

523-
Can we resolve a use fo `foo` in type position to the import from `b`? That
525+
Can we resolve a use of `foo` in type position to the import from `b`? That
524526
depends on whether `foo` exists in the type namespace in `a`. If we can prove
525527
that it does not (i.e., resolution fails) then we can use the glob import. If we
526528
cannot (i.e., the name is unresolved but we can't prove it will not resolve
@@ -641,6 +643,13 @@ name lookup could be done lazily (probably with some caching) so no tables
641643
binding names to definitions are kept. I prefer the first option, but this is
642644
not really in scope for this RFC.
643645

646+
## `pub(restricted)`
647+
648+
Where this RFC touches on the privacy system there are some edge cases involving
649+
the `pub(path)` form of restricted visibility. I expect the precise solutions
650+
will be settled during implementation and this RFC should be amended to reflect
651+
those choices.
652+
644653

645654
# References
646655

0 commit comments

Comments
 (0)