about summary refs log tree commit diff
diff options
context:
space:
mode:
authorlcnr <rust@lcnr.de>2025-09-26 16:37:03 +0200
committerlcnr <rust@lcnr.de>2025-09-26 16:37:08 +0200
commitc2e39c2f20c568b96fe89c751e65bbbe9116231c (patch)
treea39e314986a87bff5c14affbd05099ee46a627a8
parentd6fe5334185385372d1fe8f1c9df8f5d3e7be788 (diff)
downloadrust-c2e39c2f20c568b96fe89c751e65bbbe9116231c.tar.gz
rust-c2e39c2f20c568b96fe89c751e65bbbe9116231c.zip
review
-rw-r--r--compiler/rustc_hir_typeck/src/method/probe.rs9
-rw-r--r--compiler/rustc_infer/src/infer/canonical/query_response.rs11
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 e34ee6258b8..12f80a197b1 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<ty::Predicate<'tcx>>,
     ) -> 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 a20cd31113a..b3959113d5d 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()