feat(num): improve error messages for TryFromIntError#156225
Merged
rust-bors[bot] merged 1 commit intoJul 21, 2026
Merged
Conversation
Change to display more detailed error messages based on `IntErrorKind`.
Collaborator
|
rustbot has assigned @Mark-Simulacrum. Use Why was this reviewer chosen?The reviewer was selected based on:
|
Contributor
Author
|
@rustbot label +T-libs-api -T-libs |
Member
|
@bors r+ |
Contributor
rust-bors Bot
pushed a commit
that referenced
this pull request
Jul 21, 2026
…uwer Rollup of 7 pull requests Successful merges: - #155617 (Replace `jemalloc` bootstrap options with `override-allocator`) - #156225 (feat(num): improve error messages for `TryFromIntError`) - #159058 (implement #![feature(macroless_generic_const_args)]) - #159435 (core: implement `Rng` for references) - #159471 (Make `Global` and `System` allocators unstably implement `const Clone + const Default`.) - #159590 (Remove some dead code) - #159636 (Improve some comments (and an error message))
rust-timer
added a commit
that referenced
this pull request
Jul 21, 2026
Rollup merge of #156225 - sorairolake:improve-try-from-int-error-description, r=dtolnay feat(num): improve error messages for `TryFromIntError` - Tracking issue: #153978 This pull request improves the `Display` trait implementation for `TryFromIntError` by providing more specific error messages based on the underlying `IntErrorKind`. Currently, the error message is always `"out of range integral type conversion attempted"`. This makes debugging difficult because users cannot distinguish the detailed cause of the error from the error message. `IntErrorKind::Empty` and `IntErrorKind::InvalidDigit` should be unreachable. I don't think this is breaking changes, because similar changes were made in the past in #96168. See also: <https://users.rust-lang.org/t/are-changes-to-fmt-display-considered-breaking/59775>
github-actions Bot
pushed a commit
to rust-lang/rustc-dev-guide
that referenced
this pull request
Jul 23, 2026
…uwer Rollup of 7 pull requests Successful merges: - rust-lang/rust#155617 (Replace `jemalloc` bootstrap options with `override-allocator`) - rust-lang/rust#156225 (feat(num): improve error messages for `TryFromIntError`) - rust-lang/rust#159058 (implement #![feature(macroless_generic_const_args)]) - rust-lang/rust#159435 (core: implement `Rng` for references) - rust-lang/rust#159471 (Make `Global` and `System` allocators unstably implement `const Clone + const Default`.) - rust-lang/rust#159590 (Remove some dead code) - rust-lang/rust#159636 (Improve some comments (and an error message))
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.
try_from_int_error_kind#153978This pull request improves the
Displaytrait implementation forTryFromIntErrorby providing more specific error messages based on the underlyingIntErrorKind.Currently, the error message is always
"out of range integral type conversion attempted". This makes debugging difficult because users cannot distinguish the detailed cause of the error from the error message.IntErrorKind::EmptyandIntErrorKind::InvalidDigitshould be unreachable.I don't think this is breaking changes, because similar changes were made in the past in #96168.
See also: https://users.rust-lang.org/t/are-changes-to-fmt-display-considered-breaking/59775