Open
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 | ✅ | ✅ |
- Identifier using a single unicode codepoint(
[0xC3, 0xA0]
) as a positional argument
fn main() {
let à = 100;
println!("à = {}", à);
}
This compiles and works as expected
- Identifier using combining characters(
[0x61, 0xCC, 0x80]
) as a positional argument
fn main() {
let à = 100;
println!("à = {}", à);
}
This compiles and works as expected
- 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.