What's the near and long-term future of Rustfix?

Way back when, when I migrated my "2015 edition" code to the 2018 edition, I used Rustfix to help me do it, which was awesome.

Coming from Ruby, and Rubocop, I always liked the fact that it could "fix" a lot of code, to adhere to a specific standard, and to avoid common pitfalls (I didn't like the churn it brought by moving so fast with new releases, but that's neither here nor there).

In the Rust community, we have Rustc, Clippy, Rustfmt and Rustfix to help us with all of these tasks (and RLS/RLS2 to top it all off).

While Clippy has been gaining more and more lints, Rustfmt is very stable and useful, and even though it's still early – I've had great success using RLS2, I've actually never used Rustfix, or integrated it in my editor in any way, apart from the one-time 2018 migration.

There isn't a lot of details on how to use it, there's a split between rustfix and cargo-fix, but it's not that clear to me what goes where. There was no mention of Rustfix in the 2019 roadmap. The most up-to-date information I could find is from @killercup, with a recap of the Rustfix meeting during the AH, Which ends with:

We also plan to establish an official rustfix working group. Expect an announcement soon.

But I haven't seen anything emerge yet.

This might come across as a bit critical, but it's not, as I know how busy everyone is with all the things on our agendas, not to mention all the async/await kerfuffle that has been going on in the last couple of weeks.

I'm still super bullish on what Rustfix can do for our community, but it seems to be less of a priority right now, and I wonder if that's intentional, because of time constraints, or if there's some secret work going on in the background that will unleash superpower capabilities to start building Rustfix fixes as easy as people are building Clippy lints these days.

Now, to prevent this from ending up as a what have you done for me lately post, let me just ask:

Where can one find the up-to-date state of the Rustfix project goals and planning, and how could one contribute if they had the time to do so, and the passion to see Rustfix succeed?

4 Likes

I don’t have any insight into rustfix planning, but I would like to make sure it is clear what you are asking. Rustfix just applies compiler suggestions, which any tool can do. Rustfix itself is quite simple and just applies those suggestions in bulk. Many editors provide a way to apply these suggestions one at a time (“quick fix”, etc.). I personally make heavy use of that, and can apply clippy suggestions in a single click.

rustfix is just a library that takes a set of edits (file, span, new text) and applies them. It doesn’t really know about rust. cargo fix is a tool which automatically runs the compiler, collects the suggestions (from JSON the compiler emits), and then uses the rustfix library to apply those edits, and then tests that the edits didn’t break the code.

If you want to write your own transformations, there is a tool called rerast to do that.

Are you interested in writing more sophisticated lints like what Clippy can do? I would imagine that would be difficult because Clippy uses the compiler internals, which are in frequent flux.

FWIW, there is intent to get clippy and cargo fix to work together.

So, it’s not clear to me, if you are asking to be able to add write custom clippy lints, improving the lints in rustc or clippy, or something else?

1 Like

Quick reply from an airport: Rustfix WG was announced as part of the dev tools reorganizing. We’ve had two meetings so far, with a focus on working with th clippy and diagnosistics team. Like ehuss said, rustfix itself is quite simple, it’s power comes from the compiler lints. We also want to make sure all lint suggestions are well-tested, which the rustfix library is used for as well.

So, quick contribution pointa rundown: if you want to improve the CLI experience of cargo fix, see cargo’s repo; if you want to improve a lint that comes with the compiler, see rust-lang/rust; if you want to make clippy lints auto-fixable, check in with the rustfix WG and the clippy team – we are working on this right now.

6 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.