-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Weird filesystem hierarchy with nested modules #55094
Comments
I'm nominating this issue. This would seem to be a candidate for RC2 blocker: Do we expect to be able to create non-inline modules (e.g., I don't really expect that to be permitted. But I forget precisely what our behavior was historically here, it seems like we ought to test it. (That is, using |
This is, in fact, used inside the compiler I believe -- e.g. syntax does this here: https://github.com/rust-lang/rust/blob/master/src/libsyntax/lib.rs#L113-L145 multiple times, librustc does so as well. If I'm understanding this issue correctly this is also a 1.30 release blocker essentially -- mod.rs is stabilized in 1.30 AFAIK on both 2015 and 2018 edition(s). |
I was curious, so I did some poking. The fix looks easier than I expected, but of course I'm not very familiar with this code so I'm not sure if I missed anything. I posted a pr at #55108 with what I believe might fix this (running under the assumption that filesystem paths should match the mod paths). |
Ping. I'm going to guess that there's nothing that can be done for 1.30? If this is fixed in 1.31, is it ok that it will have different behavior than 1.30? |
assigning self to take charge on this. I suspect I won't have time to investigate properly before the lang team meeting tonight, but we will see. |
I'll take a look at this, too. |
Sure, yea, I should have summarized it better. I'll try to make it clear.
main.rs: mod foo;
fn main() {
foo::inline::inner::f();
} foo.rs: pub mod inline {
pub mod inner;
} inline/foo/inner.rs: pub fn f() {} In this example, the mod path is The simple fix is to push the main.rs: mod foo;
fn main() {
foo::inline::inner::f();
} foo.rs: pub mod inline {
#[path="inner_actual.rs"]
pub mod inner;
} inline/inner_actual.rs: pub fn f () {} Notice the module path is So I'm not sure what to do here. There are a variety of choices to address this, but none of them seem good. I listed some options towards the bottom #55108. Another idea is to follow the |
Quick summary from a discussion (and confusion) in the lang team:
|
@cramertj will implement the fix per @joshtriplett's notes. |
Tagging as regression from stable to beta because the current incorrect behavior would stabilize in 1.30. |
This is happening because when we parse This mutation of the current directory path to actually point at a new path that matches the inline |
Anyways, as @ehuss said the current behavior here around |
Flatten relative offset into directory path before adding inline (mod x { ... }) module names to the current directory path. Fix #55094
Fix ordering of nested modules in non-mod.rs mods Flatten relative offset into directory path before adding inline (mod x { ... }) module names to the current directory path. Fix #55094
Doing a survey prior to weekly compiler team meeting and summarizing state of P-high issues. As you can see from reading the discussion on #55192, it was too close to the release for us to land the proposed PR for this cycle. So the plan of record is to remove the stabilization of non-mod.rs mods for the imminent release, and then take care of this problem as part of the next release cycle. (However, I'm not certain that the plan of record is entirely accurate; i've been given the impression that the point of cutting the new beta was delayed by about a week, which may mean that PR #551912 |
Fix ordering of nested modules in non-mod.rs mods Flatten relative offset into directory path before adding inline (mod x { ... }) module names to the current directory path. Fix #55094
For the record, the feature was destabilized in 1.30 and will be patched in 1.31 (and remains stable on the current beta and nightly). |
Flatten relative offset into directory path before adding inline (mod x { ... }) module names to the current directory path. Fix rust-lang#55094
Compiler: rustc 1.31.0-nightly (14f42a7 2018-10-14)
I'm trying to figure out how module system should work in edition 2018 without
mod.rs
to support it in IntelliJ RustI have the following project structure: https://gist.github.com/Undin/eaef0a4765f5a991f6e62f8d07b878db.
And rustc can't compile this code in edition 2015 and 2018 with the following error
But if I move
qqq.rs
intosrc/baz/foo
folder rustc will compile it in both editions.Problems:
At least, rustc 1.29.2 shows the following error
src/baz/foo/qqq.rs
is rather unexpected becausebaz
is child module offoo
. I thinkqqq.rs
should be located insrc/foo/baz
or insrc/baz
folder but I'm not sure.It would be great to understand how it should work to implement the corresponding support in the plugin
The text was updated successfully, but these errors were encountered: