Skip to content

feat(num): improve error messages for TryFromIntError#156225

Open
sorairolake wants to merge 1 commit intorust-lang:mainfrom
sorairolake:improve-try-from-int-error-description
Open

feat(num): improve error messages for TryFromIntError#156225
sorairolake wants to merge 1 commit intorust-lang:mainfrom
sorairolake:improve-try-from-int-error-description

Conversation

@sorairolake
Copy link
Copy Markdown
Contributor

@sorairolake sorairolake commented May 6, 2026

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

Change to display more detailed error messages based on `IntErrorKind`.
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels May 6, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 6, 2026

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @scottmcm, libs
  • @scottmcm, libs expanded to 8 candidates
  • Random selection from Mark-Simulacrum, jhpratt, nia-e, scottmcm

@sorairolake
Copy link
Copy Markdown
Contributor Author

@rustbot label +T-libs-api -T-libs
r? libs-api

@rustbot rustbot added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed T-libs Relevant to the library team, which will review and decide on the PR/issue. labels May 6, 2026
@rustbot rustbot assigned dtolnay and unassigned Mark-Simulacrum May 6, 2026
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-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants