Skip to content

Commit

Permalink
hir: Remove duplicate function in TraitItemFunc
Browse files Browse the repository at this point in the history
Both TraitItemFunc::has_definition() and TraitItemFunc::has_block_defined()
were exactly the same implementation, so remove one.

gcc/rust/ChangeLog:

	* hir/tree/rust-hir-item.h: Remove TraitItemFunc::has_block_defined()
	* backend/rust-compile-implitem.cc (CompileTraitItem::visit):
	Call TraitItemFunc::has_definition() instead.
	* checks/errors/rust-const-checker.cc (ConstChecker::visit): Likewise.
	* checks/errors/rust-hir-pattern-analysis.cc (PatternChecker::visit): Likewise.
	* checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Likewise.
	* typecheck/rust-hir-trait-resolve.cc (ResolveTraitItemToRef::visit): Likewise.
  • Loading branch information
CohenArthur committed Nov 30, 2024
1 parent 10cc6e8 commit afbd873
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion gcc/rust/backend/rust-compile-implitem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ CompileTraitItem::visit (HIR::TraitItemConst &constant)
void
CompileTraitItem::visit (HIR::TraitItemFunc &func)
{
rust_assert (func.has_block_defined ());
rust_assert (func.has_definition ());

rust_assert (concrete->get_kind () == TyTy::TypeKind::FNDEF);
TyTy::FnType *fntype = static_cast<TyTy::FnType *> (concrete);
Expand Down
2 changes: 1 addition & 1 deletion gcc/rust/checks/errors/rust-const-checker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ ConstChecker::visit (StaticItem &static_item)
void
ConstChecker::visit (TraitItemFunc &item)
{
if (item.has_block_defined ())
if (item.has_definition ())
item.get_block_expr ().accept_vis (*this);
}

Expand Down
2 changes: 1 addition & 1 deletion gcc/rust/checks/errors/rust-hir-pattern-analysis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ PatternChecker::visit (StaticItem &static_item)
void
PatternChecker::visit (TraitItemFunc &item)
{
if (item.has_block_defined ())
if (item.has_definition ())
item.get_block_expr ().accept_vis (*this);
}

Expand Down
2 changes: 1 addition & 1 deletion gcc/rust/checks/errors/rust-unsafe-checker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ UnsafeChecker::visit (StaticItem &static_item)
void
UnsafeChecker::visit (TraitItemFunc &item)
{
if (item.has_block_defined ())
if (item.has_definition ())
item.get_block_expr ().accept_vis (*this);
}

Expand Down
2 changes: 0 additions & 2 deletions gcc/rust/hir/tree/rust-hir-item.h
Original file line number Diff line number Diff line change
Expand Up @@ -1991,8 +1991,6 @@ class TraitItemFunc : public TraitItem

const TraitFunctionDecl &get_decl () const { return decl; }

bool has_block_defined () const { return block_expr != nullptr; }

BlockExpr &get_block_expr () { return *block_expr; }

const std::string trait_identifier () const override final
Expand Down
2 changes: 1 addition & 1 deletion gcc/rust/typecheck/rust-hir-trait-resolve.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ ResolveTraitItemToRef::visit (HIR::TraitItemFunc &fn)
{
// create trait-item-ref
location_t locus = fn.get_locus ();
bool is_optional = fn.has_block_defined ();
bool is_optional = fn.has_definition ();
std::string identifier = fn.get_decl ().get_function_name ().as_string ();

resolved = TraitItemReference (identifier, is_optional,
Expand Down

0 comments on commit afbd873

Please sign in to comment.