about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2024-06-30 11:30:55 -0400
committerMichael Goulet <michael@errs.io>2024-07-05 11:59:52 -0400
commitfdde66acee3ba4c85798ea5120fa76f86bf697fe (patch)
tree241e261cb51f44d1799577a0032511651a659512 /compiler
parent11dd90f7613a4b160ed8398a3f1c7c129ad1a372 (diff)
downloadrust-fdde66acee3ba4c85798ea5120fa76f86bf697fe.tar.gz
rust-fdde66acee3ba4c85798ea5120fa76f86bf697fe.zip
Process alias-relate obligations when proving receiver_is_valid
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_hir_analysis/src/check/wfcheck.rs10
-rw-r--r--compiler/rustc_infer/src/infer/mod.rs4
2 files changed, 13 insertions, 1 deletions
diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs
index 2230528a5ae..279e9fc5df3 100644
--- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs
+++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs
@@ -1712,7 +1712,15 @@ fn receiver_is_valid<'tcx>(
     let cause =
         ObligationCause::new(span, wfcx.body_def_id, traits::ObligationCauseCode::MethodReceiver);
 
-    let can_eq_self = |ty| infcx.can_eq(wfcx.param_env, self_ty, ty);
+    let can_eq_self = |ty| {
+        wfcx.infcx.probe(|_| {
+            let ocx = ObligationCtxt::new(wfcx.infcx);
+            let Ok(()) = ocx.eq(&ObligationCause::dummy(), wfcx.param_env, self_ty, ty) else {
+                return false;
+            };
+            ocx.select_where_possible().is_empty()
+        })
+    };
 
     // `self: Self` is always valid.
     if can_eq_self(receiver_ty) {
diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs
index ff593d7ffb7..835c412a64d 100644
--- a/compiler/rustc_infer/src/infer/mod.rs
+++ b/compiler/rustc_infer/src/infer/mod.rs
@@ -767,6 +767,8 @@ impl<'tcx> InferCtxt<'tcx> {
             .collect()
     }
 
+    // FIXME(-Znext-solver): Get rid of this method, it's never correct. Either that,
+    // or we need to process the obligations.
     pub fn can_sub<T>(&self, param_env: ty::ParamEnv<'tcx>, expected: T, actual: T) -> bool
     where
         T: at::ToTrace<'tcx>,
@@ -779,6 +781,8 @@ impl<'tcx> InferCtxt<'tcx> {
         })
     }
 
+    // FIXME(-Znext-solver): Get rid of this method, it's never correct. Either that,
+    // or we need to process the obligations.
     pub fn can_eq<T>(&self, param_env: ty::ParamEnv<'tcx>, a: T, b: T) -> bool
     where
         T: at::ToTrace<'tcx>,