Skip to content

Conversation

@pascaldekloe
Copy link
Contributor

  • Formatting of floating-points centralised in fmt/float.rs

  • Drop of numfmt feature; no intermediate Part structure

  • FullDecoded step from omitted with num::FpCategory

  • MaybeUninit to str contained in grisu.rs & dragon.rs

  • Exponent in native bit-width (isize instead of i16)

  • Decode logic of floating-points explained in comments

  • Explicit fallback from Grisu to Dragon (with Option)

  • Abstraction between Grisu and Dragon in tests undone

  • Fixed buffer-size for formatting in "shortest" mode

  • Macro instead of traits for generic handling of types

  • FIX: check_exact macro missed check of last decimal

  • FIX: faulty values in *_sanity_test due to previous

    r? tgross35

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 22, 2025
@rustbot
Copy link
Collaborator

rustbot commented Dec 22, 2025

tgross35 is currently at their maximum review capacity.
They may take a while to respond.

@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Dec 22, 2025
@pascaldekloe
Copy link
Contributor Author

Refactor a little cascaded a little. 😅 I hope you are OK with such big change.

The new pad_number method on fmt::Formatter could be part of the core library.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@quaternic
Copy link
Contributor

@pascaldekloe

Refactor a little cascaded a little. 😅 I hope you are OK with such big change.

At +1,625 −3,292 (lines), this is quite large indeed, and as such, difficult to review. That is in part due to incorporating many different kinds of changes, which makes it hard to get an idea of what is actually being changed.

For one, parts of the diff seem to be just renames of functions or local variables, which would be easy to review if that's all it did. If the renames feel necessary for clarity, it would help to do them in a separate commit.

  • Formatting of floating-points centralised in fmt/float.rs

  • Drop of numfmt feature; no intermediate Part structure
    ...

These look like short commit descriptions. Did you have these as separate commits at some point?

@pascaldekloe
Copy link
Contributor Author

pascaldekloe commented Dec 23, 2025

Functions were renamed while changing the signature, @quaternic. Might as well use better names while making a change.

Logic separated in traits from num::flt2dec moved to the main macro_rules in fmt/float.rs.
Logic from num/flt2dec/mod.rs also moved to fmt/float.rs, without the use Part.
Those two moves cause the majority of the change. I didn't see a way in making that work in separate commits, as it both moves and changes the respective code.

Then I found out about how tests were reliant on abstraction. On hindsight I could have undone the abstraction in tests first, as a separate commit. Especially the broken test values would have been nice to see separate.

Changes in strategy (Grisu and Dragon) are readable as is I believe. Writing the unsafe all over the new code first, just to have it in a separate commit seemed like an overkill. The idea of making Parts use str without unsafe first before removing it wasn't any better.

@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-20-2 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)

---- fmt::test_format_macro_interface stdout ----
---- fmt::test_format_macro_interface stderr ----

