https://gcc.gnu.org/g:68f142a0e92cc451d92e0bd9a4ca75dc50a7ff8f
commit 68f142a0e92cc451d92e0bd9a4ca75dc50a7ff8f Author: Arthur Cohen <arthur.co...@embecosm.com> Date: Thu Dec 26 22:45:12 2024 +0000 lang-item: Add LangItem::PrettyString Which formats a lang item as it appears in source code. gcc/rust/ChangeLog: * util/rust-lang-item.cc (LangItem::PrettyString): New. * util/rust-lang-item.h: New. Diff: --- gcc/rust/util/rust-lang-item.cc | 6 ++++++ gcc/rust/util/rust-lang-item.h | 1 + 2 files changed, 7 insertions(+) diff --git a/gcc/rust/util/rust-lang-item.cc b/gcc/rust/util/rust-lang-item.cc index bd5a29da9ffe..674b18919d27 100644 --- a/gcc/rust/util/rust-lang-item.cc +++ b/gcc/rust/util/rust-lang-item.cc @@ -118,6 +118,12 @@ LangItem::ToString (LangItem::Kind type) return str.value (); } +std::string +LangItem::PrettyString (LangItem::Kind type) +{ + return "#[lang = \"" + LangItem::ToString (type) + "\"]"; +} + LangItem::Kind LangItem::OperatorToLangItem (ArithmeticOrLogicalOperator op) { diff --git a/gcc/rust/util/rust-lang-item.h b/gcc/rust/util/rust-lang-item.h index 35ee5c2a2c3a..f2e9d7036124 100644 --- a/gcc/rust/util/rust-lang-item.h +++ b/gcc/rust/util/rust-lang-item.h @@ -134,6 +134,7 @@ public: static tl::optional<Kind> Parse (const std::string &item); static std::string ToString (Kind type); + static std::string PrettyString (Kind type); static Kind OperatorToLangItem (ArithmeticOrLogicalOperator op); static Kind CompoundAssignmentOperatorToLangItem (ArithmeticOrLogicalOperator op);