Skip to content

Commit

Permalink
Get rid of duplicate interface #3396
Browse files Browse the repository at this point in the history
gcc/rust/ChangeLog:

	* typecheck/rust-autoderef.cc
	(insert_implicit_type): Update single-parameter call to
	pass explicit HirId.
	* typecheck/rust-hir-type-check-expr.cc: Same.
	* typecheck/rust-hir-type-check-pattern.cc: Same.
	* typecheck/rust-hir-type-check.h: Removed call
	to the duplicate interface.
	* typecheck/rust-typecheck-context.cc
	(TypeCheckContext::insert_implicit_type): Removed the
	interface with no HirId field.

Signed-off-by: Guransh Singh <[email protected]>
  • Loading branch information
GS-GOAT committed Feb 8, 2025
1 parent 7691105 commit af234dd
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 11 deletions.
2 changes: 1 addition & 1 deletion gcc/rust/typecheck/rust-autoderef.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Adjuster::try_unsize_type (TyTy::BaseType *ty)
auto slice
= new TyTy::SliceType (mappings.get_next_hir_id (), ty->get_ident ().locus,
TyTy::TyVar (slice_elem->get_ref ()));
context->insert_implicit_type (slice);
context->insert_implicit_type (slice->get_ref (), slice);

return Adjustment (Adjustment::AdjustmentType::UNSIZE, ty, slice);
}
Expand Down
2 changes: 1 addition & 1 deletion gcc/rust/typecheck/rust-hir-type-check-expr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1576,7 +1576,7 @@ TypeCheckExpr::visit (HIR::ClosureExpr &expr)
TyTy::TupleType *closure_args
= new TyTy::TupleType (implicit_args_id, expr.get_locus (),
parameter_types);
context->insert_implicit_type (closure_args);
context->insert_implicit_type (closure_args->get_ref (), closure_args);

location_t result_type_locus = expr.has_return_type ()
? expr.get_return_type ().get_locus ()
Expand Down
3 changes: 2 additions & 1 deletion gcc/rust/typecheck/rust-hir-type-check-pattern.cc
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,8 @@ ClosureParamInfer::Resolve (HIR::Pattern &pattern)

if (resolver.infered->get_kind () != TyTy::TypeKind::ERROR)
{
resolver.context->insert_implicit_type (resolver.infered);
resolver.context->insert_implicit_type (resolver.infered->get_ref (),
resolver.infered);
resolver.mappings.insert_location (resolver.infered->get_ref (),
pattern.get_locus ());
}
Expand Down
1 change: 0 additions & 1 deletion gcc/rust/typecheck/rust-hir-type-check.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ class TypeCheckContext

void insert_type (const Analysis::NodeMapping &mappings,
TyTy::BaseType *type);
void insert_implicit_type (TyTy::BaseType *type);
bool lookup_type (HirId id, TyTy::BaseType **type) const;
void clear_type (TyTy::BaseType *ty);

Expand Down
7 changes: 0 additions & 7 deletions gcc/rust/typecheck/rust-typecheck-context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,6 @@ TypeCheckContext::insert_type (const Analysis::NodeMapping &mappings,
resolved[id] = type;
}

void
TypeCheckContext::insert_implicit_type (TyTy::BaseType *type)
{
rust_assert (type != nullptr);
resolved[type->get_ref ()] = type;
}

void
TypeCheckContext::insert_implicit_type (HirId id, TyTy::BaseType *type)
{
Expand Down

0 comments on commit af234dd

Please sign in to comment.