Skip to content

Commit fdf3c0f

Browse files
authored
Rollup merge of #101966 - crlf0710:emoji_unittest, r=Mark-Simulacrum
Add unit test for identifier Unicode emoji diagnostics Seems current diagnostics has some support for emoji usages, however it seems outdated and incomplete. This adds a simple unit test to showcase the status quo.
2 parents 9f073b0 + d381d8e commit fdf3c0f

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
fn invalid_emoji_usages() {
2+
let arrow↔️ = "basic emoji"; //~ ERROR: identifiers cannot contain emoji
3+
// FIXME
4+
let planet🪐 = "basic emoji"; //~ ERROR: unknown start of token
5+
// FIXME
6+
let wireless🛜 = "basic emoji"; //~ ERROR: unknown start of token
7+
// FIXME
8+
let key1️⃣ = "keycap sequence"; //~ ERROR: unknown start of token
9+
//~^ WARN: identifier contains uncommon Unicode codepoints
10+
let flag🇺🇳 = "flag sequence"; //~ ERROR: identifiers cannot contain emoji
11+
let wales🏴 = "tag sequence"; //~ ERROR: identifiers cannot contain emoji
12+
let folded🙏🏿 = "modifier sequence"; //~ ERROR: identifiers cannot contain emoji
13+
}
14+
15+
fn main() {
16+
invalid_emoji_usages();
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
error: unknown start of token: \u{1fa90}
2+
--> $DIR/lex-emoji-identifiers.rs:4:15
3+
|
4+
LL | let planet🪐 = "basic emoji";
5+
| ^^
6+
7+
error: unknown start of token: \u{1f6dc}
8+
--> $DIR/lex-emoji-identifiers.rs:6:17
9+
|
10+
LL | let wireless🛜 = "basic emoji";
11+
| ^^
12+
13+
error: unknown start of token: \u{20e3}
14+
--> $DIR/lex-emoji-identifiers.rs:8:14
15+
|
16+
LL | let key1️⃣ = "keycap sequence";
17+
| ^
18+
19+
error: identifiers cannot contain emoji: `arrow↔️`
20+
--> $DIR/lex-emoji-identifiers.rs:2:9
21+
|
22+
LL | let arrow↔️ = "basic emoji";
23+
| ^^^^^^
24+
25+
error: identifiers cannot contain emoji: `flag🇺🇳`
26+
--> $DIR/lex-emoji-identifiers.rs:10:9
27+
|
28+
LL | let flag🇺🇳 = "flag sequence";
29+
| ^^^^^^
30+
31+
error: identifiers cannot contain emoji: `wales🏴`
32+
--> $DIR/lex-emoji-identifiers.rs:11:9
33+
|
34+
LL | let wales🏴 = "tag sequence";
35+
| ^^^^^^^
36+
37+
error: identifiers cannot contain emoji: `folded🙏🏿`
38+
--> $DIR/lex-emoji-identifiers.rs:12:9
39+
|
40+
LL | let folded🙏🏿 = "modifier sequence";
41+
| ^^^^^^^^^^
42+
43+
warning: identifier contains uncommon Unicode codepoints
44+
--> $DIR/lex-emoji-identifiers.rs:8:9
45+
|
46+
LL | let key1️⃣ = "keycap sequence";
47+
| ^^^^
48+
|
49+
= note: `#[warn(uncommon_codepoints)]` on by default
50+
51+
error: aborting due to 7 previous errors; 1 warning emitted
52+

0 commit comments

Comments
 (0)