-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolve: allow non-imported items to shadow glob imports #31377
Conversation
a21319e
to
42b9a4e
Compare
I think we want an RFC before accepting this, right? (As discussed in #31337) |
☔ The latest upstream changes (presumably #31338) made this pull request unmergeable. Please resolve the merge conflicts. |
@@ -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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a comment describing the purpose of this flag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Are "glob vs glob" conflicts still result in errors? (In this implementation, I mean, not in the potential RFC.) |
42b9a4e
to
7ab5316
Compare
@petrochenkov yes -- glob vs glob conflicts are still errors, as are glob import vs single import conflicts. |
2d62a8c
to
819f8e2
Compare
☔ The latest upstream changes (presumably #31461) made this pull request unmergeable. Please resolve the merge conflicts. |
819f8e2
to
4d56389
Compare
4d56389
to
9490e1e
Compare
rebased |
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. |
☔ The latest upstream changes (presumably #31648) made this pull request unmergeable. Please resolve the merge conflicts. |
Closing because of the decision in #31337 and because I no longer like the "linked namespaces" shadowing sematics I implemented here (see this comment). |
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