From 95fa967f5c5ce9445fa3f08195c01138338fd0bd Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Mon, 30 Jan 2023 18:19:07 +0000 Subject: gccrs: Refactor the type unification code This refactors the unification systems to be a consistent interface using switch statements and simple functions instead of the old clunky visitor system. This is more maintainable as it is harder to miss cases when we can take advantages of switch statements. Signed-off-by: Philip Herron gcc/rust/ChangeLog: * Make-lang.in: update names * backend/rust-compile-expr.cc (CompileExpr::resolve_method_address): update to use new interface * typecheck/rust-coercion.cc (TypeCoercionRules::coerce_borrowed_pointer): likewise * typecheck/rust-hir-type-check-base.cc (TypeCheckBase::unify_site): likewise * typecheck/rust-tyty.cc (BaseType::destructure): likewise (InferType::unify): removed old unify interface (ErrorType::unify): likewise (ADTType::unify): likewise (TupleType::unify): likewise (FnType::unify): likewise (FnPtr::unify): likewise (ClosureType::unify): likewise (ArrayType::unify): likewise (SliceType::unify): likewise (BoolType::unify): likewise (IntType::unify): likewise (UintType::unify): likewise (FloatType::unify): likewise (USizeType::unify): likewise (ISizeType::unify): likewise (CharType::unify): likewise (ReferenceType::unify): likewise (PointerType::unify): likewise (ParamType::unify): likewise (StrType::unify): likewise (NeverType::unify): likewise (PlaceholderType::unify): likewise (ProjectionType::unify): likewise (DynamicObjectType::unify): likewise * typecheck/rust-tyty.h: update destructure interface * typecheck/rust-tyty-rules.h: Removed. * typecheck/rust-unify.cc: New file. * typecheck/rust-unify.h: New file. gcc/testsuite/ChangeLog: * rust/compile/never_type_err1.rs: Moved to... * rust/compile/never_type1.rs: ...here. It now works --- gcc/rust/backend/rust-compile-expr.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'gcc/rust/backend') diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc index 8b56be7..97df107 100644 --- a/gcc/rust/backend/rust-compile-expr.cc +++ b/gcc/rust/backend/rust-compile-expr.cc @@ -26,6 +26,7 @@ #include "rust-compile-block.h" #include "rust-compile-implitem.h" #include "rust-constexpr.h" +#include "rust-unify.h" #include "rust-gcc.h" #include "fold-const.h" @@ -2030,7 +2031,10 @@ CompileExpr::resolve_method_address (TyTy::FnType *fntype, HirId ref, { TyTy::BaseType *infer_impl_call = candidate_call->infer_substitions (expr_locus); - monomorphized = infer_impl_call->unify (fntype); + monomorphized = Resolver::UnifyRules::Resolve ( + TyTy::TyWithLocation (infer_impl_call), + TyTy::TyWithLocation (fntype), expr_locus, true /* commit */, + true /* emit_errors */); } return CompileInherentImplItem::Compile (impl_item, ctx, monomorphized); -- cgit v1.1