diff options
| author | bors <bors@rust-lang.org> | 2021-11-25 08:16:08 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-11-25 08:16:08 +0000 |
| commit | 23a436606b118bd2fbb12f64fce21e7f9d355349 (patch) | |
| tree | f7cdcfcb705dc416fd967deb4e89ad3184f282c4 /src/test/ui | |
| parent | c6eda7d8a7af3ef51311d3106874a7d8de994edc (diff) | |
| parent | d92916439c372967e4c12b7ece3c8d7e860a8777 (diff) | |
| download | rust-23a436606b118bd2fbb12f64fce21e7f9d355349.tar.gz rust-23a436606b118bd2fbb12f64fce21e7f9d355349.zip | |
Auto merge of #88781 - estebank:emoji-idents, r=oli-obk
Tokenize emoji as if they were valid identifiers In the lexer, consider emojis to be valid identifiers and reject them later to avoid knock down parse errors. Partially address #86102.
Diffstat (limited to 'src/test/ui')
| -rw-r--r-- | src/test/ui/parser/emoji-identifiers.rs | 16 | ||||
| -rw-r--r-- | src/test/ui/parser/emoji-identifiers.stderr | 83 |
2 files changed, 99 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..ef18939bbb8 --- /dev/null +++ b/src/test/ui/parser/emoji-identifiers.rs @@ -0,0 +1,16 @@ +struct ABig๐ฉโ๐ฉโ๐งโ๐งFamily; //~ ERROR identifiers cannot contain emoji +struct ๐; //~ ERROR identifiers cannot contain emoji +impl ๐ { + fn full_of_โจ() -> ๐ { //~ ERROR identifiers cannot contain emoji + ๐ + } +} +fn i_like_to_๐ _a_lot() -> ๐ { //~ ERROR identifiers cannot contain emoji + ๐::full_ofโจ() //~ ERROR no function or associated item named `full_ofโจ` found for struct `๐` + //~^ ERROR identifiers cannot contain emoji +} +fn main() { + let _ = i_like_to_๐_a_lot() โ 4; //~ ERROR cannot find function `i_like_to_๐_a_lot` in this scope + //~^ ERROR identifiers cannot contain emoji + //~| ERROR unknown start of token: \u{2796} +} diff --git a/src/test/ui/parser/emoji-identifiers.stderr b/src/test/ui/parser/emoji-identifiers.stderr new file mode 100644 index 00000000000..5f9263c4c13 --- /dev/null +++ b/src/test/ui/parser/emoji-identifiers.stderr @@ -0,0 +1,83 @@ +error: unknown start of token: \u{2796} + --> $DIR/emoji-identifiers.rs:13:33 + | +LL | let _ = i_like_to_๐_a_lot() โ 4; + | ^^ + | +help: Unicode character 'โ' (Heavy Minus Sign) looks like '-' (Minus/Hyphen), but it is not + | +LL | let _ = i_like_to_๐_a_lot() - 4; + | ~ + +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() โ 4; + | ^^^^^^^^^^^^^^^^^^ help: a function with a similar name exists: `i_like_to_๐ _a_lot` + +error: identifiers cannot contain emoji: `ABig๐ฉ๐ฉ๐ง๐งFamily` + --> $DIR/emoji-identifiers.rs:1:8 + | +LL | struct ABig๐ฉ๐ฉ๐ง๐งFamily; + | ^^^^^^^^^^^^^^^^^^ + +error: identifiers cannot contain emoji: `๐` + --> $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 emoji: `full_of_โจ` + --> $DIR/emoji-identifiers.rs:4:8 + | +LL | fn full_of_โจ() -> ๐ { + | ^^^^^^^^^^ + +error: identifiers cannot contain emoji: `i_like_to_๐ _a_lot` + --> $DIR/emoji-identifiers.rs:8:4 + | +LL | fn i_like_to_๐ _a_lot() -> ๐ { + | ^^^^^^^^^^^^^^^^^^ + +error: identifiers cannot contain emoji: `full_ofโจ` + --> $DIR/emoji-identifiers.rs:9:8 + | +LL | ๐::full_ofโจ() + | ^^^^^^^^^ + +error: identifiers cannot contain emoji: `i_like_to_๐_a_lot` + --> $DIR/emoji-identifiers.rs:13:13 + | +LL | let _ = i_like_to_๐_a_lot() โ 4; + | ^^^^^^^^^^^^^^^^^^ + +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 9 previous errors + +Some errors have detailed explanations: E0425, E0599. +For more information about an error, try `rustc --explain E0425`. |
