1
- - Feature Name: N/A
1
+ - Feature Name: item_like_imports
2
2
- Start Date: 2016-02-09
3
3
- RFC PR: (leave this empty)
4
4
- Rust Issue: (leave this empty)
@@ -310,7 +310,7 @@ mod boz {
310
310
```
311
311
312
312
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:
314
314
315
315
```
316
316
macro_rules! foo {
@@ -332,10 +332,10 @@ mod b {
332
332
```
333
333
334
334
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.
339
339
340
340
An error is reported if there is an ambiguity between names due to the lack of
341
341
shadowing, e.g., (this example assumes modularised macros),
@@ -393,6 +393,9 @@ following behaviour should be followed for a re-export of `foo`:
393
393
it is declared publicly and imported but not re-exported in namespaces in which
394
394
it is declared privately.
395
395
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).
396
399
397
400
## Changes to the implementation
398
401
@@ -433,8 +436,7 @@ in the same way as we parsed the original program. We add new names to the
433
436
binding table, and expand any new macro uses.
434
437
435
438
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).
438
440
439
441
In pseudo-code:
440
442
@@ -520,7 +522,7 @@ use a::foo; // foo exists in the value namespace of a.
520
522
use b::*; // foo exists in the type namespace of b.
521
523
```
522
524
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
524
526
depends on whether ` foo ` exists in the type namespace in ` a ` . If we can prove
525
527
that it does not (i.e., resolution fails) then we can use the glob import. If we
526
528
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
641
643
binding names to definitions are kept. I prefer the first option, but this is
642
644
not really in scope for this RFC.
643
645
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
+
644
653
645
654
# References
646
655
0 commit comments