Skip to content

Commit a204260

Browse files
committed
gccrs: bug-fix implicit inference checks
When generating implicit inference variables we can miss cases where the other side might be another inference variable too but it runs the risk of generating unending inference cycles needing more info but if they other side is a non general inference variables like <integer> or <float> this is safe to do so and allows us to infer mroe cases. Signed-off-by: Philip Herron <[email protected]> gcc/rust/ChangeLog: * typecheck/rust-unify.cc (UnifyRules::go): fix inference check
1 parent 0632bfb commit a204260

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

gcc/rust/typecheck/rust-unify.cc

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,22 @@ UnifyRules::go ()
153153
{
154154
bool rgot_param = rtype->get_kind () == TyTy::TypeKind::PARAM;
155155
bool lhs_is_infer_var = ltype->get_kind () == TyTy::TypeKind::INFER;
156-
bool expected_is_concrete = ltype->is_concrete () && !lhs_is_infer_var;
156+
bool lhs_is_general_infer_var
157+
= lhs_is_infer_var
158+
&& static_cast<TyTy::InferType *> (ltype)->get_infer_kind ()
159+
== TyTy::InferType::GENERAL;
160+
bool expected_is_concrete
161+
= ltype->is_concrete () && !lhs_is_general_infer_var;
157162
bool rneeds_infer = expected_is_concrete && rgot_param;
158163

159164
bool lgot_param = ltype->get_kind () == TyTy::TypeKind::PARAM;
160165
bool rhs_is_infer_var = rtype->get_kind () == TyTy::TypeKind::INFER;
161-
bool receiver_is_concrete = rtype->is_concrete () && !rhs_is_infer_var;
166+
bool rhs_is_general_infer_var
167+
= rhs_is_infer_var
168+
&& static_cast<TyTy::InferType *> (rtype)->get_infer_kind ()
169+
== TyTy::InferType::GENERAL;
170+
bool receiver_is_concrete
171+
= rtype->is_concrete () && !rhs_is_general_infer_var;
162172
bool lneeds_infer = receiver_is_concrete && lgot_param;
163173

164174
if (rneeds_infer)

0 commit comments

Comments
 (0)