[gccrs COMMIT 1/3] lower: Mention which attribute is unknown

[email protected]
Newsgroups gmane.comp.gcc.rust,gmane.comp.gcc.patches
Message-ID <[email protected]>
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.
---
This change was merged into the gccrs repository and is posted here for
upstream visibility and potential drive-by review, as requested by GCC
release managers.
Each commit email contains a link to its details on github from where you can
find the Pull-Request and associated discussions.


Commit on github: https://github.com/Rust-GCC/gccrs/commit/87469f093f1b01c2d0f1a959674e2a55a9d941dc

The commit has NOT been mentioned in any issue.

The commit has been mentioned in the following pull-request(s):
 - https://github.com/Rust-GCC/gccrs/pull/4752

 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 7a5ac6dd2..8a952f8dc 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 70a98866d..0de6ace8a 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;
 	}
 

base-commit: f36b5728fde83087c5a4ab9f2aadc8b97b0d9afd
-- 
2.54.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.