Skip to content

Weird filesystem hierarchy with nested modules  #55094

Closed
@Undin

Description

@Undin

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 Rust

I 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

error[E0583]: file not found for module `qqq`
 --> src/foo.rs:5:13
  |
5 |     pub mod qqq;
  |             ^^^
  |
  = help: name the file either foo/qqq.rs or foo/qqq/mod.rs inside the directory "src/baz"

error: aborting due to previous error

For more information about this error, try `rustc --explain E0583`.

But if I move qqq.rs into src/baz/foo folder rustc will compile it in both editions.

Problems:

  • This code souldn't be compilable in edition 2015.
    At least, rustc 1.29.2 shows the following error
error[E0658]: mod statements in non-mod.rs files are unstable (see issue #44660)
 --> src/foo.rs:5:13
  |
5 |     pub mod qqq;
  |             ^^^
  |
  = help: on stable builds, rename this file to foo/mod.rs

error: aborting due to previous error

For more information about this error, try `rustc --explain E0658`.
  • src/baz/foo/qqq.rs is rather unexpected because baz is child module of foo. I think qqq.rs should be located in src/foo/baz or in src/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

Metadata

Metadata

Assignees

Labels

A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyP-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions