https://gcc.gnu.org/g:2b54f6275a569bdafc5e95f2c1f8a565c16ab0a0
commit r17-4091-g2b54f6275a569bdafc5e95f2c1f8a565c16ab0a0 Author: Arthur Cohen <[email protected]> Date: Mon Aug 3 12:27:18 2026 +0200 gccrs: lower: Mention which attribute is unknown 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. Diff: --- 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 7a5ac6dd2e38..8a952f8dceed 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 70a98866dcef..0de6ace8acf3 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; }
