Skip to content

Commit 2076e69

Browse files
bors[bot]philberty
andauthored
Merge #1108
1108: Add missing unify rules for inference variables r=philberty a=philberty Inference variables can unify with anything so this includes these covariant types like references/slices etc. This patch is needed for more complex type-checking in libcore and generics. Co-authored-by: Philip Herron <[email protected]>
2 parents c494f30 + 7609dfc commit 2076e69

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

gcc/rust/typecheck/rust-tyty-rules.h

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,18 @@ class ArrayRules : public BaseRules
867867
TyVar (base_resolved->get_ref ()));
868868
}
869869

870+
void visit (InferType &type) override
871+
{
872+
if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL)
873+
{
874+
BaseRules::visit (type);
875+
return;
876+
}
877+
878+
resolved = base->clone ();
879+
resolved->set_ref (type.get_ref ());
880+
}
881+
870882
private:
871883
BaseType *get_base () override { return base; }
872884

@@ -896,6 +908,18 @@ class SliceRules : public BaseRules
896908
TyVar (base_resolved->get_ref ()));
897909
}
898910

911+
void visit (InferType &type) override
912+
{
913+
if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL)
914+
{
915+
BaseRules::visit (type);
916+
return;
917+
}
918+
919+
resolved = base->clone ();
920+
resolved->set_ref (type.get_ref ());
921+
}
922+
899923
private:
900924
BaseType *get_base () override { return base; }
901925

@@ -1140,6 +1164,18 @@ class TupleRules : public BaseRules
11401164
type.get_ident ().locus, fields);
11411165
}
11421166

1167+
void visit (InferType &type) override
1168+
{
1169+
if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL)
1170+
{
1171+
BaseRules::visit (type);
1172+
return;
1173+
}
1174+
1175+
resolved = base->clone ();
1176+
resolved->set_ref (type.get_ref ());
1177+
}
1178+
11431179
private:
11441180
BaseType *get_base () override { return base; }
11451181

@@ -1263,6 +1299,18 @@ class ReferenceRules : public BaseRules
12631299
base->mutability ());
12641300
}
12651301

1302+
void visit (InferType &type) override
1303+
{
1304+
if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL)
1305+
{
1306+
BaseRules::visit (type);
1307+
return;
1308+
}
1309+
1310+
resolved = base->clone ();
1311+
resolved->set_ref (type.get_ref ());
1312+
}
1313+
12661314
private:
12671315
BaseType *get_base () override { return base; }
12681316

@@ -1303,6 +1351,18 @@ class PointerRules : public BaseRules
13031351
base->mutability ());
13041352
}
13051353

1354+
void visit (InferType &type) override
1355+
{
1356+
if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL)
1357+
{
1358+
BaseRules::visit (type);
1359+
return;
1360+
}
1361+
1362+
resolved = base->clone ();
1363+
resolved->set_ref (type.get_ref ());
1364+
}
1365+
13061366
private:
13071367
BaseType *get_base () override { return base; }
13081368

0 commit comments

Comments
 (0)