Skip to content

Rustfmt wrongly alphabatizes raw identifiers in use statements #5362

Closed
@InsertCreativityHere

Description

@InsertCreativityHere

Description

I'm writing a toy compiler, and recently split up the elements of my grammar into their own modules.
Unfortunately, there's overlap between the elements and some Rust keywords, so sometimes I need to use raw identifiers:

use self::r#enum::*;
use self::interface::*;
use self::struct::*;

I would expect these to be sorted alphabetically, not including the r#
But, rustfmt seems to include it when sorting, and changes this to:

use self::interface::*;
use self::r#enum::*;
use self::struct::*;

Note that this doesn't happen with modules:

mod r#enum;
mod interface;
mod struct;

here rustfmt correctly ignores the r# prefix when sorting.

I'm open to fixing this, if someone could point me in the right direction! Since it seems *crosses fingers* like an easy fix.

Environment

rustfmt 1.4.38-nightly (e0944922 2022-05-31) on macOS Monterey

Metadata

Metadata

Assignees

No one assigned

    Labels

    1x-backport:pendingFixed/resolved in source but not yet backported to a 1x branch and releasea-imports`use` syntaxduplicate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions