Updating dependency caused type inference to fail on unrelated code #44345
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Note: This is not a bug. This is a case that I ran into that was difficult to debug, and extremely confusing. In the interest of the ergonomics initiative, I wanted to report it. However, rustc is behaving as expected. Feel free to close this at your leisure.
At some point last night, Diesel's builds suddenly started failing for no apparent reason. This line was failing to infer that the
_
there isbool
(theVec
annotation is cruft from back when there needed to be acollect
call as well). It was especially baffling, because the test above it is nearly identical, and this line was compiling just fine.Eventually after cleaning up some build output and diffing it, we found that the only thing that had changed was a new version of
serde_json
being released. That led us to this commit, which made the reason for the failure much more obvious.Nobody really did anything wrong here. Implementing a non-fundamental trait is defined as a minor breaking change in RFC #1105. However, the failure was extremely non-local and confusing. We were convinced this was a bug in rustc for a few hours until we finally tracked it down.
While there is no bug, I think two things could have improved this situation. First, I think we should consider amending that RFC so that implementing a trait which is not part of your crate for a type which is not part of your crate to be considered a major breaking change, as any code it breaks will be code which does not interact with that crate.
Secondly, I wonder if the error message could give some more diagnostic output here. If the message listed the impls of
PartialEq
forbool
, this would have been immediately clear what had happened.The text was updated successfully, but these errors were encountered: