rust-lang / rust-lang/rust

Identifiers with combining characters do not work as captured identifiers in `println!` format strings

Open
#137,063 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-fmt A-proc-macros A-Unicode C-bug T-compiler T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Identifiers with combining characters do not work as captured identifiers in println! format strings.

Minimal reproducible example

Identifier using combining characters([0x61, 0xCC, 0x80]) as a captured identifier

fn main() {
    let à = 100;
    println!("à = {à}");
}

I expected to see this happen:

Successful compilation

Instead, this happened:

error[E0425]: cannot find value `à` in this scope
 --> not_works.rs:3:21
  |
3 |     println!("à = {à}");
  |                    ^ not found in this scope

error: aborting due to 1 previous error

Other tests

Combining Characters Single Codepoint
Captured Identifier 🚫
Positional Argument
  1. Identifier using a single unicode codepoint([0xC3, 0xA0]) as a positional argument
fn main() {
    let à = 100;
    println!("à = {}", à);
}

This compiles and works as expected

  1. Identifier using combining characters([0x61, 0xCC, 0x80]) as a positional argument
fn main() {
    let à = 100;
    println!("à = {}", à);
}

This compiles and works as expected

  1. Identifier using a single unicode codepoint([0xC3, 0xA0]) as a captured identifier
fn main() {
    let à = 100;
    println!("à = {à}");
}

This compiles and works as expected

Meta

Using rust playground, I tested all these examples with stable, beta, and nightly.

1.84.1
1.85.0-beta.9 (2025-02-13 461de7492e5354419cf2)
1.86.0-nightly (2025-02-14 d8810e3e2dab96778d20)

Not sure if this is a known limitation but I couldn't find any info on it.

Seems like a unicode normalization issue.

Also, mixing a variable that is declared as combining characters and then used
as a single codepoint works, it's just combining characters as a captured
identifier that doesn't work.

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 with the minimal reproducer in the issue and compare captured identifiers containing combining characters with the working positional and single-codepoint cases. Trace the compiler entry point that resolves captured format-string identifiers and inspect how identifier normalization is handled. Done when the reproducer compiles and a regression test covers the combining-character case.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.