Emit delayed bug during wfck for stranded opaque#148173
Merged
bors merged 2 commits intorust-lang:masterfrom Oct 28, 2025
Merged
Emit delayed bug during wfck for stranded opaque#148173bors merged 2 commits intorust-lang:masterfrom
bors merged 2 commits intorust-lang:masterfrom
Conversation
Collaborator
Member
Author
|
r? @BoxyUwU |
BoxyUwU
reviewed
Oct 27, 2025
93f796d to
16dc78c
Compare
BoxyUwU
reviewed
Oct 28, 2025
This comment has been minimized.
This comment has been minimized.
2654c1a to
c797724
Compare
Member
|
@bors r+ rollup |
Collaborator
rust-timer
added a commit
that referenced
this pull request
Oct 28, 2025
Rollup merge of #148173 - tiif:fix-opaque-ice, r=BoxyUwU Emit delayed bug during wfck for stranded opaque Fixes rust-lang/trait-system-refactor-initiative#235 ## Problem The fundamental issue here is ``OpaqueTypeCollector`` operates on ``rustc_middle::Ty``, but ``check_type_wf`` operates on HIR. Since [check_type_wf](https://github.com/rust-lang/rust/blob/2f7620a5ccfea7d59d1f500e2a2e59cf1c867a1b/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 at https://github.com/rust-lang/rust/blob/34a8c7368c84fc699fc83a8851a02f93fd655931/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
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes rust-lang/trait-system-refactor-initiative#235
Problem
The fundamental issue here is
OpaqueTypeCollectoroperates onrustc_middle::Ty, butcheck_type_wfoperates on HIR.Since check_type_wf operates on HIR, it can see the stranded opaque and tries to infer it's hidden type. But
OpaqueTypeCollectoroperates onrustc_middle::Ty, so theOpaqueTypeCollectorcan no longer see a stranded opaque, hence its hidden type could not be inferred.As a result, the tests ICE'ed at
rust/compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs
Line 253 in 34a8c73
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
OpaqueTypeCollectorto be a HIR visitor instead of arustc_middle::Tyvisitor, but we believe a HIR-basedOpaqueTypeCollectorwill not work and might not worth the cost of rewriting.Acknowledgement
This PR is a joint effort with @BoxyUwU :3