lang (syntax | resolve)
This RFC proposes the mod
keyword used to refer
the immediate parent namespace in use
items (use a::b::{mod, c}
)
to be changed to self
.
While this looks fine:
use a::b::{mod, c};
pub mod a {
pub mod b {
pub type c = ();
}
}
This looks strange, since we are not really importing a module:
use Foo::{mod, Bar, Baz};
enum Foo { Bar, Baz }
RFC #168 was written when there was no namespaced enum
,
therefore the choice of the keyword was suboptimal.
This RFC simply proposes to use self
in place of mod
.
This should amount to one line change to the parser,
possibly with a renaming of relevant AST node (PathListMod
).
self
is already used to denote a relative path in the use
item.
While they can be clearly distinguished
(any use of self
proposed in this RFC will appear inside braces),
this can cause some confusion to beginners.
Don't do this.
Simply accept that mod
also acts as a general term for namespaces.
Allow enum
to be used in place of mod
when the parent item is enum
.
This clearly expresses the intent and it doesn't reuse self
.
However, this is not very future-proof for several reasons.
struct P(Q);
),
with no way of selectively importing one of them by the item type.
An explicit item type in use
will imply that we can selectively import,
while we actually can't.None.