rust-lang/rustfix

Can "cargo fix" be made available as a standalone binary?

mgeisler opened this issue · 2 comments

Hi there! I work on Android and generate a bunch of Rust code. For this, I was hoping to use rustfmt to remove unnecessary parenthesis — but found out that this is implemented in cargo fix and not in rustfmt (rust-lang/rustfmt#3823)

Android uses its own build system and so there is no clippy available in the build environment. This makes it hard or impossible for me to call out to cargo fix. However, rustfmt is available and this made me wonder if cargo fix could or should also be available as a standalone binary?

It's not critical thing for me right now (we'll just disable the lints for the auto-generated files), but I imagine that others will run into this more and more as large companies integrate rustc (but not cargo) in their build systems.

I suspect the best path forward for you would be to write a binary that uses the rustfix library the way you need: the design space for such a binary is pretty large. Rustfmt works on files and as such is a simple CLI, but rustfix needs to be sandwiched in the middle of a build pipeline: you need to call the right build command to get the diagnostics and then pass them through this tool.

That said I think we would accept a PR for a sufficiently generic CLI interface, behind a feature.