Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fmt does not find modules inside inline modules inside non-inline modules #5063

Closed
heftig opened this issue Nov 4, 2021 · 1 comment · Fixed by #5064
Closed

fmt does not find modules inside inline modules inside non-inline modules #5063

heftig opened this issue Nov 4, 2021 · 1 comment · Fixed by #5064
Assignees
Labels

Comments

@heftig
Copy link

heftig commented Nov 4, 2021

Problem
cargo fmt does not processes modules that are referenced in an inline mod in a non-inline mod.

This is slightly more complex case than #4874, so it seems that bug was not fully fixed.

Steps

crate tree:

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

src/main.rs:

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

mod foo;

src/foo.rs:

mod bar {
    mod baz;
}

src/foo/bar/baz.rs: empty

1.52.0 is fine:

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

1.53.0, stable and nightly are broken:

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

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

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

Notes

Output of rustfmt --version:

  • 1.52.0: rustfmt 1.4.36-stable (7de6968 2021-02-07)
  • 1.53.0: rustfmt 1.4.37-stable (2a3635d 2021-05-04)
  • stable: rustfmt 1.4.37-stable (59eed8a 2021-11-01)
  • nightly: rustfmt 1.4.38-nightly (baba668 2021-11-03)

Rust via rustup 1.24.3, Arch Linux.

@calebcartwright
Copy link
Member

Thanks for the report @heftig and the repro case! Believe I know what the issue is so I'll take a look later today after work.

I still suspect we could handle our mod/file resolution process a bit more simply, but can never seem to find the time for investigating a more holistic refactor. Will make sure the fix for this gets pulled into the next sync though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants