Skip to content

Commit

Permalink
lang-item: Add Option::{None, Some}, Iterator::next, IntoIter::into_iter
Browse files Browse the repository at this point in the history
gcc/rust/ChangeLog:

	* util/rust-lang-item.h: Add new lang items.
	* util/rust-lang-item.cc: Likewise.
  • Loading branch information
CohenArthur committed Dec 31, 2024
1 parent 5c64794 commit 699fdd4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions gcc/rust/util/rust-lang-item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ const BiMap<std::string, LangItem::Kind> Rust::LangItem::lang_items = {{
{"str", Kind::STR},
{"f32_runtime", Kind::F32_RUNTIME},
{"f64_runtime", Kind::F64_RUNTIME},

{"Some", Kind::OPTION_SOME},
{"None", Kind::OPTION_NONE},

{"into_iter", Kind::INTOITER_INTOITER},
{"next", Kind::ITERATOR_NEXT},
}};

tl::optional<LangItem::Kind>
Expand Down
9 changes: 9 additions & 0 deletions gcc/rust/util/rust-lang-item.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ namespace Rust {
class LangItem
{
public:
// FIXME: We should clean up that enum to make it more inline with the list of
// lang-items in Rust 1.49
// https://github.com/rust-lang/rust/blob/1.49.0/compiler/rustc_hir/src/lang_items.rs
enum class Kind
{
// https://github.com/rust-lang/rust/blob/master/library/core/src/ops/arith.rs
Expand Down Expand Up @@ -117,6 +120,12 @@ class LangItem
STR,
F32_RUNTIME,
F64_RUNTIME,

OPTION_SOME,
OPTION_NONE,

INTOITER_INTOITER,
ITERATOR_NEXT,
};

static const BiMap<std::string, Kind> lang_items;
Expand Down

0 comments on commit 699fdd4

Please sign in to comment.