Skip to content

std::chars::Char::escape_unicode generates old-style \u and \U escapes, breaking syntax::print #19811

@emk

Description

@emk

CC @pnkfelix, #19739.

Thank you for your work on the Unicode escape migration! This is probably already on your to-do list, but I thought I'd submit a test-case just to be safe.

The following test case:

fn main() {
    let mut escaped = String::from_str("");
    for c in '\u{10401}'.escape_unicode() {
        escaped.push(c);
    }
    assert_eq!("\\u{10401}", escaped);
}

…gives us:

assertion failed: `(left == right) && (right == left)` (left: `\u{10401}`, right: `\U00010401`)

Among other things, this causes issues for syntax::print and rust-peg, as described in kevinmehall/rust-peg#34.

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions