Emit delayed bug during wfck for stranded opaque #148173
Open
+83
−0
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