Skip to content

Rust doesn't support Emojis for variable names #18982

Closed
@kparaju

Description

@kparaju

Rust currently doesn't support emojis for variable names. Is there any plans to include this feature?

➜  servo git:(mime-sniffing-one-sniffertask) ✗ ./mach build                                 
Compiling net v0.0.1 (file:///Users/kparaju/Documents/repos/servo)
resource_task.rs:224:13: 224:14 error: unknown start of token: \U0001f443
resource_task.rs:224         let 👃 = sniffer_task::new_sniffer_task();
                                 ^
Could not compile `net`.

Activity

bstrie

bstrie commented on Nov 15, 2014

@bstrie
Contributor

Sadly, at this time Rust only intends to support the subset of emotions that can be derived from UAX 31, and only then by employing a feature flag. You'll have to put some effort into your emoji, I'm afraid. For example:

#![feature(non_ascii_idents)]
#![allow(non_snake_case)]  // ㅋㅋㅋㅋ

fn main() {
    ಠ_ಠ();
}

fn ಠ_ಠ() {
    println!("Hello, 世界");
}

Post 1.0 I expect that we can consider expanding the definition of what is permitted within Unicode identifiers, though it would have to proceed through the RFC process.

LenaWil

LenaWil commented on Nov 21, 2019

@LenaWil

Related RFC for those getting here through Google: #55467.

Artoria2e5

Artoria2e5 commented on Apr 21, 2021

@Artoria2e5
Contributor

I am of the opinion that this issue should be reopened in light of the RFC being stabilized. As the friendly C++ folks noted on their report about adopting UAX #31 for C++:

6.3 Does not allow emoji

class \U0001F4A9 : public std::exception {};

Throwing “PILE OF POO” becomes ill-formed. Conference slide-ware will be less entertaining.

The same 💩 emoji is rejected by rust precisely due to UAX-31, and arguably it makes stuff less fun than what Swift allows :Q (On the other hand, it does render the point about emoji width calculation on the RFC moot!)

flipbit03

flipbit03 commented on Mar 9, 2024

@flipbit03

I don't see the issue with emoji or any unicode identifiers. It's just a code point after all.

added a commit that references this issue on Jan 20, 2025

Merge pull request rust-lang#18982 from Veykril/push-lstmvzsowxyt

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @kparaju@Centril@bstrie@flipbit03@LenaWil

        Issue actions

          Rust doesn't support Emojis for variable names · Issue #18982 · rust-lang/rust