84adf0d8dd
PR #96746 fixed a very similar bug, so the same logic is used in a different place.
For high-level intro to how type checking works in rustc, see the type checking chapter of the rustc dev guide.