Add _value API for number literals in proc-macro#154608
Add _value API for number literals in proc-macro#154608GuillaumeGomez wants to merge 2 commits intorust-lang:mainfrom
_value API for number literals in proc-macro#154608Conversation
This comment has been minimized.
This comment has been minimized.
ae03536 to
7cb03fd
Compare
|
My favourite kind of failure: works locally but not in CI. T_T Updated the value in the tests to see which one exactly is failing. |
This comment has been minimized.
This comment has been minimized.
7cb03fd to
c755b56
Compare
|
Bug comes from an issue with GCC proc-macro ABI. Ignoring this test on GCC backend for now. |
|
CI fixed. :) |
|
A libs (or maybe even libs-api) reviewer seems more appropriate to review this PR. r? Amanieu (since you reviewed #136355) |
|
I missed it already has an accepted ACP. The PR can be reviewed by libs reviewer. r? libs |
library/proc_macro/src/lib.rs
Outdated
| Hexadecimal = 16, | ||
| } | ||
|
|
||
| fn parse_number(value: &str) -> (String, Base) { |
There was a problem hiding this comment.
Is this exactly in sync with what the rustc parser permits?
I guess that would be a mix of https://doc.rust-lang.org/nightly/reference/tokens.html#grammar-INTEGER_LITERAL and whatever we then tokenize from it?
Perhaps this should go over the bridge and ask rustc to parse the string for us?
There was a problem hiding this comment.
There is no code in rustc currently which would allow this conversion without including a lot of other things. My code is a simplified version of integer_lit (from rustc_ast/src/util/literal.rs) which parses both the number, its base and its suffix (which we already have) and returns a LitKind, which is also unnecessary here since we already know the end type.
c755b56 to
ebb3161
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
Added the method for |
Part of #136652.
This PR adds the
*_valuefor numbers (integers and floats). However,f16andf128are voluntarily left out as they're still unstable. Adding support for them is just a matter of uncommenting two lines, so should be fine.Setting same reviewer as last time.
r? @Urgau