transmutability: Stall new solver when inference variables remain#149228
transmutability: Stall new solver when inference variables remain#149228lapla-cogito wants to merge 1 commit into
Conversation
|
It seems wrong to return an error here. It should not be impossible to transmute. We should instead stall somehow here. There should probably just be an |
|
☔ The latest upstream changes (presumably #151003) made this pull request unmergeable. Please resolve the merge conflicts. |
|
@lapla-cogito any updates on this? thanks. |
|
I will update this patch in a few days. |
is_transmutable for non-region infers|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
Since adding @rustbot ready |
| if goal.predicate.has_non_region_infer() { | ||
| return ecx.forced_ambiguity(MaybeCause::Ambiguity); | ||
| } |
There was a problem hiding this comment.
can you move this check into ecx.is_transmutable? That should be able to just return Certainty::AMBIGUOUS which is then properly handled already
we want to handle structurally_normalize_const to return something ambiguous or to take something that references an infer var and the returned assume then does not as the infer var wasn't used.
|
issue resolved in #154991 |
| dst: I::Ty, | ||
| assume: I::Const, | ||
| ) -> Result<Certainty, NoSolution> { | ||
| if src.has_non_region_infer() || dst.has_non_region_infer() { |
There was a problem hiding this comment.
also need to check assume 🤔
There was a problem hiding this comment.
Sorry for the delay, I've been thinking about this a bit, and now that 154991 has been merged, I'm not sure why we still need to check assume here. IIUC, assume can only become Unevaluated when GCE is enabled, but currently GCE and the next solver cannot be used together. Given that, I'm not sure whether there is any actual issue that could arise from not checking assume here.
Of course, if this is intended to account for some future change (for example, if GCE and the next solver were to become usable together although my understanding is that GCE is being superseded by things like GCA, so I'm not sure how realistic that scenario is), then I can see the rationale. Otherwise, it seems to me that simply adding a test case would be sufficient.
Triage: Do you mean that this PR is not needed any longer? |
I think we just need to add the test |
|
@rustbot author #149228 (comment) is also still relevant |
|
Reminder, once the PR becomes ready for a review, use |
fixes #141400, fixes #148809
The new trait solver's
consider_builtin_transmute_candidate()was passing types with inference variables directly torustc_transmute(), which attempts layout computation and ICEs.The old solver already guards against this in
assemble_candidates_for_transmutability()by settingcandidates.ambiguous = true. Add the equivalent guard in the new solver by returningforced_ambiguitywhen the predicate contains non-region inference variables.