Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upResolve: allow non-imported items to shadow glob imports #31377
Conversation
rust-highfive
assigned
nrc
Feb 3, 2016
jseyfried
force-pushed the
jseyfried:allow_shadowing
branch
from
a21319e
to
42b9a4e
Feb 3, 2016
This comment has been minimized.
This comment has been minimized.
|
I think we want an RFC before accepting this, right? (As discussed in #31337) |
This comment has been minimized.
This comment has been minimized.
|
|
petrochenkov
reviewed
Feb 3, 2016
| @@ -949,6 +949,7 @@ bitflags! { | |||
| // Variants are considered `PUBLIC`, but some of them live in private enums. | |||
| // We need to track them to prohibit reexports like `pub use PrivEnum::Variant`. | |||
| const PRIVATE_VARIANT = 1 << 2, | |||
| const LINKED_NAMESPACES = 1 << 3, | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
petrochenkov
reviewed
Feb 3, 2016
| // aux-build:variant-namespacing.rs | ||
|
|
||
| extern crate variant_namespacing; | ||
| pub use variant_namespacing::XE::*; |
This comment has been minimized.
This comment has been minimized.
petrochenkov
Feb 3, 2016
Contributor
This test ensures that variants are defined in both namespaces, it shouldn't be deleted, it should be tweaked to avoid glob imports instead.
pub use variant_namespacing::XE::* -> pub use variant_namespacing::XE::{XStruct, XTuple, XUnit} etc.
This comment has been minimized.
This comment has been minimized.
petrochenkov
reviewed
Feb 3, 2016
| dest_import_resolution.is_public = is_public; | ||
| dest_import_resolution.target = Some(target.clone()); | ||
| self.add_export(module_, name, &dest_import_resolution); | ||
| } |
This comment has been minimized.
This comment has been minimized.
petrochenkov
Feb 3, 2016
Contributor
So, reexport sets are free from name conflicts now and #31308 can be landed?
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Are "glob vs glob" conflicts still result in errors? (In this implementation, I mean, not in the potential RFC.) |
jseyfried
force-pushed the
jseyfried:allow_shadowing
branch
from
42b9a4e
to
7ab5316
Feb 4, 2016
This comment has been minimized.
This comment has been minimized.
|
@petrochenkov yes -- glob vs glob conflicts are still errors, as are glob import vs single import conflicts. |
jseyfried
force-pushed the
jseyfried:allow_shadowing
branch
4 times, most recently
from
2d62a8c
to
819f8e2
Feb 4, 2016
This comment has been minimized.
This comment has been minimized.
|
|
nikomatsakis
added
the
I-nominated
label
Feb 11, 2016
nrc
added
the
T-compiler
label
Feb 11, 2016
jseyfried
force-pushed the
jseyfried:allow_shadowing
branch
from
819f8e2
to
4d56389
Feb 12, 2016
jseyfried
force-pushed the
jseyfried:allow_shadowing
branch
from
4d56389
to
9490e1e
Feb 12, 2016
This comment has been minimized.
This comment has been minimized.
|
rebased |
This comment has been minimized.
This comment has been minimized.
|
We discussed this in the recent @rust-lang/lang meeting. Our conclusion was that the correct semantics is not entirely clear here. @nrc is planning on introducing an RFC describing the name resolution system soon -- one that will also incorporate changes to hygiene and macro expansion -- and plans to raise this issue in that RFC. So we figured it'd be best to wait on making an official decision until we have time to discuss the alternatives in that forum. |
jseyfried
referenced this pull request
Feb 12, 2016
Closed
Items shadow glob-imported reexports #31337
petrochenkov
referenced this pull request
Feb 13, 2016
Closed
resolve: Get rid of `try_define` #31308
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
Closing because of the decision in #31337 and because I no longer like the "linked namespaces" shadowing sematics I implemented here (see this comment). |
jseyfried commentedFeb 3, 2016
This PR lets non-imported items shadow glob imported items (fixes #31337).
More precisely, a glob imported item will be shadowed (in all of the namespaces it defines) if any namespace it defines is already defined by a non-imported item.
Previously, it was possible to shadow only one namespace of a glob-imported re-export that defined both namespaces, so this is a [breaking-chage]. For example,
The breakage can be fixed by importing the shadowed item again as a fresh name or by renaming the item that shadows it.
r? @nrc