about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2025-05-28 22:33:57 +0000
committerMichael Goulet <michael@errs.io>2025-06-02 19:23:20 +0000
commit9899464906c577ae39e267d1cfb6f55cbe6067cc (patch)
tree3207a57fe30cadaf8344baa3b54a0bfe7f3e0010 /compiler/rustc_trait_selection
parent3418d5db3aa619f19f59f4ee341f6683ed6743b4 (diff)
downloadrust-9899464906c577ae39e267d1cfb6f55cbe6067cc.tar.gz
rust-9899464906c577ae39e267d1cfb6f55cbe6067cc.zip
Fast path for subtype and coercion goals
Diffstat (limited to 'compiler/rustc_trait_selection')
-rw-r--r--compiler/rustc_trait_selection/src/solve/delegate.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/compiler/rustc_trait_selection/src/solve/delegate.rs b/compiler/rustc_trait_selection/src/solve/delegate.rs
index 406acdb7d88..69a0c0809b5 100644
--- a/compiler/rustc_trait_selection/src/solve/delegate.rs
+++ b/compiler/rustc_trait_selection/src/solve/delegate.rs
@@ -125,6 +125,17 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate<
 
                 Some(Certainty::Yes)
             }
+            ty::PredicateKind::Subtype(ty::SubtypePredicate { a, b, .. })
+            | ty::PredicateKind::Coerce(ty::CoercePredicate { a, b }) => {
+                if self.shallow_resolve(a).is_ty_var() && self.shallow_resolve(b).is_ty_var() {
+                    // FIXME: We also need to register a subtype relation between these vars
+                    // when those are added, and if they aren't in the same sub root then
+                    // we should mark this goal as `has_changed`.
+                    Some(Certainty::AMBIGUOUS)
+                } else {
+                    None
+                }
+            }
             _ => None,
         }
     }