-
Notifications
You must be signed in to change notification settings - Fork 1.9k
ra_syntax: removed code duplication and token reevaluation #2891
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
Conversation
| // and the comments on the linked PR. | ||
| let float_suffix_list = ["f32", "f64"]; | ||
| pub fn kind(&self) -> LiteralKind { | ||
| const INT_SUFFIXES: [&'static str; 12] = [ |
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.
FYI: There is a caveat.
If the language introduces new suffixes or user-defined suffixes (who knows)
You should ensure that suffixes in these arrays do not include each other as a substring at the end or replace .ends_with()
test with something more elaborated (or just order the suffixes properly to avoid a bug)
| .map(|&suffix| SmolStr::new(suffix)) | ||
| } | ||
|
|
||
| // The lexer treats e.g. `1f64` as an integer literal. See |
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.
I think this comment is useful. Without the comment it’s not necessarily obvious why we’d check float suffixes for a token of kind INT_NUMBER (and indeed the code incorrectly didn’t do this before the PR in which the comment was added).
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.
Nit (in case you touch this code again): "below".
matklad
left a comment
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.
bors r+
Nice cleanup!
Also, big 👍 on the general refactoring work, rust-analyzer can use a lot of that!
|
Hmm, strange, it runs well on my PC |
|
bors retry That's a known bug on windows (which existed before we've enabled CI on windows). This should pass CI. |
|
@Veetaha could you rebase this? Due to another issue with github actions/bors, I think this won't get past the bors. bors d+ |
|
✌️ Veetaha can now approve this pull request. To approve and merge a pull request, simply reply with |
|
bors retry please |
|
✌️ Veetaha can now approve this pull request. To approve and merge a pull request, simply reply with |
|
Thank you bors, now merge |
|
bors merge |
Build succeeded
|
Just a small refactoring along the way of reading the codebase