From c2e39c2f20c568b96fe89c751e65bbbe9116231c Mon Sep 17 00:00:00 2001 From: lcnr Date: Fri, 26 Sep 2025 16:37:03 +0200 Subject: [PATCH] review --- compiler/rustc_hir_typeck/src/method/probe.rs | 9 +++++++++ .../rustc_infer/src/infer/canonical/query_response.rs | 11 ++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/method/probe.rs b/compiler/rustc_hir_typeck/src/method/probe.rs index e34ee6258b85..12f80a197b1b 100644 --- a/compiler/rustc_hir_typeck/src/method/probe.rs +++ b/compiler/rustc_hir_typeck/src/method/probe.rs @@ -2192,6 +2192,15 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { &self, trait_predicate: Option>, ) -> bool { + // This function is what hacky and doesn't perfectly do what we want it to. + // It's not soundness critical and we should be able to freely improve this + // in the future. + // + // Some concrete edge cases include the fact that `goal_may_hold_opaque_types_jank` + // also fails if there are any constraints opaques which are never used as a self + // type. We also allow where-bounds which are currently ambiguous but end up + // constraining an opaque later on. + // Check whether the trait candidate would not be applicable if the // opaque type were rigid. if let Some(predicate) = trait_predicate { diff --git a/compiler/rustc_infer/src/infer/canonical/query_response.rs b/compiler/rustc_infer/src/infer/canonical/query_response.rs index a20cd31113ab..b3959113d5dc 100644 --- a/compiler/rustc_infer/src/infer/canonical/query_response.rs +++ b/compiler/rustc_infer/src/infer/canonical/query_response.rs @@ -87,14 +87,11 @@ impl<'tcx> InferCtxt<'tcx> { { // While we ignore region constraints and pending obligations, // we do return constrained opaque types to avoid unconstrained - // inference variables in the response. This is still slightly - // insufficient as ambiguous `Projection` obligations have the - // same issue. + // inference variables in the response. This is important as we want + // to check that opaques in deref steps stay unconstrained. // - // FIXME(-Znext-solver): We could alternatively extend the `var_values` - // each time we call `make_query_response_ignoring_pending_obligations` - // and equate inference variables created inside of the query this way. - // This is what we do for `CanonicalState` and is probably a bit nicer. + // This doesn't handle the more general case for non-opaques as + // ambiguous `Projection` obligations have same the issue. let opaque_types = if self.next_trait_solver() { self.inner .borrow_mut()