Skip to content

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

Closed
@mattheww

Description

@mattheww
Contributor

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.

Activity

added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Apr 9, 2024
added
A-grammarArea: The grammar of Rust
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
and removed
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Apr 9, 2024
fmease

fmease commented on Apr 9, 2024

@fmease
Member

Regression from 1.57 to 1.58 (stable to stable). Very likely in #88781, cc @estebank.
Regression from error to pass. Previous error: unknown start of token: \u{1f41b}.

added
I-prioritizeIssue: Indicates that prioritization has been requested for this issue.
on Apr 9, 2024
apiraino

apiraino commented on Apr 10, 2024

@apiraino
Contributor

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-low

added
P-lowLow priority
and removed
I-prioritizeIssue: Indicates that prioritization has been requested for this issue.
on Apr 10, 2024
self-assigned this
on Apr 10, 2024
added a commit that references this issue on Apr 10, 2024
92debb1

12 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

    Participants

    @mattheww@estebank@apiraino@fmease@rustbot

    Issue actions

      Rust 2015 and 2018 allow emoji in identifiers in "Unknown prefix" position · Issue #123696 · rust-lang/rust