Introduce changes for packages as namespaces#152299
Introduce changes for packages as namespaces#152299b-naber wants to merge 7 commits intorust-lang:mainfrom
Conversation
Scope::NamespacedCrates
|
HIR ty lowering was modified cc @fmease |
|
(I'll review this after another large PR, #151864.) |
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Introduce changes for packages as namespaces
|
Let's again split this into two parts to make progress. I can see potential issues in the both parts and it would be better to deal with them separately. |
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (12dbfa8): comparison URL. Overall result: ❌ regressions - please read the text belowBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesResults (primary -3.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 481.762s -> 483.193s (0.30%) |
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