From: Arthur Cohen <[email protected]>

And also check attributes only in one place to avoid duplicating error handling.

gcc/rust/ChangeLog:

        * ast/rust-collect-lang-items.cc (get_lang_item_attr): Remove attribute 
checking
        code as this will be done during lowering.
        * hir/rust-ast-lower-base.cc 
(ASTLoweringBase::handle_outer_attributes): Mention
        the attribute which is unknown.
---
 gcc/rust/ast/rust-collect-lang-items.cc | 9 +++------
 gcc/rust/hir/rust-ast-lower-base.cc     | 3 ++-
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/gcc/rust/ast/rust-collect-lang-items.cc 
b/gcc/rust/ast/rust-collect-lang-items.cc
index 7a5ac6dd2e3..8a952f8dcee 100644
--- a/gcc/rust/ast/rust-collect-lang-items.cc
+++ b/gcc/rust/ast/rust-collect-lang-items.cc
@@ -36,12 +36,9 @@ 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 (!Analysis::Attributes::is_known (str_path))
-       {
-         rust_error_at (attr.get_locus (), "unknown attribute %qs",
-                        str_path.c_str ());
-         continue;
-       }
+
+      // Attribute checking is done elsewhere, we can just check whether or not
+      // we're dealing with a lang item here
 
       bool is_lang_item = str_path == Values::Attributes::LANG;
 
diff --git a/gcc/rust/hir/rust-ast-lower-base.cc 
b/gcc/rust/hir/rust-ast-lower-base.cc
index 70a98866dce..0de6ace8acf 100644
--- a/gcc/rust/hir/rust-ast-lower-base.cc
+++ b/gcc/rust/hir/rust-ast-lower-base.cc
@@ -799,7 +799,8 @@ ASTLoweringBase::handle_outer_attributes (const ItemWrapper 
&item)
       const auto &str_path = attr.get_path ().as_string ();
       if (!Analysis::Attributes::is_known (str_path))
        {
-         rust_error_at (attr.get_locus (), "unknown attribute");
+         rust_error_at (attr.get_locus (), "unknown attribute: %qs",
+                        str_path.c_str ());
          continue;
        }
 
-- 
2.50.1

Reply via email to