about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDavid Wood <david.wood2@arm.com>2025-05-13 16:47:10 +0000
committerDavid Wood <david.wood2@arm.com>2025-05-13 16:47:10 +0000
commitfebb16a40fe2c3722f6e4202ee6783bf6b79b29c (patch)
tree954745a8743855b9a705c5dedbed8361ac98e990
parenta5e1dba0cda0db75106ea6c5022e874c7ee116b5 (diff)
downloadrust-febb16a40fe2c3722f6e4202ee6783bf6b79b29c.tar.gz
rust-febb16a40fe2c3722f6e4202ee6783bf6b79b29c.zip
type_ir: add faster exit for `types_may_unify`
-rw-r--r--compiler/rustc_type_ir/src/fast_reject.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/compiler/rustc_type_ir/src/fast_reject.rs b/compiler/rustc_type_ir/src/fast_reject.rs
index 11ec1f0a9fb..34502f49550 100644
--- a/compiler/rustc_type_ir/src/fast_reject.rs
+++ b/compiler/rustc_type_ir/src/fast_reject.rs
@@ -232,6 +232,9 @@ impl<I: Interner, const INSTANTIATE_LHS_WITH_INFER: bool, const INSTANTIATE_RHS_
     }
 
     pub fn types_may_unify(self, lhs: I::Ty, rhs: I::Ty) -> bool {
+        if lhs == rhs {
+            return true;
+        }
         self.types_may_unify_inner(lhs, rhs, Self::STARTING_DEPTH)
     }