Skip to content

--print-config minimal doesn't work as advertised #2758

Description

@tchajed

What I tried:
(1) rustfmt --print-config minimal .rustfmt.toml
(2) rustfmt --print-config minimal .rustfmt.toml src/lib.rs

What I expected:
Invocation (1) should have produced a minimal configuration in .rustfmt.toml based on settings from the current directory, without formatting anything.
Invocation (2) should have done something similar, but only incorporating src/lib.rs.

What actually happened:
The PATH following --print-config minimal is both the path to the minimal config and the file to run rustfmt on. So, the first complains the file doesn't exist; if it exists, it tries to format it and throws a syntax error. The second is the exact same, with an extra ignored argument.

Looking at the code, I think this feature is implemented, but the command line isn't parsed correctly; --print-config minimal needs to consume an additional argument which is just the path to the new config. If it were parsed correctly, the behavior would be surprising, since it would both format the code and print a config (when I would expect --print-config to not modify the source code).

Also, note that there are no tests for either --print-config default or --print-config minimal.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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-ICE

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions