Skip to content

Allow a wildcard *.rs that can be used to format all .rs file in that directory and it's subdirectories #2426

Closed
@ishanjain28

Description

@ishanjain28

Sometimes, I want to run rustfmt on all source files in a directory. There is a * wildcard that can be used but it also tries to format toml and any other files in the directory.

I think, There should be a *.rs wildcard that formats all Rust source files in the specified directory and also any rust files in the subdirectories of specified directory.

Activity

ishanjain28

ishanjain28 commented on Feb 11, 2018

@ishanjain28
Author

On a second thought, Formatting all .rs files in a directory and it's subdirectories might cause performance issues and there might be someone who doesn't wants to format all the source files in subdirectories.

So, A -r --recursive flag is probably a good idea.

ishanjain28

ishanjain28 commented on Feb 11, 2018

@ishanjain28
Author

Oh, Just found out about the --skip-children option. It automatically formats all imported modules in the file. My issue is now resolved but -r --recursive and *.rs wildcard might be useful for someone who has different/unrelated .rs files in a directory.

nrc

nrc commented on Feb 11, 2018

@nrc
Member

Rustfmt formats programs rather than files. If you format lib.rs/main.rs, it will format all files in the library/application.

added a commit that references this issue on Sep 6, 2018
AlexAegis

AlexAegis commented on Dec 8, 2019

@AlexAegis

And how about workspaces?
Would be nice to just pass a glob like so:
rustfmt src/**/*.rs

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @nrc@ishanjain28@AlexAegis

        Issue actions

          Allow a wildcard *.rs that can be used to format all .rs file in that directory and it's subdirectories · Issue #2426 · rust-lang/rustfmt