Skip to content

rustfmt fails on Rust 2018 "path clarity" submodules #3427

Closed
@mjbshaw

Description

@mjbshaw

I originally reported this in #2407, but on further reflection I think it deserves its own issue. rustfmt fails for Rust 2018 submodules that don't use mod.rs (because of path clarity). Example:

$ mkdir foo
$ touch foo/bar.rs
$ echo 'mod bar;' > foo.rs
$ rustfmt --edition 2018 foo.rs
error[E0583]: file not found for module `bar`
 --> /private/tmp/demo/foo.rs:1:5
  |
1 | mod bar;
  |     ^^^
  |
  = help: name the file either bar.rs or bar/mod.rs inside the directory "/private/tmp/demo"

For clarity, the file structure is:

$ tree
.
├── foo
│   └── bar.rs
└── foo.rs

Here, foo.rs is the Rust 2018 equivalent of Rust 2015's foo/mod.rs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugPanic, non-idempotency, invalid code, etc.p-high

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions