rust-lang / rust-lang/rustfmt

Use Unicode string comparison for sortable identifiers

Open
#5,075 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-feature-request P-low
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
2d 13h
Merged PRs (30d)
24

Description

Rust supports Unicode identifiers (https://rust-lang.github.io/rfcs/2457-non-ascii-idents.html). I think it would make sense for rustfmt to sort identifiers according to Unicode collation rather than Unicode codepoint ordering.

The following code:

use example::{e, é, f};

Is formatted like this:

use example::{e, f, é};

As é is later in Unicode than f.

I think it would make sense to for it to be ordered like {e, é, f}.

Different languages have different collations. It would useful for rustfmt to provide an option to configure locale with a default setting und (which is good enough for most languages).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by examining rustfmt's current identifier-sorting behavior and the linked Unicode identifiers RFC. Define how configurable locale collation, including the default und setting, should affect the example import ordering; done means the behavior and configuration are specified and verified for Unicode identifiers.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.