On Tue, 7 Oct 2025 at 10:21, Miguel Ojeda
<[email protected]> wrote:
>
> We can use a trick today to approximate that, which is adding a
> comment after one of the commas, e.g.
>
> use crate::{
> fmt,
> page::AsPageIter, //
> };
Ok, I think that's pretty ugly, but as a "waiting for official support
for the magic comma", it's probably about the best we can do.
> By the way, I also took a very quick look at the "trailing comma" idea
> to see how complex it could be upstream (it could be either a "just
> accept the multiline formatting if there is a trailing comma" approach
> or the "take the comma as a hint to reformat accordingly" one
> mentioned), and it seems doable. But we will see what they think about
> it -- they don't have much bandwidth, I think.
I wonder how common the magic comma is in the python world - maybe
some Rust people are already familiar with the notion and it might be
an easy thing to convince them of.
Those python formatting tools may be _written_ in rust (well, at least
Ruff seems to be), but I don't know if there's much cross-pollination
of ideas.
> I ran a quick test for the reformatting approach on the kernel, and
> the diff isn't terribly big (e.g. +183 -45). One gets things like [1]
> -- notice how the nested one (`property::`) is kept as a one liner
> because there is no comma there, but the others are reformatted as
> vertical on purpose. And if one adds a comma after `NArgs`, then it
> will make it multiline.
That example change looks sensible to me.
Although that example actually made me go "WTF?" regardless of the
changes involved.
I clearly do not understand the sorting rules either. Why are the
"device::" entries not sorted?
Linus