I see a number of benefits to moving rustfmt
, specifically, in tree:
- This is a core tool we expect basically every rust developer to be using
- If we are going to do so, I think we have to step up to the plate and make sure that it’s always working, and that it always covers the same language as the compiler
- For example, there was a long period where
rustfmt
rendered any use ofimpl Trait
asTODO
. As someone who tries to use rustfmt on personal projects, I found this very annoying, because I was in the habit of running it regularly, and it would break my code every time.
- If rustfmt were in tree, we could test it on all run-pass tests, just as we do the current pretty-printer:
- This would ensure that, whenever you add a new language feature, you must also have some modicum of support in rustfmt
- Hopefully, we can kill the old pretty-printer, and replace it with rustfmt.
- As I understand it, they’re largely interchangeable.
- Eventually I predict we are going to want to make various changes for which a more advanced
rustfix
would be useful:- Example might be rewrite function signatures to use elision 2.0.
- This would require a combination of semantic information and rustfmt, and that will be easier to coordinate with both in tree (and to keep it working as we make other changes).
At the moment, I don’ think clippy has the “official blessing” that rustfmt does, so the case there is somewhat less clear. But clearly it’s a popular project, so at minimum making it easier to find out when there is breakage and ensure it is promptly fixed makes sense.
Another factor: before we move clippy in tree, we would definitely have to develop some policy around lints. This would be useful anyway, though. Right now I feel a lot of uncertainty about what kinds of lints we should add as well as whether they belong in clippy or rustc etc. (Like, if clippy is in tree, why does it exist at all, rather than just being part of rustc?) This feels like a big conversation (bigger than this thread).
One other question: I heard mention of adapting rustup
to understand not to upgrade nightly until clippy is working etc. Setting up that tooling sounds itself like a fair amount of work, so that makes me a bit nervous.