thread 'main' (38522) panicked at library/core/src/num/flt2dec/strategy/grisu.rs:544:16:
attempt to subtract with overflow
stack backtrace:
   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic_const::panic_const_sub_overflow
   3: core::num::flt2dec::strategy::grisu::format_fixed
   4: core::fmt::float::fmt_enote_fixed
   5: core::fmt::float::fmt_exp_f64
   6: core::fmt::write
   7: alloc::fmt::format::format_inner
   8: alloc::fmt::format::{closure#0}
             at /checkout/obj/build/aarch64-unknown-linux-gnu/stage2-codegen/cg_clif/build/sysroot_tests/library/alloc/src/fmt.rs:654:34
   9: <core::option::Option<&str>>::map_or_else::<alloc::string::String, alloc::fmt::format::{closure#0}, <str as alloc::borrow::ToOwned>::to_owned>
             at /checkout/obj/build/aarch64-unknown-linux-gnu/stage2-codegen/cg_clif/build/sysroot_tests/library/core/src/option.rs:1278:21
  10: alloc::fmt::format
             at /checkout/obj/build/aarch64-unknown-linux-gnu/stage2-codegen/cg_clif/build/sysroot_tests/library/alloc/src/fmt.rs:654:5
  11: alloctests::fmt::test_format_macro_interface
             at ./tests/fmt.rs:150:8
---
    fmt::test_format_macro_interface

test result: FAILED. 844 passed; 1 failed; 28 ignored; 0 measured; 0 filtered out; finished in 1.05s

error: test failed, to rerun pass `-p alloctests --test alloctests`
env -u RUSTC_WRAPPER CARGO_ENCODED_RUSTDOCFLAGS="-Csymbol-mangling-version=v0\u{1f}-Zannotate-moves\u{1f}-Zrandomize-layout\u{1f}-Zunstable-options\u{1f}--check-cfg=cfg(bootstrap)\u{1f}-Dwarnings\u{1f}-Wrustdoc::invalid_codeblock_attributes\u{1f}--crate-version\u{1f}1.94.0-nightly\t(1d90ac41d\t2025-12-23)" CARGO_ENCODED_RUSTFLAGS="-Csymbol-mangling-version=v0\u{1f}-Zannotate-moves\u{1f}-Zrandomize-layout\u{1f}-Zunstable-options\u{1f}--check-cfg=cfg(bootstrap)\u{1f}-Zmacro-backtrace\u{1f}-Csplit-debuginfo=off\u{1f}-Clink-arg=-L/usr/lib/llvm-20/lib\u{1f}-Cllvm-args=-import-instr-limit=10\u{1f}-Clink-args=-Wl,-z,origin\u{1f}-Clink-args=-Wl,-rpath,$ORIGIN/../lib\u{1f}-Alinker-messages\u{1f}--cap-lints=allow\u{1f}--cfg\u{1f}randomized_layouts" RUSTC="/checkout/obj/build/aarch64-unknown-linux-gnu/stage2-codegen/cg_clif/dist/rustc-clif" RUSTDOC="/checkout/obj/build/aarch64-unknown-linux-gnu/stage2-codegen/cg_clif/dist/rustdoc-clif" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage0/bin/cargo" "test" "--manifest-path" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2-codegen/cg_clif/build/sysroot_tests/Cargo.toml" "--target-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2-codegen/cg_clif/build/sysroot_tests_target" "--locked" "--target" "aarch64-unknown-linux-gnu" "-p" "coretests" "-p" "alloctests" "--tests" "--" "-q" exited with status ExitStatus(unix_wait_status(25856))
Bootstrap failed while executing `--stage 2 test --skip tests --skip coverage-map --skip coverage-run --skip library --skip tidyselftest`
Command `/checkout/obj/build/aarch64-unknown-linux-gnu/stage0/bin/cargo run --target aarch64-unknown-linux-gnu -Zbinary-dep-depinfo -j 4 -Zroot-dir=/checkout --locked --color=always --release --manifest-path /checkout/compiler/rustc_codegen_cranelift/build_system/Cargo.toml -- test --download-dir /checkout/obj/build/cg_clif_download --out-dir /checkout/obj/build/aarch64-unknown-linux-gnu/stage2-codegen/cg_clif --no-unstable-features --use-backend cranelift --sysroot llvm --skip-test testsuite.extended_sysroot [workdir=/checkout/compiler/rustc_codegen_cranelift]` failed with exit code 1
Created at: src/bootstrap/src/core/build_steps/test.rs:3849:25
Executed at: src/bootstrap/src/core/build_steps/test.rs:3894:26

Command has failed. Rerun with -v to see more details.
Build completed unsuccessfully in 0:21:23
  local time: Tue Dec 23 19:41:38 UTC 2025
  network time: Tue, 23 Dec 2025 19:41:38 GMT
##[error]Process completed with exit code 1.
##[group]Run echo "disk usage:"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants