about summary refs log tree commit diff
path: root/src/test/ui/parser
diff options
context:
space:
mode:
authorEsteban Kuber <esteban@kuber.com.ar>2021-08-29 08:34:23 +0000
committerEsteban Kuber <esteban@kuber.com.ar>2021-11-23 20:35:07 +0000
commit5a68abb0943e687cc6c8165376b4ed6deda17db3 (patch)
treed3fb75d0d5d4be7be5e4e1cf665c94da12ed647b /src/test/ui/parser
parent311fa1f14dd8ffbbe83b229a94b17f7f1ecaf33b (diff)
downloadrust-5a68abb0943e687cc6c8165376b4ed6deda17db3.tar.gz
rust-5a68abb0943e687cc6c8165376b4ed6deda17db3.zip
Tokenize emoji as if they were valid indentifiers
In the lexer, consider emojis to be valid identifiers and reject
them later to avoid knock down parse errors.
Diffstat (limited to 'src/test/ui/parser')
-rw-r--r--src/test/ui/parser/emoji-identifiers.rs16
-rw-r--r--src/test/ui/parser/emoji-identifiers.stderr72
2 files changed, 88 insertions, 0 deletions
diff --git a/src/test/ui/parser/emoji-identifiers.rs b/src/test/ui/parser/emoji-identifiers.rs
new file mode 100644
index 00000000000..2f4df4cf216
--- /dev/null
+++ b/src/test/ui/parser/emoji-identifiers.rs
@@ -0,0 +1,16 @@
+struct ABig๐Ÿ‘ฉโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘งFamily; //~ ERROR identifiers cannot contain emojis
+struct ๐Ÿ‘€; //~ ERROR identifiers cannot contain emojis
+impl ๐Ÿ‘€ {
+    fn full_of_โœจ() -> ๐Ÿ‘€ { //~ ERROR identifiers cannot contain emojis
+        ๐Ÿ‘€
+    }
+}
+fn i_like_to_๐Ÿ˜…_a_lot() -> ๐Ÿ‘€ { //~ ERROR identifiers cannot contain emojis
+    ๐Ÿ‘€::full_ofโœจ() //~ ERROR no function or associated item named `full_ofโœจ` found for struct `๐Ÿ‘€`
+    //~^ ERROR identifiers cannot contain emojis
+}
+fn main() {
+    let _ = i_like_to_๐Ÿ˜„_a_lot(); //~ ERROR cannot find function `i_like_to_๐Ÿ˜„_a_lot` in this scope
+    //~^ ERROR identifiers cannot contain emojis
+}
+
diff --git a/src/test/ui/parser/emoji-identifiers.stderr b/src/test/ui/parser/emoji-identifiers.stderr
new file mode 100644
index 00000000000..3b17bb01de9
--- /dev/null
+++ b/src/test/ui/parser/emoji-identifiers.stderr
@@ -0,0 +1,72 @@
+error[E0425]: cannot find function `i_like_to_๐Ÿ˜„_a_lot` in this scope
+  --> $DIR/emoji-identifiers.rs:13:13
+   |
+LL | fn i_like_to_๐Ÿ˜…_a_lot() -> ๐Ÿ‘€ {
+   | ----------------------------- similarly named function `i_like_to_๐Ÿ˜…_a_lot` defined here
+...
+LL |     let _ = i_like_to_๐Ÿ˜„_a_lot();
+   |             ^^^^^^^^^^^^^^^^^^ help: a function with a similar name exists: `i_like_to_๐Ÿ˜…_a_lot`
+
+error: identifiers cannot contain emojis: `i_like_to_๐Ÿ˜„_a_lot`
+  --> $DIR/emoji-identifiers.rs:13:13
+   |
+LL |     let _ = i_like_to_๐Ÿ˜„_a_lot();
+   |             ^^^^^^^^^^^^^^^^^^
+
+error: identifiers cannot contain emojis: `full_of_โœจ`
+  --> $DIR/emoji-identifiers.rs:4:8
+   |
+LL |     fn full_of_โœจ() -> ๐Ÿ‘€ {
+   |        ^^^^^^^^^^
+
+error: identifiers cannot contain emojis: `full_ofโœจ`
+  --> $DIR/emoji-identifiers.rs:9:8
+   |
+LL |     ๐Ÿ‘€::full_ofโœจ()
+   |         ^^^^^^^^^
+
+error: identifiers cannot contain emojis: `๐Ÿ‘€`
+  --> $DIR/emoji-identifiers.rs:2:8
+   |
+LL | struct ๐Ÿ‘€;
+   |        ^^
+LL | impl ๐Ÿ‘€ {
+   |      ^^
+LL |     fn full_of_โœจ() -> ๐Ÿ‘€ {
+   |                        ^^
+LL |         ๐Ÿ‘€
+   |         ^^
+...
+LL | fn i_like_to_๐Ÿ˜…_a_lot() -> ๐Ÿ‘€ {
+   |                            ^^
+LL |     ๐Ÿ‘€::full_ofโœจ()
+   |     ^^
+
+error: identifiers cannot contain emojis: `i_like_to_๐Ÿ˜…_a_lot`
+  --> $DIR/emoji-identifiers.rs:8:4
+   |
+LL | fn i_like_to_๐Ÿ˜…_a_lot() -> ๐Ÿ‘€ {
+   |    ^^^^^^^^^^^^^^^^^^
+
+error: identifiers cannot contain emojis: `ABig๐Ÿ‘ฉโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘งFamily`
+  --> $DIR/emoji-identifiers.rs:1:8
+   |
+LL | struct ABig๐Ÿ‘ฉโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘งFamily;
+   |        ^^^^^^^^^^^^^^^^^^
+
+error[E0599]: no function or associated item named `full_ofโœจ` found for struct `๐Ÿ‘€` in the current scope
+  --> $DIR/emoji-identifiers.rs:9:8
+   |
+LL | struct ๐Ÿ‘€;
+   | ---------- function or associated item `full_ofโœจ` not found for this
+...
+LL |     ๐Ÿ‘€::full_ofโœจ()
+   |         ^^^^^^^^^
+   |         |
+   |         function or associated item not found in `๐Ÿ‘€`
+   |         help: there is an associated function with a similar name: `full_of_โœจ`
+
+error: aborting due to 8 previous errors
+
+Some errors have detailed explanations: E0425, E0599.
+For more information about an error, try `rustc --explain E0425`.