Emit delayed bug during wfck for stranded opaque Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/235 ## Problem The fundamental issue here is ``OpaqueTypeCollector`` operates on ``rustc_middle::Ty``, but ``check_type_wf`` operates on HIR. Since [check_type_wf](2f7620a5cc/compiler/rustc_hir_analysis/src/check/wfcheck.rs (L2262)) operates on HIR, it can see the stranded opaque and tries to infer it's hidden type. But ``OpaqueTypeCollector`` operates on ``rustc_middle::Ty``, so the ``OpaqueTypeCollector`` can no longer see a stranded opaque, hence its hidden type could not be inferred. As a result, the tests ICE'ed at34a8c7368c/compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs (L253)## Proposed solution This PR detects stranded opaque types during wf check and emit a delayed bug for it. ## Alternative solution `@BoxyUwU` and I had considered rewriting ``OpaqueTypeCollector`` to be a HIR visitor instead of a ``rustc_middle::Ty`` visitor, but we believe a HIR-based ``OpaqueTypeCollector`` will not work and might not worth the cost of rewriting. ## Acknowledgement This PR is a joint effort with `@BoxyUwU` :3
For high-level intro to how type checking works in rustc, see the type checking chapter of the rustc dev guide.