Skip to content

fmt no longer finds modules inside inline modules #4874

Closed
@heftig

Description

@heftig

Problem
cargo fmt no longer processes modules that are referenced in an inline mod.

Steps

crate tree:

.
├── Cargo.toml
└── src
    ├── bar
    │   └── baz.rs
    ├── foo
    │   └── qux.rs
    ├── foo.rs
    └── main.rs

src/main.rs:

fn main() {
    println!("Hello, world!");
}

mod foo;
mod bar {
    mod baz;
}

src/foo.rs: mod qux;
src/foo/qux.rs: empty
src/bar/baz.rs: empty

Stable is fine:

> cargo +stable fmt -- -v
Formatting /home/jan/x/src/bar/baz.rs
Formatting /home/jan/x/src/foo/qux.rs
Formatting /home/jan/x/src/foo.rs
Formatting /home/jan/x/src/main.rs

Nightly is broken:

> cargo +nightly fmt -- -v
Formatting /home/jan/x/src/foo/qux.rs
Formatting /home/jan/x/src/foo.rs
Formatting /home/jan/x/src/main.rs

Notes

Output of cargo version:

  • Nightly is broken: cargo 1.54.0-nightly (44456677b 2021-06-12)
  • Stable is fine: cargo 1.52.0 (69767412a 2021-04-21)

Rust via rustup 1.24.3, Arch Linux.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions