“Utterly Insane”: Linus Torvalds Slams Rust’s rustfmt for Making Kernel Code “Less Maintainable”
Linux creator Linus Torvalds has once again publicly criticized developers—this time drawing attention to text and code formatting in Rust. Just a day earlier, he had stated that big-endian support for RISC-V would not be included in the Linux kernel; now his remarks have turned toward what he called the “insane” formatting style in Rust and the sloppy explanations accompanying some submissions.
The trigger was a recent pull request for the DRM subsystem submitted for review. Torvalds remarked that the text appeared to be “a random collection of words,” in which the original structure had been completely lost.
“Notice how there are several subsections: Alloc, DMA/Scatterlist, DRM, and Rust. But they’re all thrown together in a random heap, because you apparently just pasted it into your editor or MUA and lost all indentation,” he wrote.
According to Torvalds, such carelessness completely destroys the multi-layered hierarchy that was originally clear in the submission. In a sardonic aside, he asked whether the author was using the ancient Edlin editor from the MS-DOS era.
The discussion then shifted to the Rust code, which has been part of the Linux kernel since version 6.18. Torvalds expressed particular frustration with how use directives are formatted.
“I hate the pointless and utterly insane rustfmt check. I rewrote several
use crate::xyz;statements into a cleaner block form so new lines could be added easily. But rustfmtcheck compressed it all into one dense line, and I have no idea what heuristics it’s following,” he complained.
Torvalds emphasized that the automatic formatting tool “literally makes code less maintainable,” complicating merges and future development.
What irritated him most was the inconsistency of the rules: in some cases, the tool insists on multi-line formatting; in others, it compresses everything into a single line—creating what he called “confusion and annoyance.”
He addressed Miguel Ojeda, who had previously asked him to use rustfmtcheck, requesting that he find a “sane solution.” Torvalds added that he had left the code in his own version, deliberately ignoring the formatter’s suggestions.
To support his point, he linked to the official Rust style guide, noting that while the recommended rules might suit compact data structures, they are inappropriate for use directives, which refer to “independent entities.”
In his view, it is precisely because of these “horribly random rustfmt heuristics” that many developers prefer to keep each use directive on a separate line.
The full correspondence is available on LKML.
Support Our Threat Intelligence
If you find our technology report and cybersecurity news helpful, consider supporting our work.