Skip to content

Rust 2015 and 2018 allow emoji in identifiers in "Unknown prefix" position #123696

Closed
@mattheww

Description

@mattheww

In the 2015 and 2018 editions, the following compiles (with warnings):

macro_rules! lexes {($($_:tt)*) => {}}

lexes!(🐛#);
lexes!(🐛"foo");
lexes!(🐛'q');
lexes!(🐛'q);

playground

The 🐛 is taken as an identifier, although emoji aren't generally permitted in identifiers in any edition.

I tested with rustc 1.77.1.

I think the underlying problem is that ident_or_unknown_prefix() and fake_ident_or_unknown_prefix() in rustc_lexer distinguish "identifiers" containing emoji (as InvalidIdent rather than Ident), but don't have a way to make that distinction for UnknownPrefix.

Metadata

Metadata

Assignees

Labels

A-UnicodeArea: UnicodeA-grammarArea: The grammar of RustC-bugCategory: This is a bug.P-lowLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions