Add test for bad cast with deferred projection equality #108287
Merged
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.
Unification during coercion (
Coerce::unify
) needs to consider deferred projection obligations (at least pass over them withpredicate_may_hold
or something, to disqualify any totally wrong unifications) -- otherwise, we'll shallowly consider<u8 as Add>::Output
andchar
as coercible duringFnCtxt::try_coerce
, which will fail later when the nested obligations are registered and processed.Cast checking needs to be able to structurally normalize types so it sees
u8
instead of<u8 as Add>::Output
. Otherwise it'll always consider the latter as part of a non-primitive cast. CurrentlyFnCtxt::normalize
doesn't do anything useful here, interestingly.I tried looking into both of these and it's not immediately clear where to refactor existing typeck code to fix this (at least the latter), but I'm gonna commit a test for it at least so we don't forget. This is one of the issues that's keeping us from building larger projects.