From: Arthur Cohen Date: Thu, 26 Dec 2024 22:45:12 +0000 (+0000) Subject: gccrs: lang-item: Add LangItem::PrettyString X-Git-Tag: basepoints/gcc-16~930 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5702b0a24e64082bcfd19372a67ef7699d033d22;p=thirdparty%2Fgcc.git gccrs: 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 --git a/gcc/rust/util/rust-lang-item.cc b/gcc/rust/util/rust-lang-item.cc index 4a609096144..e038e900f94 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 62b15d7b3fc..f947f3f021c 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 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);