Rustfmt cannot find mod with #[path] on windows
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
Rustfmt on windows cannot resolve module to file if #[path] used.
Note, #[path] should contain windows-unfriendly relative path.
To Reproduce
Use #[path = "./some-relative-path.rs"] in code.
Pointed file should be and valid rust source or empty.
#[path = "../module_foo.rs"]
mod module_foo;
Error:
> cargo fmt -- --check
error: couldn't read \\?\D:\a\rustfmt-issue-4477\rustfmt-issue-4477\src\..\module_foo.rs: The filename, directory name, or volume label syntax is incorrect. (os error 123)
Error writing files: failed to resolve mod `module_foo`: \\?\D:\a\rustfmt-issue-4477\rustfmt-issue-4477\src\..\module_foo.rs does not exist
Check out demo for this issue. Also there is two cases reproduced on GHA:
Expected behavior
No rustfmt's IO errors.
All modules resolved.
Meta
- rustfmt versions:
- rustfmt 1.4.15-stable (530eadf4 2020-06-02)
- rustfmt 1.4.15-nightly (aedff61f 2020-05-19)
- From where did you install rustfmt?: rustup, crates.io
- How do you run rustfmt:
rustfmt,cargo-fmt
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Windows failure with the issue's #[path = "../module_foo.rs"] example and cargo fmt -- --check, using the linked demo repository. Trace rustfmt's module-resolution entry point for Windows paths; done means the relative-path module resolves without an I/O error, while the filename-only case continues to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- operating-systems, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100