Skip to content

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

@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

    C-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICEP-highHigh priority

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions