aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2023-02-27 17:39:09 +0000
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 18:19:00 +0100
commit49d5df4c826e14beaa9ee4c01c8fb710bd81a7bb (patch)
treeeed49339000e09873695b030ea34912ae559f4b9 /gcc
parent0d8c98f7ff59bccb168e4b93fb55f2d1d22c3f44 (diff)
downloadgcc-49d5df4c826e14beaa9ee4c01c8fb710bd81a7bb.zip
gcc-49d5df4c826e14beaa9ee4c01c8fb710bd81a7bb.tar.gz
gcc-49d5df4c826e14beaa9ee4c01c8fb710bd81a7bb.tar.bz2
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 <herron.philip@googlemail.com> gcc/rust/ChangeLog: * typecheck/rust-unify.cc (UnifyRules::go): fix inference check
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/typecheck/rust-unify.cc14
1 files changed, 12 insertions, 2 deletions
diff --git a/gcc/rust/typecheck/rust-unify.cc b/gcc/rust/typecheck/rust-unify.cc
index dcd1783..3af261d 100644
--- a/gcc/rust/typecheck/rust-unify.cc
+++ b/gcc/rust/typecheck/rust-unify.cc
@@ -153,12 +153,22 @@ UnifyRules::go ()
{
bool rgot_param = rtype->get_kind () == TyTy::TypeKind::PARAM;
bool lhs_is_infer_var = ltype->get_kind () == TyTy::TypeKind::INFER;
- bool expected_is_concrete = ltype->is_concrete () && !lhs_is_infer_var;
+ bool lhs_is_general_infer_var
+ = lhs_is_infer_var
+ && static_cast<TyTy::InferType *> (ltype)->get_infer_kind ()
+ == TyTy::InferType::GENERAL;
+ bool expected_is_concrete
+ = ltype->is_concrete () && !lhs_is_general_infer_var;
bool rneeds_infer = expected_is_concrete && rgot_param;
bool lgot_param = ltype->get_kind () == TyTy::TypeKind::PARAM;
bool rhs_is_infer_var = rtype->get_kind () == TyTy::TypeKind::INFER;
- bool receiver_is_concrete = rtype->is_concrete () && !rhs_is_infer_var;
+ bool rhs_is_general_infer_var
+ = rhs_is_infer_var
+ && static_cast<TyTy::InferType *> (rtype)->get_infer_kind ()
+ == TyTy::InferType::GENERAL;
+ bool receiver_is_concrete
+ = rtype->is_concrete () && !rhs_is_general_infer_var;
bool lneeds_infer = receiver_is_concrete && lgot_param;
if (rneeds_infer)