Auto merge of #119947 - compiler-errors:old-solver-instantiate-response, r=lcnr
Make sure to instantiate placeholders correctly in old solver When creating the query substitution guess for an input placeholder type like `!1_T` (in universe 1), we were guessing the response substitution with something like `!0_T`. This failed to unify with `!1_T`, causing an ICE. This PR reworks the query substitution guess code to work a bit more like the new solver. I'm *pretty* sure this is correct, though I'd really appreciate some scrutiny from someone (*cough* lcnr) who knows a bit more about query instantiation :) Fixes #119941 r? lcnr
This commit is contained in:
commit
533cfde67c
7 changed files with 106 additions and 4 deletions
|
@ -483,7 +483,13 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
let result_subst = CanonicalVarValues {
|
||||
var_values: self.tcx.mk_args_from_iter(
|
||||
query_response.variables.iter().enumerate().map(|(index, info)| {
|
||||
if info.is_existential() {
|
||||
if info.universe() != ty::UniverseIndex::ROOT {
|
||||
// A variable from inside a binder of the query. While ideally these shouldn't
|
||||
// exist at all, we have to deal with them for now.
|
||||
self.instantiate_canonical_var(cause.span, info, |u| {
|
||||
universe_map[u.as_usize()]
|
||||
})
|
||||
} else if info.is_existential() {
|
||||
match opt_values[BoundVar::new(index)] {
|
||||
Some(k) => k,
|
||||
None => self.instantiate_canonical_var(cause.span, info, |u| {
|
||||
|
@ -491,9 +497,11 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
}),
|
||||
}
|
||||
} else {
|
||||
self.instantiate_canonical_var(cause.span, info, |u| {
|
||||
universe_map[u.as_usize()]
|
||||
})
|
||||
// For placeholders which were already part of the input, we simply map this
|
||||
// universal bound variable back the placeholder of the input.
|
||||
opt_values[BoundVar::new(index)].expect(
|
||||
"expected placeholder to be unified with itself during response",
|
||||
)
|
||||
}
|
||||
}),
|
||||
),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue