On Tue, Oct 7, 2025 at 8:35 PM Linus Torvalds
<[email protected]> wrote:
>
> 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?

Essentially, `self` (a special case) is placed first, then it puts
things like modules (i.e. `lower_case`), then things like types (i.e.
`CamelCase`), and then things like constants (i.e. `UPPERCASE`):

    use crate::{
        self, myitem1,
        myitem1::{myitem2, MyItem2, MYITEM2},
        myitem3, MyItem1,
        MyItem1::{myitem2, MyItem2, MYITEM2},
        MyItem3, MYITEM1,
        MYITEM1::{myitem2, MyItem2, MYITEM2},
        MYITEM3,
    };

This got substantially changed for the next edition (2024), though --
they decided to just do version sorting (I added a 256 to show that
too):

    use crate::{
        self, MYITEM1,
        MYITEM1::{MYITEM2, MyItem2, myitem2},
        MYITEM3, MyItem1,
        MyItem1::{MYITEM2, MyItem2, myitem2},
        MyItem3, myitem1,
        myitem1::{MYITEM2, MyItem2, myitem2},
        myitem3, myitem256,
    };

https://github.com/rust-lang/rust/issues/123800

You can play with the new one in Compiler Explorer (right-click ->
Format Document).

Cheers,
Miguel

Reply via email to