Skip to content

sort integer suffix as a whole number rather than by individual digits in arbitrary_source_item_ordering #15129

Open
@amab8901

Description

@amab8901

Summary

if two items have different integer suffixes but identical everywhere to the left of the integer suffix, then I think the arbitrary_source_item_ordering lint should apply the numerical ordering of the entire suffixed integer as a whole number (rather than its individual digits).

Lint Name

arbitrary_source_item_ordering

Reproducer

I tried this code:

pub(crate) enum ByteType {
    Uint8,
    Uint16,
    Uint32,
    Uint64,
}

I saw this happen:

lint triggered:

incorrect ordering of items (must be alphabetically ordered)

I expected to see this happen:
lint should be silent

Version

rustc 1.87.0 (17067e9ac 2025-05-09)
binary: rustc
commit-hash: 17067e9ac6d7ecb70e50f92c1944e545188d2359
commit-date: 2025-05-09
host: x86_64-unknown-linux-gnu
release: 1.87.0
LLVM version: 20.1.1

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messages

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions