From 417d8e99202f66f19521f9dd2e05fa99421d33a8 Mon Sep 17 00:00:00 2001 From: sasa630 Date: Thu, 6 Mar 2025 01:50:52 +0200 Subject: [PATCH] Refactored to use implicit insert and remove insert_type method from the context object (#3395) gcc/rust/ChangeLog: * typecheck/rust-substitution-mapper.cc: Refactored code to use insert_implicit_type instead of insert_type. * typecheck/rust-hir-type-check.h: Removed declaration of insert_type from TypeCheckContext class. * typecheck/rust-typecheck-context.cc: Removed definition of insert_type. Signed-off-by: sasa630 --- gcc/rust/typecheck/rust-hir-type-check.h | 2 -- gcc/rust/typecheck/rust-substitution-mapper.cc | 11 ++++------- gcc/rust/typecheck/rust-typecheck-context.cc | 11 ----------- 3 files changed, 4 insertions(+), 20 deletions(-) diff --git a/gcc/rust/typecheck/rust-hir-type-check.h b/gcc/rust/typecheck/rust-hir-type-check.h index 65f38c6099cd..d5be564c3c90 100644 --- a/gcc/rust/typecheck/rust-hir-type-check.h +++ b/gcc/rust/typecheck/rust-hir-type-check.h @@ -169,8 +169,6 @@ class TypeCheckContext void insert_builtin (HirId id, NodeId ref, TyTy::BaseType *type); const std::vector> &get_builtins () const; - void insert_type (const Analysis::NodeMapping &mappings, - TyTy::BaseType *type); bool lookup_type (HirId id, TyTy::BaseType **type) const; void clear_type (TyTy::BaseType *ty); diff --git a/gcc/rust/typecheck/rust-substitution-mapper.cc b/gcc/rust/typecheck/rust-substitution-mapper.cc index 20fe8f04adcb..31a04e648081 100644 --- a/gcc/rust/typecheck/rust-substitution-mapper.cc +++ b/gcc/rust/typecheck/rust-substitution-mapper.cc @@ -152,18 +152,15 @@ SubstMapperInternal::Resolve (TyTy::BaseType *base, = context->lookup_type (mapper.resolved->get_ty_ref (), &unused); if (!is_ty_available) { - context->insert_type ( - Analysis::NodeMapping (0, 0, mapper.resolved->get_ty_ref (), 0), - mapper.resolved); + context->insert_implicit_type(mapper.resolved->get_ty_ref (), + mapper.resolved); } bool is_ref_available = context->lookup_type (mapper.resolved->get_ref (), &unused); if (!is_ref_available) { - context->insert_type (Analysis::NodeMapping (0, 0, - mapper.resolved->get_ref (), - 0), - mapper.resolved); + context->insert_implicit_type(mapper.resolved->get_ref (), + mapper.resolved); } return mapper.resolved; diff --git a/gcc/rust/typecheck/rust-typecheck-context.cc b/gcc/rust/typecheck/rust-typecheck-context.cc index 907833fba971..575a55c3182b 100644 --- a/gcc/rust/typecheck/rust-typecheck-context.cc +++ b/gcc/rust/typecheck/rust-typecheck-context.cc @@ -79,17 +79,6 @@ TypeCheckContext::get_builtins () const return builtins; } -void -TypeCheckContext::insert_type (const Analysis::NodeMapping &mappings, - TyTy::BaseType *type) -{ - rust_assert (type != nullptr); - NodeId ref = mappings.get_nodeid (); - HirId id = mappings.get_hirid (); - node_id_refs[ref] = id; - resolved[id] = type; -} - void TypeCheckContext::insert_implicit_type (HirId id, TyTy::BaseType *type) {