From: Philip Herron Date: Mon, 25 Aug 2025 12:30:22 +0000 (+0100) Subject: gccrs: respect the unify rules commit flag X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2df042c661f66171fc9432ef992ce6cf6de7c022;p=thirdparty%2Fgcc.git gccrs: respect the unify rules commit flag We use the types compatable interface for unify here and so if we dont respect the commit flag the interface can have unintended side effects with infer type hints throwing things off down the line. gcc/rust/ChangeLog: * typecheck/rust-unify.cc (UnifyRules::expect_inference_variable): dont commit (UnifyRules::expect_adt): likewise (UnifyRules::expect_bool): likewise (UnifyRules::expect_char): likewise (UnifyRules::expect_int): likewise (UnifyRules::expect_uint): likewise (UnifyRules::expect_float): likewise (UnifyRules::expect_isize): likewise (UnifyRules::expect_usize): likewise Signed-off-by: Philip Herron --- diff --git a/gcc/rust/typecheck/rust-unify.cc b/gcc/rust/typecheck/rust-unify.cc index 852451aeef4..5c1e5b732cd 100644 --- a/gcc/rust/typecheck/rust-unify.cc +++ b/gcc/rust/typecheck/rust-unify.cc @@ -385,7 +385,8 @@ UnifyRules::expect_inference_variable (TyTy::InferType *ltype, == TyTy::InferType::InferTypeKind::INTEGRAL); if (is_valid) { - ltype->apply_primitive_type_hint (*rtype); + if (commit_flag) + ltype->apply_primitive_type_hint (*rtype); return rtype; } } @@ -399,7 +400,8 @@ UnifyRules::expect_inference_variable (TyTy::InferType *ltype, == TyTy::InferType::InferTypeKind::FLOAT); if (is_valid) { - ltype->apply_primitive_type_hint (*rtype); + if (commit_flag) + ltype->apply_primitive_type_hint (*rtype); return rtype; } } @@ -523,7 +525,7 @@ UnifyRules::expect_adt (TyTy::ADTType *ltype, TyTy::BaseType *rtype) } } - return type.clone (); + return ltype; } break; @@ -1269,7 +1271,8 @@ UnifyRules::expect_bool (TyTy::BoolType *ltype, TyTy::BaseType *rtype) = r->get_infer_kind () == TyTy::InferType::InferTypeKind::GENERAL; if (is_valid) { - r->apply_primitive_type_hint (*ltype); + if (commit_flag) + r->apply_primitive_type_hint (*ltype); return ltype->clone (); } } @@ -1319,7 +1322,8 @@ UnifyRules::expect_char (TyTy::CharType *ltype, TyTy::BaseType *rtype) = r->get_infer_kind () == TyTy::InferType::InferTypeKind::GENERAL; if (is_valid) { - r->apply_primitive_type_hint (*ltype); + if (commit_flag) + r->apply_primitive_type_hint (*ltype); return ltype->clone (); } } @@ -1370,7 +1374,8 @@ UnifyRules::expect_int (TyTy::IntType *ltype, TyTy::BaseType *rtype) || r->get_infer_kind () == TyTy::InferType::InferTypeKind::INTEGRAL; if (is_valid) { - r->apply_primitive_type_hint (*ltype); + if (commit_flag) + r->apply_primitive_type_hint (*ltype); return ltype->clone (); } } @@ -1428,7 +1433,8 @@ UnifyRules::expect_uint (TyTy::UintType *ltype, TyTy::BaseType *rtype) || r->get_infer_kind () == TyTy::InferType::InferTypeKind::INTEGRAL; if (is_valid) { - r->apply_primitive_type_hint (*ltype); + if (commit_flag) + r->apply_primitive_type_hint (*ltype); return ltype->clone (); } } @@ -1486,7 +1492,8 @@ UnifyRules::expect_float (TyTy::FloatType *ltype, TyTy::BaseType *rtype) || r->get_infer_kind () == TyTy::InferType::InferTypeKind::FLOAT; if (is_valid) { - r->apply_primitive_type_hint (*ltype); + if (commit_flag) + r->apply_primitive_type_hint (*ltype); return ltype->clone (); } } @@ -1543,7 +1550,8 @@ UnifyRules::expect_isize (TyTy::ISizeType *ltype, TyTy::BaseType *rtype) = r->get_infer_kind () != TyTy::InferType::InferTypeKind::FLOAT; if (is_valid) { - r->apply_primitive_type_hint (*ltype); + if (commit_flag) + r->apply_primitive_type_hint (*ltype); return ltype->clone (); } } @@ -1593,7 +1601,8 @@ UnifyRules::expect_usize (TyTy::USizeType *ltype, TyTy::BaseType *rtype) = r->get_infer_kind () != TyTy::InferType::InferTypeKind::FLOAT; if (is_valid) { - r->apply_primitive_type_hint (*ltype); + if (commit_flag) + r->apply_primitive_type_hint (*ltype); return ltype->clone (); } }