Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust doesn't support Emojis for variable names #18982

Closed
kparaju opened this issue Nov 15, 2014 · 4 comments
Closed

Rust doesn't support Emojis for variable names #18982

kparaju opened this issue Nov 15, 2014 · 4 comments
Labels
F-non_ascii_idents `#![feature(non_ascii_idents)]`

Comments

@kparaju
Copy link

kparaju commented Nov 15, 2014

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`.
@bstrie
Copy link
Contributor

bstrie commented Nov 15, 2014

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.

@bstrie bstrie closed this as completed Nov 15, 2014
@LenaWil
Copy link

LenaWil commented Nov 21, 2019

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

@Centril Centril added the F-non_ascii_idents `#![feature(non_ascii_idents)]` label Nov 23, 2019
@Artoria2e5
Copy link
Contributor

Artoria2e5 commented Apr 21, 2021

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
Copy link

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

lnicola pushed a commit to lnicola/rust that referenced this issue Jan 20, 2025
Extract variable assist triggers less eagerly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-non_ascii_idents `#![feature(non_ascii_idents)]`
Projects
None yet
Development

No branches or pull requests

6 participants