I want to make a little contribution to rustc
and so decided to read Coding conventions - Guide to Rustc Development. It says rustc
uses some custom tool called tidy
. Why is that? Why don't just make custom lints for clippy
?
The tidy script checks whether the code is properly formatted with rustfmt
; I believe that’s not something that clippy
can do. AFAIR, rustc also does not use clippy
on CI.
Thanks for a rapid reply! I don't think writing a separate in-house tool instead of using cargo fmt
& cargo clippy
is a particularly good idea... Maybe it's just the legacy left from the times when both commands didn't exist yet?
tidy
calls rustfmt
internally. It's not reimplementing formatting.
(You can even call ./x.py fmt
to format the repo.)
tidy does a fair amount more than you'd think. Feature names (for nightly features) have to be declared alphabetically, for example, but only within its "section". This requires parsing the comments for instruction (when the section starts and ends) — something certainly undesirable in any lint.
rustc also has it's own set of lints for use internally. These aren't part of cargo. Could a large chunk of tidy be converted to internal rustc lints? Probably! There's just no reason to, as tidy works. It also doesn't require any type information, as it operates purely on the textual representation. So any change there would inherently slow it down.