From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id 0C56E3858404; Tue, 28 Feb 2023 22:37:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0C56E3858404 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677623855; bh=HpGV9/kP8HWU9XlayyHlYjkzVoPaGF4yj1MEK2Vj8Pg=; h=From:To:Subject:Date:From; b=uLHOUYJ//I7SYO8NrBNc2uWDyiV3wZszZB6EMxpmvCKREAKesnryzLzeeeqQnjd04 pv716b4wvN+FGH+NYJOvBwf5KvYsgQN3BMXVw/IlywB874qhhsk4KxYQ74JuTzBIus KZwl4l66oFKKYkFjTgkMvuo811byh9hy0FxYdbcQ= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Thomas Schwinge To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] gccrs: bug-fix implicit inference checks X-Act-Checkin: gcc X-Git-Author: Philip Herron X-Git-Refname: refs/heads/devel/rust/master X-Git-Oldrev: 0632bfbf63449ed4d963d3a29aff1deb0b07e65f X-Git-Newrev: a20426036a360d781dae2361ffd4c7dcfe4bb40a Message-Id: <20230228223735.0C56E3858404@sourceware.org> Date: Tue, 28 Feb 2023 22:37:35 +0000 (GMT) List-Id: https://gcc.gnu.org/g:a20426036a360d781dae2361ffd4c7dcfe4bb40a commit a20426036a360d781dae2361ffd4c7dcfe4bb40a Author: Philip Herron Date: Mon Feb 27 17:39:09 2023 +0000 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 or this is safe to do so and allows us to infer mroe cases. Signed-off-by: Philip Herron gcc/rust/ChangeLog: * typecheck/rust-unify.cc (UnifyRules::go): fix inference check Diff: --- gcc/rust/typecheck/rust-unify.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gcc/rust/typecheck/rust-unify.cc b/gcc/rust/typecheck/rust-unify.cc index e76b362aa0c..fb7b5d4bd6f 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 (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 (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)