Introduce changes for packages as namespaces#152299
Open
b-naber wants to merge 7 commits intorust-lang:mainfrom
Open
Introduce changes for packages as namespaces#152299b-naber wants to merge 7 commits intorust-lang:mainfrom
b-naber wants to merge 7 commits intorust-lang:mainfrom
Conversation
Scope::NamespacedCrates
Collaborator
|
HIR ty lowering was modified cc @fmease |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the compiler changes for RFC 3243.
After the refactorings introduced in #143734 and #149681, we can now introduce a new scope to handle namespaced crate names.
Scope::NamespacedCrateshas lower precedence thanScope::ModuleNonGlobsandScope::ModuleGlobs, and is used to as a fallback whenever anIdentisn't resolvable in aModule. In cases where the root of a namespaced crate (fooinfoo::bar) isn't in the extern prelude, we have to introduce a virtual module. This PR introduces a new variantVirtualModtoResandScopeSet::NamespacedCrates. An alternative to this approach would be to create synthetic metadata for these crates, which seemed like the less attractive option to me.One potential downside to this approach that uses a new Scope is that in cases where a crate contains a public module whose name overlaps with the name of a namespaced crate (i.e.
fooandfoo::barare dependencies andbaris a public module infoo), only the module in the base crate is used for resolution. This seems like less of a problem in practice though, as crate owners would probably only re-export the crate through that module in the first place?! Throwing an ambiguity error in this situation would be preferable, but is not possible with this implementation approach.Namespaces are also limited to two levels, though that is by design currently, and not a limitation of the implementation approach.
r? @petrochenkov