Uh oh!
There was an error while loading. Please reload this page.
Add _value API for number literals in proc-macro - #154608
Conversation
This comment has been minimized.
This comment has been minimized.
ae03536 to
7cb03fdCompareGuillaumeGomez
commented
Mar 31, 2026
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
c755b56CompareGuillaumeGomez
commented
Mar 31, 2026
Bug comes from an issue with GCC proc-macro ABI. Ignoring this test on GCC backend for now. |
GuillaumeGomez
commented
Mar 31, 2026
CI fixed. :) |
Urgau
commented
Mar 31, 2026
A libs (or maybe even libs-api) reviewer seems more appropriate to review this PR. r? Amanieu (since you reviewed #136355) |
Urgau
commented
Mar 31, 2026
I missed it already has an accepted ACP. The PR can be reviewed by libs reviewer. r? libs |
Uh oh!
There was an error while loading. Please reload this page.
| 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.
There was a problem hiding this comment.
I think my question is not about specific code in rustc but rather whether the implementation here parses exactly the same literals that rustc would from the given token(s). Is that the case? Essentially, can we document these functions as being bug-for-bug compatible with what rustc would do, or do we need a separate grammar for this?
There was a problem hiding this comment.
At this point, the compiler already ran on the literal so all errors have been checked already. The remaining potential errors mostly come from trying to convert a int/float not fitting the expected output.
Uh oh!
There was an error while loading. Please reload this page.
c755b56 to
ebb3161Compare
This comment has been minimized.
This comment has been minimized.
GuillaumeGomez
commented
Apr 10, 2026
Added the method for |
GuillaumeGomez
commented
May 12, 2026
Forgot to change the status. @rustbot ready |
Mark-Simulacrum
commented
May 31, 2026
Can you reply to my comment here? #154608 (comment) @rustbot author |
GuillaumeGomez
commented
Jun 2, 2026
Forgot to do so. Answered it. @rustbot ready |
e673d20 to
bd4bf50CompareGuillaumeGomez
commented
Jun 7, 2026
@bors try jobs=x86_64-mingw-1 |
This comment has been minimized.
This comment has been minimized.
…=<try> Add `_value` API for number literals in proc-macro try-job: x86_64-mingw-1
This comment has been minimized.
This comment has been minimized.
bd4bf50 to
48c52aeCompare💔 Test for f7e180c failed: CI. Failed job:
|
rust-log-analyzer
commented
Jun 7, 2026
The job Click to see the possible cause of the failure (guessed by this bot) |
GuillaumeGomez
commented
Jun 7, 2026
@bors try jobs=x86_64-mingw-1 |
This comment has been minimized.
This comment has been minimized.
…=<try> Add `_value` API for number literals in proc-macro try-job: x86_64-mingw-1
GuillaumeGomez
commented
Jun 8, 2026
@bors r=Mark-Simulacrum rollup |
…acro_API, r=Mark-Simulacrum Add `_value` API for number literals in proc-macro Part of rust-lang#136652. This PR adds the `*_value` for numbers (integers and floats). However, `f16` and `f128` are 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
…uwer Rollup of 13 pull requests Successful merges: - #147302 (asm! support for the Xtensa architecture) - #148820 (Add very basic "comptime" fn implementation) - #157299 (Fix unstable diagnostics in tests) - #143511 (Improve TLS codegen by marking the panic/init path as cold) - #154608 (Add `_value` API for number literals in proc-macro) - #156762 (xfs support in `test_rename_directory_to_non_empty_directory`) - #157300 (Relax test requirements for consistency) - #157383 (tests: codegen-llvm: Ignore BPF targets in c-variadic-opt) - #157413 (fix: don't suggest .into_iter() for .cloned()/.copied() on non-reference Option) - #157578 (Fix diagnostics for non-exhaustive destructuring assignments (#157553)) - #157587 (explain that the size_of constant also serves to avoid optimizing away 'unused' size_of calls) - #157596 (test: remove ineffective link-extern-crate-with-drop-type test) - #157602 (rustdoc: Remove unnecessary fast path)
Uh oh!
There was an error while loading. Please reload this page.
Rollup merge of #154608 - GuillaumeGomez:number_value_proc-macro_API, r=Mark-Simulacrum Add `_value` API for number literals in proc-macro Part of #136652. This PR adds the `*_value` for numbers (integers and floats). However, `f16` and `f128` are 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
panstromek
commented
Jun 15, 2026
@rust-timer build 35f7c69 |
This comment has been minimized.
This comment has been minimized.
rust-timer
commented
Jun 15, 2026
Finished benchmarking commit (35f7c69): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up. @rustbot label: -S-waiting-on-perf -perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -5.0%, secondary 6.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary 3.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 1.6%, secondary 1.8%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 517.572s -> 516.06s (-0.29%) |
…uwer Rollup of 13 pull requests Successful merges: - rust-lang/rust#147302 (asm! support for the Xtensa architecture) - rust-lang/rust#148820 (Add very basic "comptime" fn implementation) - rust-lang/rust#157299 (Fix unstable diagnostics in tests) - rust-lang/rust#143511 (Improve TLS codegen by marking the panic/init path as cold) - rust-lang/rust#154608 (Add `_value` API for number literals in proc-macro) - rust-lang/rust#156762 (xfs support in `test_rename_directory_to_non_empty_directory`) - rust-lang/rust#157300 (Relax test requirements for consistency) - rust-lang/rust#157383 (tests: codegen-llvm: Ignore BPF targets in c-variadic-opt) - rust-lang/rust#157413 (fix: don't suggest .into_iter() for .cloned()/.copied() on non-reference Option) - rust-lang/rust#157578 (Fix diagnostics for non-exhaustive destructuring assignments (rust-lang/rust#157553)) - rust-lang/rust#157587 (explain that the size_of constant also serves to avoid optimizing away 'unused' size_of calls) - rust-lang/rust#157596 (test: remove ineffective link-extern-crate-with-drop-type test) - rust-lang/rust#157602 (rustdoc: Remove unnecessary fast path)
View all comments
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