Add compiler support for namespaced crates#140271
Add compiler support for namespaced crates#140271b-naber wants to merge 3 commits intorust-lang:mainfrom
Conversation
Co-authored-by: Eric Holk <eric.holk@gmail.com>
| return module.copied(); | ||
| } | ||
|
|
||
| //if def_id.is_crate_root() && !def_id.is_local() { |
There was a problem hiding this comment.
Expected this to hold, but it fails when compiling libc. Likely here: https://github.com/rust-lang/libc/blob/e8b01525c30545041af1ad7ba24c05ee3251016b/src/lib.rs#L33-L37
This comment has been minimized.
This comment has been minimized.
|
I've reviewed the implementation, perhaps it can be made a bit differently, but and I don't think it can be made significantly less hacky, so I'm against the direction in general - #122349 (comment). |
Thanks for looking at the PR. I disagree with your conclusion though. The changes that this PR introduces are fairly isolated from the existing name resolution functionality. We only ever try to resolve to a namespaced crate when If we do resolve to a namespaced crate it's simply treated as a As far as I can tell there's very little maintainability burden introduced by this solution. If there's a large change in the future in terms of how name resolution is supposed to work, I do agree that this is an additional road block that could pose a problem. I kind of imagine that to be manageable, even though it's impossible to tell really without a concrete change in mind. So I can understand you in your wish that this feature wouldn't touch the compiler at all, the fact is that this RFC has already been accepted. |
|
This is a bit similar to
Until it's stable it can be unaccepted. While it's unstable I think I'm fine with gradually merging parts that do fit into the current model, and then thinking how to model the remaining parts. |
This comment has been minimized.
This comment has been minimized.
f14fd6e to
eb78d3b
Compare
This comment has been minimized.
This comment has been minimized.
eb78d3b to
b86434d
Compare
|
There's some discussion about this PR and RFC 3243 going on at #t-compiler > RFC 3243. (I'm mostly posting this here to increase my chances of finding the link in the future.) |
|
|
||
| #[test] | ||
| fn test_bar() { | ||
| assert_eq!(bar::BAR, "bar"); |
There was a problem hiding this comment.
This test seems unrelated to namespaced crates, right?
There was a problem hiding this comment.
Yeah, no idea what this test is, seems to be incomplete.
Attempt to implement the remaining changes for RFC 3243. This is joint work with @eholk.
Opening a draft PR to get feedback from @petrochenkov on the viability of the approach.
r? @petrochenkov