Skip to content

Commit 2704c26

Browse files
committed
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 <mostafayounis630@gmail.com> follow code format
1 parent bee59d6 commit 2704c26

File tree

3 files changed

+4
-20
lines changed

3 files changed

+4
-20
lines changed

gcc/rust/typecheck/rust-hir-type-check.h

-2
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,6 @@ class TypeCheckContext
169169
void insert_builtin (HirId id, NodeId ref, TyTy::BaseType *type);
170170
const std::vector<std::unique_ptr<TyTy::BaseType>> &get_builtins () const;
171171

172-
void insert_type (const Analysis::NodeMapping &mappings,
173-
TyTy::BaseType *type);
174172
bool lookup_type (HirId id, TyTy::BaseType **type) const;
175173
void clear_type (TyTy::BaseType *ty);
176174

gcc/rust/typecheck/rust-substitution-mapper.cc

+4-7
Original file line numberDiff line numberDiff line change
@@ -152,18 +152,15 @@ SubstMapperInternal::Resolve (TyTy::BaseType *base,
152152
= context->lookup_type (mapper.resolved->get_ty_ref (), &unused);
153153
if (!is_ty_available)
154154
{
155-
context->insert_type (
156-
Analysis::NodeMapping (0, 0, mapper.resolved->get_ty_ref (), 0),
157-
mapper.resolved);
155+
context->insert_implicit_type (mapper.resolved->get_ty_ref (),
156+
mapper.resolved);
158157
}
159158
bool is_ref_available
160159
= context->lookup_type (mapper.resolved->get_ref (), &unused);
161160
if (!is_ref_available)
162161
{
163-
context->insert_type (Analysis::NodeMapping (0, 0,
164-
mapper.resolved->get_ref (),
165-
0),
166-
mapper.resolved);
162+
context->insert_implicit_type (mapper.resolved->get_ref (),
163+
mapper.resolved);
167164
}
168165

169166
return mapper.resolved;

gcc/rust/typecheck/rust-typecheck-context.cc

-11
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,6 @@ TypeCheckContext::get_builtins () const
7979
return builtins;
8080
}
8181

82-
void
83-
TypeCheckContext::insert_type (const Analysis::NodeMapping &mappings,
84-
TyTy::BaseType *type)
85-
{
86-
rust_assert (type != nullptr);
87-
NodeId ref = mappings.get_nodeid ();
88-
HirId id = mappings.get_hirid ();
89-
node_id_refs[ref] = id;
90-
resolved[id] = type;
91-
}
92-
9382
void
9483
TypeCheckContext::insert_implicit_type (HirId id, TyTy::BaseType *type)
9584
{

0 commit comments

Comments
 (0)