Skip to content

Commit 2ad6a39

Browse files
authored
Rollup merge of rust-lang#108342 - lcnr:opaque-tys, r=oli-obk
apply query response: actually define opaque types not sure whether this fixes any code considering that rust-lang#107891 doesn't break anything, but this is currently wrong as the `eq` there should just always fail right now. We can definitely hit this code if we remove the `replace_opaque_types_with_inference_vars` hack. Doing so without this PR causes a few tests to ICE, e.g. https://github.com/rust-lang/rust/blob/bd4a96a12d0bf6dc12edf20a45df3a33052c9d7d/tests/ui/impl-trait/issue-99642.rs#L1-L7 r? `@oli-obk`
2 parents 783617b + cff59f8 commit 2ad6a39

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

compiler/rustc_infer/src/infer/canonical/query_response.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ impl<'tcx> InferCtxt<'tcx> {
393393
/// will instantiate fresh inference variables for each canonical
394394
/// variable instead. Therefore, the result of this method must be
395395
/// properly unified
396+
#[instrument(level = "debug", skip(self, cause, param_env))]
396397
fn query_response_substitution_guess<R>(
397398
&self,
398399
cause: &ObligationCause<'tcx>,
@@ -403,11 +404,6 @@ impl<'tcx> InferCtxt<'tcx> {
403404
where
404405
R: Debug + TypeFoldable<'tcx>,
405406
{
406-
debug!(
407-
"query_response_substitution_guess(original_values={:#?}, query_response={:#?})",
408-
original_values, query_response,
409-
);
410-
411407
// For each new universe created in the query result that did
412408
// not appear in the original query, create a local
413409
// superuniverse.
@@ -502,7 +498,9 @@ impl<'tcx> InferCtxt<'tcx> {
502498
for &(a, b) in &query_response.value.opaque_types {
503499
let a = substitute_value(self.tcx, &result_subst, a);
504500
let b = substitute_value(self.tcx, &result_subst, b);
505-
obligations.extend(self.at(cause, param_env).eq(a, b)?.obligations);
501+
debug!(?a, ?b, "constrain opaque type");
502+
obligations
503+
.extend(self.at(cause, param_env).define_opaque_types(true).eq(a, b)?.obligations);
506504
}
507505

508506
Ok(InferOk { value: result_subst, obligations })

0 commit comments

Comments
 (0)