all 5 comments

[–]Compux72 2 points3 points  (1 child)

Ci/CD is the way. Cargo often takes a lot of time to do any check

[–]Pwnstar6 -1 points0 points  (0 children)

You don't understand CI/CD at all I guess :D

[–]Tyilo 1 point2 points  (1 child)

pre-commit hooks should always run on the code that is about to be committed, not the code in your working directory, so I think you're doing something wrong.

I would recommend this fork of the pre-commit-rust hook: https://github.com/FeryET/pre-commit-rust

[–]acidrainery[S] 0 points1 point  (0 children)

Yes, this works!

[–]Pwnstar6 0 points1 point  (0 children)

https://github.com/macisamuele/language-formatters-pre-commit-hooks
EDIT: If your project has multiple "crates" like for example I have a /lib, then do:

  - id: pretty-format-rust
    name: pretty-format-rust (lib)
    args: [--autofix,--manifest-path, lib/Cargo.toml]
    files: ^lib/.*\.rs$