Skip to content

Commit 712ae2f

Browse files
committed
Fix equality interface on TyTy::FnType
We missed a case to ensure the substitutions are equal in the is_equal interface. This becomes important when dealing with generic associated types since the projections could end up overlapping and we need to differentiate them by the substitutions and monomorphization.
1 parent 1ada076 commit 712ae2f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

gcc/rust/typecheck/rust-tyty.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,6 +1230,19 @@ FnType::is_equal (const BaseType &other) const
12301230
{
12311231
if (get_num_substitutions () != other2.get_num_substitutions ())
12321232
return false;
1233+
1234+
const FnType &ofn = static_cast<const FnType &> (other);
1235+
for (size_t i = 0; i < get_num_substitutions (); i++)
1236+
{
1237+
const SubstitutionParamMapping &a = get_substs ().at (i);
1238+
const SubstitutionParamMapping &b = ofn.get_substs ().at (i);
1239+
1240+
const ParamType *pa = a.get_param_ty ();
1241+
const ParamType *pb = b.get_param_ty ();
1242+
1243+
if (!pa->is_equal (*pb))
1244+
return false;
1245+
}
12331246
}
12341247

12351248
if (num_params () != other2.num_params ())

0 commit comments

Comments
 (0)