Skip to content

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

Open
@interactive-toast

Description

@interactive-toast

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-UnicodeArea: UnicodeA-fmtArea: `core::fmt`A-proc-macrosArea: Procedural macrosC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions