Skip to content

Commit 15d4383

Browse files
committed
Let InferenceTable::unify() relate Zip values
1 parent 6afd0f5 commit 15d4383

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

crates/hir-ty/src/infer/unify.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,8 @@ impl<'a> InferenceTable<'a> {
340340
self.resolve_with_fallback(t, &|_, _, d, _| d)
341341
}
342342

343-
/// Unify two types and register new trait goals that arise from that.
344-
pub(crate) fn unify(&mut self, ty1: &Ty, ty2: &Ty) -> bool {
343+
/// Unify two relatable values (e.g. `Ty`) and register new trait goals that arise from that.
344+
pub(crate) fn unify<T: ?Sized + Zip<Interner>>(&mut self, ty1: &T, ty2: &T) -> bool {
345345
let result = match self.try_unify(ty1, ty2) {
346346
Ok(r) => r,
347347
Err(_) => return false,
@@ -350,9 +350,13 @@ impl<'a> InferenceTable<'a> {
350350
true
351351
}
352352

353-
/// Unify two types and return new trait goals arising from it, so the
353+
/// Unify two relatable values (e.g. `Ty`) and return new trait goals arising from it, so the
354354
/// caller needs to deal with them.
355-
pub(crate) fn try_unify<T: Zip<Interner>>(&mut self, t1: &T, t2: &T) -> InferResult<()> {
355+
pub(crate) fn try_unify<T: ?Sized + Zip<Interner>>(
356+
&mut self,
357+
t1: &T,
358+
t2: &T,
359+
) -> InferResult<()> {
356360
match self.var_unification_table.relate(
357361
Interner,
358362
&self.db,

crates/hir-ty/src/method_resolution.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,7 @@ fn is_valid_fn_candidate(
12141214
let expected_receiver =
12151215
sig.map(|s| s.params()[0].clone()).substitute(Interner, &fn_subst);
12161216

1217-
check_that!(table.unify(&receiver_ty, &expected_receiver));
1217+
check_that!(table.unify(receiver_ty, &expected_receiver));
12181218
}
12191219

12201220
if let ItemContainerId::ImplId(impl_id) = container {

0 commit comments

Comments
 (0)