-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Tokenize emoji as if they were valid identifiers #88781
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5a68abb
Tokenize emoji as if they were valid indentifiers
estebank a96fe02
Replace ZWJ with nothing in terminal output
estebank 20b69e6
Fix RustDoc
estebank 081198a
Add `unic-emoji-char` and its dependencies to the allow list
estebank 4489aeb
fix fmt
estebank 21224e6
Account for confusable codepoints when recovering emoji identifiers
estebank d68add9
review comment: plural of emoji is emoji
estebank 143f784
`replace_tabs` -> `normalize_whitespace`
estebank 38979a3
udpate comment to be more accurate
estebank 5402e48
Sort `FxHashSet`'s contents before emitting errors for consistent output
estebank d929164
Update cargo to fix tokenizer test affected by tokenizing emoji
estebank File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hash maps are great, until they aren't XD
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried using it's API, but it really doesn't fit well with this case. I'm sorting the output before emitting the diagnostic instead.