Skip to content

Commit

Permalink
mappings: Move lang_item definitions to .cc
Browse files Browse the repository at this point in the history
gcc/rust/ChangeLog:

	* util/rust-hir-map.h: Move definitions from header...
	* util/rust-hir-map.cc: ...to source file.
  • Loading branch information
CohenArthur committed Nov 28, 2024
1 parent 1d5f710 commit 10cc6e8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
19 changes: 19 additions & 0 deletions gcc/rust/util/rust-hir-map.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1258,5 +1258,24 @@ Mappings::lookup_trait_item_lang_item (LangItem::Kind item, location_t locus)
return lookup_trait_item_defid (trait_item_id);
}

void
Mappings::insert_lang_item (LangItem::Kind item_type, DefId id)
{
auto it = lang_item_mappings.find (item_type);
rust_assert (it == lang_item_mappings.end ());

lang_item_mappings[item_type] = id;
}

tl::optional<DefId &>
Mappings::lookup_lang_item (LangItem::Kind item_type)
{
auto it = lang_item_mappings.find (item_type);
if (it == lang_item_mappings.end ())
return tl::nullopt;

return it->second;
}

} // namespace Analysis
} // namespace Rust
18 changes: 2 additions & 16 deletions gcc/rust/util/rust-hir-map.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,22 +256,8 @@ class Mappings
return it->second;
}

void insert_lang_item (LangItem::Kind item_type, DefId id)
{
auto it = lang_item_mappings.find (item_type);
rust_assert (it == lang_item_mappings.end ());

lang_item_mappings[item_type] = id;
}

tl::optional<DefId &> lookup_lang_item (LangItem::Kind item_type)
{
auto it = lang_item_mappings.find (item_type);
if (it == lang_item_mappings.end ())
return tl::nullopt;

return it->second;
}
void insert_lang_item (LangItem::Kind item_type, DefId id);
tl::optional<DefId &> lookup_lang_item (LangItem::Kind item_type);

// This will fatal_error when this lang item does not exist
DefId get_lang_item (LangItem::Kind item_type, location_t locus);
Expand Down

0 comments on commit 10cc6e8

Please sign in to comment.