After Linus Torvalds yesterday shot down RISC-V big endian prospects for the Linux kernel, today he has used his authority to wage a war on “crazy” Rust code formatting as well as to critique poor text formatting.
In response to the recently submitted Direct Rendering Manager (DRM) subsystem pull request, Torvalds began by voicing his displeasure over the text formatting of it:
“Notice how there are multiple sub-areas: Alloc, DMA/Scatterlist, DRM and Rust.
But it’s all just a random jumble, because you have apparently pasted it into your editor or MUA or whatever and dropped the indentation in the process.
Or something.
What kind of *broken* editor are you using? I’m not trying to start an emacs or vi war here, but you seem to be using something truly broken.
EDLIN?
…
Look, again, no logic and you’ve completely corrupted any multi-level indentation that presumably existed at some point judging by the organization.WTH?
…
Please make the explanations *readable*, not just a random jumble of words.”
Edlin is the line/text editor found on early versions of PC DOS and MS-DOS…
But then on a more technical note, Linus Torvalds went on to seek better clarity of Rust code formatting moving forward. When looking at the Rust DRM code added for Linux 6.18, Torvalds commented after looking at some of the new code:
“And on a more technical side: I absolutely detest the mindless and completely crazy Rust format checking.
I noticed that people added multiple
use crate::xyz;
next to each other, so I turned them into
use crate::{
xyz,
abc,
};instead to make it easy to just add another crate without messing crap up. The use statements around it had that format too, so it all seemed sensible and visually consistent.
But then I run rustfmtcheck, and that thing is all bass-ackwards garbage. Instead of making it clean and clear to add new rules, it suggests
use crate::{xyz, abc};
but I have no idea what the heuristics for when to use multiple lines and when to use that compressed format are.
This is just ANNOYING. It’s automated tooling that is literally making bad decisions for the maintainability. This is the kind of thing that makes future conflicts harder for me to deal with.
Miguel, I know you asked me to run rustfmtcheck, but that thing is just WRONG. It may be right “in the moment”, but it is
(a) really annoying when merging and not knowing what the heck the rules are
(b) it’s bad long term when you don’t have clean lists of “add one line for a new use”
Is there some *sane* solution to this? Because I left my resolution alone and ignored the horrible rustfmtcheck results.
I tried to google the rust format rules, and apparently it’s this:
https://doc.rust-lang.org/style-guide/index.html#small-items
can we please fix up whatever random heuristics? That small items thing may make sense when we’re talking things that really are one common data structure, but the “use” directive is literally about *independent* things that get used, and smushing them all together seems entirely wrong.
I realize that a number of users seem to just leave the repeated
use kernel::xyz;
use kernel::abc;as separate lines, possibly *becasue* of this horrendous rustfmt random heuristic behavior.”
The post in full can be read on the LKML.