Adding a trait impl for an integer type causes existing code to break with misleading error #138402
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Code
Playground
Current output
Desired output
Rationale and extra context
This appears to be an edge case in the type resolver. When only one integer type implements the necessary trait, the compiler can correctly infer that a bare integer literal must be of that type. However, when an implementation of that trait for a second integer type is added, it breaks existing user code because the type resolver is obligated to fall back to treating bare integer literals as
i32
.The current diagnostic output doesn't explain why it's talking about
i32
, and users will likely be very surprised that adding a trait implementation breaks their build.Other cases
Rust Version
Anything else?
No response
The text was updated successfully, but these errors were encountered: