aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/ast/rust-collect-lang-items.cc
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2024-12-04 13:53:11 +0000
committerCohenArthur <arthur.cohen@embecosm.com>2024-12-04 17:39:53 +0000
commit72081086d6b8228f7db6526e39e41bea2eae244c (patch)
treecffdb8fed5c0679a7e39b3c3e4df2ed2a15ff429 /gcc/rust/ast/rust-collect-lang-items.cc
parent6b7e055ecc9a83295cb1f6cd7bb58f3270f2cd0c (diff)
downloadgcc-72081086d6b8228f7db6526e39e41bea2eae244c.zip
gcc-72081086d6b8228f7db6526e39e41bea2eae244c.tar.gz
gcc-72081086d6b8228f7db6526e39e41bea2eae244c.tar.bz2
attributes: Add class for sharing methods on attributes.
gcc/rust/ChangeLog: * util/rust-attributes.h (class Attributes): New. * util/rust-attributes.cc: Implement Attributes::is_known(). * ast/rust-collect-lang-items.cc (is_known_attribute): Remove. (get_lang_item_attr): Call Attributes::is_known() instead. * hir/rust-ast-lower-base.cc (ASTLoweringBase::handle_outer_attributes): Likewise. (ASTLoweringBase::is_known_attribute): Remove.
Diffstat (limited to 'gcc/rust/ast/rust-collect-lang-items.cc')
-rw-r--r--gcc/rust/ast/rust-collect-lang-items.cc13
1 files changed, 1 insertions, 12 deletions
diff --git a/gcc/rust/ast/rust-collect-lang-items.cc b/gcc/rust/ast/rust-collect-lang-items.cc
index 11a30aa..308720a 100644
--- a/gcc/rust/ast/rust-collect-lang-items.cc
+++ b/gcc/rust/ast/rust-collect-lang-items.cc
@@ -27,17 +27,6 @@
namespace Rust {
namespace AST {
-// FIXME: Before merging: De-duplicate with function in rust-ast-lower-base.cc
-bool
-is_known_attribute (const std::string &attribute_path)
-{
- const auto &lookup
- = Analysis::BuiltinAttributeMappings::get ()->lookup_builtin (
- attribute_path);
-
- return !lookup.is_error ();
-}
-
template <typename T>
tl::optional<LangItem::Kind>
get_lang_item_attr (const T &maybe_lang_item)
@@ -45,7 +34,7 @@ get_lang_item_attr (const T &maybe_lang_item)
for (const auto &attr : maybe_lang_item.get_outer_attrs ())
{
const auto &str_path = attr.get_path ().as_string ();
- if (!is_known_attribute (str_path))
+ if (!Analysis::Attributes::is_known (str_path))
{
rust_error_at (attr.get_locus (), "unknown attribute");
continue;