]> git.ipfire.org Git - thirdparty/gcc.git/commit
gccrs: Refactor TyTy::ConstType into separate types
authorPhilip Herron <herron.philip@googlemail.com>
Sat, 4 Oct 2025 20:53:40 +0000 (21:53 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Thu, 30 Oct 2025 20:30:56 +0000 (21:30 +0100)
commit66a9a3a95bae4c7ea02495f938b674f6e037f951
treebb054d269012670621a165f6a7a96a9bbc78ad4f
parent2a773d3ed64ae49390cca1466d0429c9ecf675a5
gccrs: Refactor TyTy::ConstType into separate types

This patch refactors the const generic type system to follow the same pattern
as regular type parameters. The monolithic ConstType is split into four
distinct types:

  ConstParamType (generic parameter placeholder)
  ConstValueType (resolved constant value)
  ConstInferType (inference variable)
  ConstErrorType (error sentinel)

gcc/rust/ChangeLog:

* backend/rust-compile-expr.cc (CompileExpr::array_copied_expr): refactor to new classes
* backend/rust-compile-pattern.cc (CompilePatternCheckExpr::visit): likewise
(CompilePatternBindings::visit): likewise
* backend/rust-compile-type.cc (TyTyResolveCompile::visit): likewise
* backend/rust-compile-type.h: likewise
* typecheck/rust-hir-type-check-base.cc (TypeCheckBase::resolve_literal): likewise
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): likewise
* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): likewise
* typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): likewise
* typecheck/rust-substitution-mapper.cc (SubstMapperInternal::visit): likewise
* typecheck/rust-substitution-mapper.h: likewise
* typecheck/rust-type-util.cc (unify_site_and): remove bad delete (alpine32)
* typecheck/rust-tyty-call.h: refactor to new classes
* typecheck/rust-tyty-subst.cc (SubstitutionParamMapping::clone): likewise
(SubstitutionRef::infer_substitions): likewise
* typecheck/rust-tyty-util.cc (TyVar::get_implicit_const_infer_var): likewise
* typecheck/rust-tyty-util.h: likewise
* typecheck/rust-tyty-variance-analysis-private.h: likewise
* typecheck/rust-tyty-visitor.h: likewise
* typecheck/rust-tyty.cc (BaseType::destructure): likewise
(BaseType::monomorphized_clone): likewise
(BaseType::is_concrete): likewise
(VariantDef::clone): likewise
(VariantDef::monomorphized_clone): likewise
(ArrayType::as_string): likewise
(ArrayType::get_capacity): likewise
(ArrayType::handle_substitions): likewise
(generate_tree_str): likewise
(ConstType::ConstType): likewise
(ConstParamType::ConstParamType): likewise
(ConstType::accept_vis): likewise
(ConstParamType::const_kind): likewise
(ConstParamType::get_symbol): likewise
(ConstParamType::can_resolve): likewise
(ConstParamType::resolve): likewise
(ConstParamType::accept_vis): likewise
(ConstType::set_value): likewise
(ConstType::as_string): likewise
(ConstParamType::as_string): likewise
(ConstType::clone): likewise
(ConstParamType::clone): likewise
(ConstType::get_symbol): likewise
(ConstParamType::get_name): likewise
(ConstType::can_resolve): likewise
(ConstParamType::is_equal): likewise
(ConstType::resolve): likewise
(ConstValueType::ConstValueType): likewise
(ConstValueType::const_kind): likewise
(ConstValueType::accept_vis): likewise
(ConstValueType::as_string): likewise
(ConstValueType::clone): likewise
(ConstValueType::get_name): likewise
(ConstValueType::is_equal): likewise
(ConstValueType::get_value): likewise
(ConstInferType::ConstInferType): likewise
(ConstInferType::const_kind): likewise
(ConstInferType::accept_vis): likewise
(ConstType::get_name): likewise
(ConstInferType::as_string): likewise
(ConstInferType::clone): likewise
(ConstInferType::get_name): likewise
(ConstType::is_equal): likewise
(ConstInferType::is_equal): likewise
(ConstErrorType::ConstErrorType): likewise
(ConstErrorType::const_kind): likewise
(ConstType::handle_substitions): likewise
(ConstErrorType::accept_vis): likewise
(ConstErrorType::as_string): likewise
(ConstErrorType::clone): likewise
(ConstErrorType::get_name): likewise
(ConstErrorType::is_equal): likewise
* typecheck/rust-tyty.h (class BaseConstType): likewise
(class ConstType): likewise
(class ConstParamType): likewise
(class ConstValueType): likewise
(class ConstInferType): likewise
(class ConstErrorType): likewise
* typecheck/rust-unify.cc (UnifyRules::commit): likewise
(UnifyRules::go): likewise
(UnifyRules::expect_array): likewise
(UnifyRules::expect_const): likewise
* typecheck/rust-unify.h: likewise

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
21 files changed:
gcc/rust/backend/rust-compile-expr.cc
gcc/rust/backend/rust-compile-pattern.cc
gcc/rust/backend/rust-compile-type.cc
gcc/rust/backend/rust-compile-type.h
gcc/rust/typecheck/rust-hir-type-check-base.cc
gcc/rust/typecheck/rust-hir-type-check-expr.cc
gcc/rust/typecheck/rust-hir-type-check-pattern.cc
gcc/rust/typecheck/rust-hir-type-check-type.cc
gcc/rust/typecheck/rust-substitution-mapper.cc
gcc/rust/typecheck/rust-substitution-mapper.h
gcc/rust/typecheck/rust-type-util.cc
gcc/rust/typecheck/rust-tyty-call.h
gcc/rust/typecheck/rust-tyty-subst.cc
gcc/rust/typecheck/rust-tyty-util.cc
gcc/rust/typecheck/rust-tyty-util.h
gcc/rust/typecheck/rust-tyty-variance-analysis-private.h
gcc/rust/typecheck/rust-tyty-visitor.h
gcc/rust/typecheck/rust-tyty.cc
gcc/rust/typecheck/rust-tyty.h
gcc/rust/typecheck/rust-unify.cc
gcc/rust/typecheck/rust-unify.h