Closed
Description
Reproduction, clone https://github.com/Marwes/rustfmt-bug and run cargo fmt
.
error[E0583]: file not found for module `support`
--> /home/markus/Code/rustfmt-bug/tests/test.rs:1:5
|
1 | mod support;
| ^^^^^^^
|
= help: name the file either test/support.rs or test/support/mod.rs inside the directory "/home/markus/Code/rustfmt-bug/tests"
Since both tests/test.rs
and tests/test/
exists, rustfmt is unable to find tests/support/mod.rs
as mod support;
as it appears that rustfmt thinks that test.rs
is part of the tests/test/
module tree. This is different from how rustc/cargo sees it which compile the code happily.
I guess rustc/cargo has different module resolution for tests/
than src/
since rustfmt's behaviour would be correct in src/
.
Workaround is to use #[path = "module.rs"]
on the offending module.