Repository navigation
Fix no-panic link failure for non-constant u32/u64/u128 - #72
Open
patrick-immometrica wants to merge 1 commit into
Open
patrick-immometrica wants to merge 1 commit into
patrick-immometrica wants to merge 1 commit into
Conversation
The tests only formatted constants, so the no-panic build in CI folded every call away and never linked a real Unsigned::fmt. With a runtime value, u32/u64/u128 (and i32/i128/usize) fail to link with no-panic enabled because of the bounds checks on buf.
patrick-immometrica
marked this pull request as ready for review
November 5, 2026 10:31
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
With the
no-panicfeature enabled, formatting a value that isn't a compile-time constant fails to link for u32, u64, u128, i32, i128 and usize:It's the bounds checks on
buf[offset]in the digit loops. LLVM can't proveoffsetstays in range, sopanic_bounds_checkstays in the binary. u8/u16/i8/i16/i64/isize happen to link fine.CI didn't catch this because the tests only format literals, so in the release build every call folds away and there's nothing left to check. The test macro now passes the value through
black_box. Without the fix,cargo build --tests --features no-panic --releasefails; with it, it passes.The fix uses
get_unchecked_mutfor those writes, as the table lookups next to them already do. I checked a downstream crate on aarch64 and x86_64 macOS: all 12 types link with no-panic now. There's no measurable difference in speed.