-
Notifications
You must be signed in to change notification settings - Fork 14k
Emit delayed bug during wfck for stranded opaque #148173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
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
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
WG-trait-system-refactor
The Rustc Trait System Refactor Initiative (-Znext-solver)
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