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

Recursive --config-path doesn't recurse #4660

Open
lnicola opened this issue Jan 21, 2021 · 2 comments
Open

Recursive --config-path doesn't recurse #4660

lnicola opened this issue Jan 21, 2021 · 2 comments
Labels
bug Panic, non-idempotency, invalid code, etc.

Comments

@lnicola
Copy link
Member

lnicola commented Jan 21, 2021

Describe the bug

The --config-path help description says:

        --config-path [Path for the configuration file]
                        Recursively searches the given path for the
                        rustfmt.toml config file. If not found reverts to the
                        input file path

However it doesn't seem to recurse:

$ rustfmt --config-path ~/Downloads/test_issue/my_crate/src/main.rs --edition 2018 < ~/Downloads/test_issue/my_crate/src/main.rs
Could not parse TOML: expected an equals, found an identifier at line 1 column 4

$ rustfmt --config-path ~/Downloads/test_issue/my_crate/src/ --edition 2018 < ~/Downloads/test_issue/my_crate/src/main.rs
Error: unable to find a config file for the given path: `~/Downloads/test_issue/my_crate/src/`

$ rustfmt --config-path ~/Downloads/test_issue/my_crate/src --edition 2018 < ~/Downloads/test_issue/my_crate/src/main.rs
Error: unable to find a config file for the given path: `~/Downloads/test_issue/my_crate/src`

$ rustfmt --config-path ~/Downloads/test_issue/my_crate --edition 2018 < ~/Downloads/test_issue/my_crate/src/main.rs
fn fjsdlkfjklsdajflksdjlfdasdsadsadsaadkjdskljflkasj_jflksjdklfjsdlkjflkdjslkfjas(a: i32, b: i32, c: i32) {
    println!("TEST");
}

fn main() {
    fjsdlkfjklsdajflksdjlfdasdsadsadsaadkjdskljflkasj_jflksjdklfjsdlkjflkdjslkfjas(1, 2, 3);
    println!("Hello, world!");
}

$ rustfmt --config-path ~/Downloads/test_issue/ --edition 2018 < ~/Downloads/test_issue/my_crate/src/main.rs
Error: unable to find a config file for the given path: `~/Downloads/test_issue/`

To Reproduce

Test project is the one from rust-lang/rust-analyzer#6973 (comment)

Expected behavior

rustfmt --config-path follows the same logic as rustfmt

Meta

  • rustfmt version: rustfmt 1.4.32-nightly (216a643 2021-01-16)
  • From where did you install rustfmt?: rustup
  • How do you run rustfmt: rustfmt
@lnicola lnicola added the bug Panic, non-idempotency, invalid code, etc. label Jan 21, 2021
@calebcartwright
Copy link
Member

I want to say that this has already been fixed in source, but hasn't been backported to a 1.x release yet. Will dig back through the issue tracker to check though, and if so will see if I can't get that fix cherry-picked for the next v1.4.33 release

@lnicola
Copy link
Member Author

lnicola commented May 22, 2021

Status: no change, this still isn't working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Panic, non-idempotency, invalid code, etc.
Projects
None yet
Development

No branches or pull requests

2 participants