Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2218022/?format=api
{ "id": 2218022, "url": "http://patchwork.ozlabs.org/api/patches/2218022/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/20260331094037.3408-8-gerris.rs@gmail.com/", "project": { "id": 17, "url": "http://patchwork.ozlabs.org/api/projects/17/?format=api", "name": "GNU Compiler Collection", "link_name": "gcc", "list_id": "gcc-patches.gcc.gnu.org", "list_email": "gcc-patches@gcc.gnu.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260331094037.3408-8-gerris.rs@gmail.com>", "list_archive_url": null, "date": "2026-03-31T09:40:34", "name": "[gccrs,COMMIT,08/10] Clean up internal attribute checking", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "077dd10e178a1fc0bbdc41eaca978a8a3f44bd0f", "submitter": { "id": 92092, "url": "http://patchwork.ozlabs.org/api/people/92092/?format=api", "name": null, "email": "gerris.rs@gmail.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/20260331094037.3408-8-gerris.rs@gmail.com/mbox/", "series": [ { "id": 498158, "url": "http://patchwork.ozlabs.org/api/series/498158/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=498158", "date": "2026-03-31T09:40:27", "name": "[gccrs,COMMIT,01/10] Remove AttrInputMacro attribute input kind", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/498158/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2218022/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2218022/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "gcc-patches@gcc.gnu.org" ], "Delivered-To": [ "patchwork-incoming@legolas.ozlabs.org", "gcc-patches@gcc.gnu.org" ], "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=qQZHeTcW;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)", "sourceware.org;\n\tdkim=pass (2048-bit key,\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=qQZHeTcW", "sourceware.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com", "sourceware.org; spf=pass smtp.mailfrom=gmail.com", "server2.sourceware.org;\n arc=none smtp.remote-ip=74.125.82.179" ], "Received": [ "from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4flNYh3sxvz1y1q\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 31 Mar 2026 20:46:48 +1100 (AEDT)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id AB2554BA2E09\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 31 Mar 2026 09:46:46 +0000 (GMT)", "from mail-dy1-f179.google.com (mail-dy1-f179.google.com\n [74.125.82.179])\n by sourceware.org (Postfix) with ESMTPS id 047A54B7A1D0\n for <gcc-patches@gcc.gnu.org>; Tue, 31 Mar 2026 09:40:51 +0000 (GMT)", "by mail-dy1-f179.google.com with SMTP id\n 5a478bee46e88-2c54c68db4dso3950709eec.0\n for <gcc-patches@gcc.gnu.org>; Tue, 31 Mar 2026 02:40:50 -0700 (PDT)", "from\n runnervmrg6be.i0fnop2thlderixbsj2qpy22md.yx.internal.cloudapp.net\n ([57.151.128.242]) by smtp.gmail.com with ESMTPSA id\n 5a478bee46e88-2c3c796d895sm9175510eec.28.2026.03.31.02.40.48\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Tue, 31 Mar 2026 02:40:49 -0700 (PDT)" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org AB2554BA2E09", "OpenDKIM Filter v2.11.0 sourceware.org 047A54B7A1D0" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 047A54B7A1D0", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 047A54B7A1D0", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774950051; cv=none;\n b=JLwuRz30fsVAkXs903LGnz4/6Vhm8AKDFfLbQVsS79i5LbbRqtcC3ds4/tIgaaMbhHU7txju42gprXbAfSpTismQQpZ2cQoUw1qn1WNIxgWI7ZakK2o8UlGUhJuhSftp+v+Mbin0aINK69IF3Fct95oS1Dt270z7Kc4OanJMhJI=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1774950051; c=relaxed/simple;\n bh=pocG07Ij1RFDrWxqjNdmsSOWbsYS3Wbna8WLvdpSJVw=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=l7U6fEV2nyRnLBR5cB/9JyATKPvLUBo7eUTOjCKHMh05LVKuZKXg3A77mdi7dKNKwaP7Hilipdid3zVf7xEoOnkevp66lfnUgCdjZh6IqouGtCSfwrPws8JiusQK5d/idH25vgSDNBmv5v6ypqhmLGj8tdgOgg6vXBsc20PJBVE=", "ARC-Authentication-Results": "i=1; server2.sourceware.org", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20251104; t=1774950050; x=1775554850; darn=gcc.gnu.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=XERyi75/jOI7tKZiA4lSHien9VwaN1u1T1KrYdl/fGw=;\n b=qQZHeTcWz+05kgTFzv6NnfBHNxUKoxa5/Tu1OMsEbS6DVyFHWs3mEJOEkjRwVJx8C0\n RTOc6lYKI590InXHq+HNetMgXWo5101AAR+p7u+JNpBhNklPeg2pYSDnWMjWEyJuGWXp\n RNQW90somfFkFIEq6VolzOoKoDSeFgiDs8RanZeLzFw1bwjpQH2+LXiTDJF/HiA/E054\n Tp0xUBqjTMbd/4ep0L9lfCt/0pPbJrS49v+HNah7xl76gEe7cNaiajeXmaG4ty36erAv\n 0tCuj2PcewvBTuvq3aPtivonAqsbRP/z+Dl/HNwFWbi3Yl/OLXZcNaYcgMOLC8rrPWIW\n QtHw==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1774950050; x=1775554850;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=XERyi75/jOI7tKZiA4lSHien9VwaN1u1T1KrYdl/fGw=;\n b=exuIh3uZXThtc+BcBWRbn/XuIjBdsPcxy9srszxZZTGViHL1wz6X2b1NexO/K3nfBx\n +MYp52NIqod0c0jT1aI22qxykXObrBiPOE8jCoUm2jMYePLhe9tl7R36Rsp4NTYvJdyf\n v/j+o3hvydCMdnyjiDJafv9azsi5Y6hl4eS21oJ5/dN2CXXJ2nM0oMuxKz4Dp2bSiFY3\n f1+6g/LLcLJZw7mip3Ah7Vk1Ok7hb9qyTfQ+J6jTpjqBBVIAVIotrR1j/YIuCnG5CFgV\n XHkD9IXsIolFrCIA1YiRbMZovwI3XHMqlYx+akgr2n5uqxQ++atS1ztBleax5cwpfJbp\n RLOw==", "X-Gm-Message-State": "AOJu0YyUTT9La4aY4Xy77LtHksS2qbYJeDBgeT5Ar/cmwQzzu8EYT4aV\n B8sCtWjioeRDQkCna5I1WTRhkxOrnNajGvfc4zeU0yaExp179M3KfmuZQKZd+Q==", "X-Gm-Gg": "ATEYQzx8HnFa56/o5kYjtriHhMgeO0K06SAkcVjTKk9SgQHC2r2hkf/Rwm1O3iDTbJq\n ewCIczcxXKcnsKraRLdDBQ/V4RisCF3ZBhoUrTZ60qqyT66Ibn6oAQhwLYPsq6igtlDdv54KIrJ\n xJMSyA7ZiAuO0jwwh98tZIyeQjFYgBmWfGgMs6X3agQjmq7EQtgK0haVO50uNJnh1plZVWug1gv\n GlYnsQsREsx6CjnDSQ8r2irjhrK+3feKKpVLS/8P2NqerzJ+iEwZi/f2t1ln6+EVkHD1uyTXkQT\n M7j6Gp/faOOtpimYsK7RAS7BYaotfHaTovNieSKgKgncm5EQrU/FemJhZHCrfWT8UY2UYxpiazl\n h5zvJFAP/IxQn0Xv8oifbZU8wBnPnsR7nndtMeskXbV7A9s/m7aW16RPIEAuypydW5NFt0vt6OX\n 3/nV4Q+5x62i/QTC3BMniGMjy75aqyjq8upnmyZR5IlGPPeXqiLVJSZK8ZnaFZjTKfn+/8qpno2\n 2emC5cq8spjVPa1aLot1pQ=", "X-Received": "by 2002:a05:7300:6420:b0:2c4:ec89:bd3 with SMTP id\n 5a478bee46e88-2c4ec8915c1mr5564326eec.24.1774950049797;\n Tue, 31 Mar 2026 02:40:49 -0700 (PDT)", "From": "gerris.rs@gmail.com", "To": "gcc-patches@gcc.gnu.org,\n\tgcc-rust@gcc.gnu.org", "Cc": "pierre-emmanuel.patry@embecosm.com, arthur.cohen@embecosm.com,\n dkm+gccrs@kataplop.net", "Subject": "[gccrs COMMIT 08/10] Clean up internal attribute checking", "Date": "Tue, 31 Mar 2026 09:40:34 +0000", "Message-ID": "<20260331094037.3408-8-gerris.rs@gmail.com>", "X-Mailer": "git-send-email 2.43.0", "In-Reply-To": "<20260331094037.3408-1-gerris.rs@gmail.com>", "References": "<20260331094037.3408-1-gerris.rs@gmail.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-BeenThere": "gcc-patches@gcc.gnu.org", "X-Mailman-Version": "2.1.30", "Precedence": "list", "List-Id": "Gcc-patches mailing list <gcc-patches.gcc.gnu.org>", "List-Unsubscribe": "<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>", "List-Archive": "<https://gcc.gnu.org/pipermail/gcc-patches/>", "List-Post": "<mailto:gcc-patches@gcc.gnu.org>", "List-Help": "<mailto:gcc-patches-request@gcc.gnu.org?subject=help>", "List-Subscribe": "<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>", "Errors-To": "gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org" }, "content": "From: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>\n\nMove all internal attribute structure checking within specific handler\nfunctions called from the attribute visit function instead of multiple\nduplicated sources in the various items. Store those handlers in a map\nto avoid the expensive string switch comparisons.\n\ngcc/rust/ChangeLog:\n\n\t* checks/errors/rust-builtin-attribute-checker.cc (check_doc_attribute):\n\tMove from here...\n\t(doc): ...to here.\n\t(check_deprecated_attribute): Move from here...\n\t(deprecated): ...to here.\n\t(check_link_section_attribute): Move from here...\n\t(link_section): ... to here.\n\t(check_export_name_attribute): Move from here...\n\t(export_name): ... to here.\n\t(check_no_mangle_function): Remove internal structure checking and move\n\tit to no_mangle handler.\n\t(check_lint_attribute): Move from here...\n\t(lint): ... to here.\n\t(link_name): Likewise with link_name.\n\t(check_crate_type): Move to anonymous namespace within the handler\n\tnamespace.\n\t(proc_macro_derive): Add proc macro specific handler.\n\t(proc_macro): Likewise.\n\t(target_feature): Likewise.\n\t(no_mangle): Add specific handler for no_mangler attribute internal\n\tstructure checking.\n\t(std::function<void): Add map with attribute name to handler matching.\n\t(tl::optional<std::function<void): Likewise.\n\t(lookup_handler): Add an helper function to retrieve the handler of any\n\tbuiltin attribute.\n\t(BuiltinAttributeChecker::visit): Change attribute visitor call with\n\tnew handler call.\n\t* checks/errors/rust-builtin-attribute-checker.h (check_valid_attribute_for_item):\n\tAdd prototype.\n\nSigned-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>\n---\nThis change was merged into the gccrs repository and is posted here for\nupstream visibility and potential drive-by review, as requested by GCC\nrelease managers.\nEach commit email contains a link to its details on github from where you can\nfind the Pull-Request and associated discussions.\n\n\nCommit on github: https://github.com/Rust-GCC/gccrs/commit/19ff10b0786e1d8bdbfa15e0e26fe6081dcbd5d6\n\nThe commit has been mentioned in the following pull-request(s):\n - https://github.com/Rust-GCC/gccrs/pull/4505\n\n .../errors/rust-builtin-attribute-checker.cc | 248 ++++++++++--------\n .../errors/rust-builtin-attribute-checker.h | 3 +\n 2 files changed, 136 insertions(+), 115 deletions(-)", "diff": "diff --git a/gcc/rust/checks/errors/rust-builtin-attribute-checker.cc b/gcc/rust/checks/errors/rust-builtin-attribute-checker.cc\nindex a2bf83f93..f6a2e2c83 100644\n--- a/gcc/rust/checks/errors/rust-builtin-attribute-checker.cc\n+++ b/gcc/rust/checks/errors/rust-builtin-attribute-checker.cc\n@@ -80,8 +80,15 @@ check_doc_alias (const std::string &alias_input, const location_t locus)\n \t\t \"%<#[doc(alias)]%> input cannot start or end with a space\");\n }\n \n-static void\n-check_doc_attribute (const AST::Attribute &attribute)\n+// This namespace contains handlers for the builtin attribute checker,\n+// those handlers must verify the attribute internal structure and emit the\n+// appropriate error message if the structure is incorrect.\n+//\n+// They DO NOT check the attribute validity on the parent item.\n+namespace handlers {\n+\n+void\n+doc (const AST::Attribute &attribute)\n {\n if (!attribute.has_attr_input ())\n {\n@@ -125,8 +132,8 @@ check_doc_attribute (const AST::Attribute &attribute)\n }\n }\n \n-static void\n-check_deprecated_attribute (const AST::Attribute &attribute)\n+void\n+deprecated (const AST::Attribute &attribute)\n {\n if (!attribute.has_attr_input ())\n return;\n@@ -219,8 +226,8 @@ check_deprecated_attribute (const AST::Attribute &attribute)\n }\n }\n \n-static void\n-check_link_section_attribute (const AST::Attribute &attribute)\n+void\n+link_section (const AST::Attribute &attribute)\n {\n if (!attribute.has_attr_input ())\n {\n@@ -231,8 +238,8 @@ check_link_section_attribute (const AST::Attribute &attribute)\n }\n }\n \n-static void\n-check_export_name_attribute (const AST::Attribute &attribute)\n+void\n+export_name (const AST::Attribute &attribute)\n {\n if (!attribute.has_attr_input ())\n {\n@@ -264,34 +271,131 @@ check_export_name_attribute (const AST::Attribute &attribute)\n rust_error_at (attribute.get_locus (), \"attribute must be a string literal\");\n }\n \n-static void\n-check_no_mangle_function (const AST::Attribute &attribute,\n-\t\t\t const AST::Function &fun)\n+void\n+lint (const AST::Attribute &attribute)\n {\n- if (attribute.has_attr_input ())\n+ if (!attribute.has_attr_input ())\n {\n- rust_error_at (attribute.get_locus (), ErrorCode::E0754,\n-\t\t \"malformed %<no_mangle%> attribute input\");\n+ auto name = attribute.get_path ().as_string ();\n+ rust_error_at (attribute.get_locus (), \"malformed %qs attribute input\",\n+\t\t name.c_str ());\n rust_inform (attribute.get_locus (),\n-\t\t \"must be of the form: %<#[no_mangle]%>\");\n+\t\t \"must be of the form: %<#[%s(lint1, lint2, ...)]%>\",\n+\t\t name.c_str ());\n }\n- if (!is_ascii_only (fun.get_function_name ().as_string ()))\n- rust_error_at (fun.get_function_name ().get_locus (),\n-\t\t \"the %<#[no_mangle]%> attribute requires ASCII identifier\");\n }\n \n+void\n+link_name (const AST::Attribute &attribute)\n+{\n+ if (!attribute.has_attr_input ())\n+ {\n+ rust_error_at (attribute.get_locus (),\n+\t\t \"malformed %<link_name%> attribute input\");\n+ rust_inform (attribute.get_locus (),\n+\t\t \"must be of the form: %<#[link_name = \\\"name\\\"]%>\");\n+ }\n+}\n+\n+namespace {\n+void\n+check_crate_type (const AST::Attribute &attribute)\n+{\n+ if (!Session::get_instance ().options.is_proc_macro ())\n+ {\n+ auto name = attribute.get_path ().as_string ();\n+\n+ rust_error_at (attribute.get_locus (),\n+\t\t \"the %<#[%s]%> attribute is only usable with crates of \"\n+\t\t \"the %<proc-macro%> crate type\",\n+\t\t name.c_str ());\n+ }\n+}\n+} // namespace\n+\n static void\n-check_lint_attribute (const AST::Attribute &attribute, const char *name)\n+proc_macro_derive (const AST::Attribute &attribute)\n {\n if (!attribute.has_attr_input ())\n {\n+ auto name = attribute.get_path ().as_string ();\n rust_error_at (attribute.get_locus (), \"malformed %qs attribute input\",\n-\t\t name);\n+\t\t name.c_str ());\n+ rust_inform (attribute.get_locus (),\n+\t\t \"must be of the form: %<#[proc_macro_derive(TraitName, \"\n+\t\t \"/*opt*/ attributes(name1, name2, ...))]%>\");\n+ }\n+ check_crate_type (attribute);\n+}\n+\n+static void\n+proc_macro (const AST::Attribute &attribute)\n+{\n+ check_crate_type (attribute);\n+}\n+\n+static void\n+target_feature (const AST::Attribute &attribute)\n+{\n+ if (!attribute.has_attr_input ())\n+ {\n+ rust_error_at (attribute.get_locus (),\n+\t\t \"malformed %<target_feature%> attribute input\");\n rust_inform (attribute.get_locus (),\n-\t\t \"must be of the form: %<#[%s(lint1, lint2, ...)]%>\", name);\n+\t\t \"must be of the form: %<#[target_feature(enable = \"\n+\t\t \"\\\"name\\\")]%>\");\n }\n }\n \n+void\n+no_mangle (const AST::Attribute &attribute)\n+{\n+ if (attribute.has_attr_input ())\n+ {\n+ rust_error_at (attribute.get_locus (), ErrorCode::E0754,\n+\t\t \"malformed %<no_mangle%> attribute input\");\n+ rust_inform (attribute.get_locus (),\n+\t\t \"must be of the form: %<#[no_mangle]%>\");\n+ }\n+}\n+\n+} // namespace handlers\n+\n+const std::unordered_map<std::string, std::function<void (AST::Attribute &)>>\n+ attribute_checking_handlers\n+ = {{Attrs::DOC, handlers::doc},\n+ {Attrs::DEPRECATED, handlers::deprecated},\n+ {Attrs::LINK_SECTION, handlers::link_section},\n+ {Attrs::EXPORT_NAME, handlers::export_name},\n+ {Attrs::NO_MANGLE, handlers::no_mangle},\n+ {Attrs::ALLOW, handlers::lint},\n+ {\"deny\", handlers::lint},\n+ {\"warn\", handlers::lint},\n+ {\"forbid\", handlers::lint},\n+ {Attrs::LINK_NAME, handlers::link_name},\n+ {Attrs::PROC_MACRO_DERIVE, handlers::proc_macro_derive},\n+ {Attrs::PROC_MACRO, handlers::proc_macro},\n+ {Attrs::PROC_MACRO_ATTRIBUTE, handlers::proc_macro},\n+ {Attrs::TARGET_FEATURE, handlers::target_feature}};\n+\n+tl::optional<std::function<void (AST::Attribute &)>>\n+lookup_handler (std::string attr_name)\n+{\n+ auto res = attribute_checking_handlers.find (attr_name);\n+ if (res != attribute_checking_handlers.cend ())\n+ return res->second;\n+ return tl::nullopt;\n+}\n+\n+static void\n+check_no_mangle_function (const AST::Attribute &attribute,\n+\t\t\t const AST::Function &fun)\n+{\n+ if (!is_ascii_only (fun.get_function_name ().as_string ()))\n+ rust_error_at (fun.get_function_name ().get_locus (),\n+\t\t \"the %<#[no_mangle]%> attribute requires ASCII identifier\");\n+}\n+\n /**\n * Emit an error when an attribute is attached\n * to an incompatable item type. e.g.:\n@@ -302,7 +406,7 @@ check_lint_attribute (const AST::Attribute &attribute, const char *name)\n * Note that \"#[derive]\" is handled\n * explicitly in rust-derive.cc\n */\n-static void\n+void\n check_valid_attribute_for_item (const AST::Attribute &attr,\n \t\t\t\tconst AST::Item &item)\n {\n@@ -349,18 +453,9 @@ BuiltinAttributeChecker::visit (AST::Crate &crate)\n void\n BuiltinAttributeChecker::visit (AST::Attribute &attribute)\n {\n- if (auto builtin = lookup_builtin (attribute))\n- {\n- auto result = builtin.value ();\n- // TODO: Add checks here for each builtin attribute\n- // TODO: Have an enum of builtins as well, switching on strings is\n- // annoying and costly\n- if (result.name == Attrs::DOC)\n-\tcheck_doc_attribute (attribute);\n- else if (result.name == Attrs::DEPRECATED)\n-\tcheck_deprecated_attribute (attribute);\n- }\n-\n+ lookup_handler (attribute.get_path ().as_string ()).map ([&] (auto handler) {\n+ handler (attribute);\n+ });\n AST::DefaultASTVisitor::visit (attribute);\n }\n \n@@ -385,14 +480,6 @@ BuiltinAttributeChecker::visit (AST::UseDeclaration &declaration)\n void\n BuiltinAttributeChecker::visit (AST::Function &function)\n {\n- auto check_crate_type = [] (const char *name, AST::Attribute &attribute) {\n- if (!Session::get_instance ().options.is_proc_macro ())\n- rust_error_at (attribute.get_locus (),\n-\t\t \"the %<#[%s]%> attribute is only usable with crates of \"\n-\t\t \"the %<proc-macro%> crate type\",\n-\t\t name);\n- };\n-\n BuiltinAttrDefinition result;\n for (auto &attribute : function.get_outer_attrs ())\n {\n@@ -402,37 +489,9 @@ BuiltinAttributeChecker::visit (AST::Function &function)\n if (!result)\n \treturn;\n \n- auto name = result->name.c_str ();\n-\n- if (result->name == Attrs::PROC_MACRO_DERIVE)\n-\t{\n-\t if (!attribute.has_attr_input ())\n-\t {\n-\t rust_error_at (attribute.get_locus (),\n-\t\t\t \"malformed %qs attribute input\", name);\n-\t rust_inform (\n-\t\tattribute.get_locus (),\n-\t\t\"must be of the form: %<#[proc_macro_derive(TraitName, \"\n-\t\t\"/*opt*/ attributes(name1, name2, ...))]%>\");\n-\t }\n-\t check_crate_type (name, attribute);\n-\t}\n- else if (result->name == Attrs::PROC_MACRO\n-\t || result->name == Attrs::PROC_MACRO_ATTRIBUTE)\n+ if (result->name == Attrs::TARGET_FEATURE)\n \t{\n-\t check_crate_type (name, attribute);\n-\t}\n- else if (result->name == Attrs::TARGET_FEATURE)\n-\t{\n-\t if (!attribute.has_attr_input ())\n-\t {\n-\t rust_error_at (attribute.get_locus (),\n-\t\t\t \"malformed %<target_feature%> attribute input\");\n-\t rust_inform (attribute.get_locus (),\n-\t\t\t \"must be of the form: %<#[target_feature(enable = \"\n-\t\t\t \"\\\"name\\\")]%>\");\n-\t }\n-\t else if (!function.get_qualifiers ().is_unsafe ())\n+\t if (!function.get_qualifiers ().is_unsafe ())\n \t {\n \t rust_error_at (\n \t\tattribute.get_locus (),\n@@ -442,38 +501,7 @@ BuiltinAttributeChecker::visit (AST::Function &function)\n \t}\n else if (result->name == Attrs::NO_MANGLE)\n \t{\n-\t if (attribute.has_attr_input ())\n-\t {\n-\t rust_error_at (attribute.get_locus (),\n-\t\t\t \"malformed %<no_mangle%> attribute input\");\n-\t rust_inform (attribute.get_locus (),\n-\t\t\t \"must be of the form: %<#[no_mangle]%>\");\n-\t }\n-\t else\n-\t check_no_mangle_function (attribute, function);\n-\t}\n- else if (result->name == Attrs::EXPORT_NAME)\n-\t{\n-\t check_export_name_attribute (attribute);\n-\t}\n- else if (result->name == Attrs::ALLOW || result->name == \"deny\"\n-\t || result->name == \"warn\" || result->name == \"forbid\")\n-\t{\n-\t check_lint_attribute (attribute, name);\n-\t}\n- else if (result->name == Attrs::LINK_NAME)\n-\t{\n-\t if (!attribute.has_attr_input ())\n-\t {\n-\t rust_error_at (attribute.get_locus (),\n-\t\t\t \"malformed %<link_name%> attribute input\");\n-\t rust_inform (attribute.get_locus (),\n-\t\t\t \"must be of the form: %<#[link_name = \\\"name\\\"]%>\");\n-\t }\n-\t}\n- else if (result->name == Attrs::LINK_SECTION)\n-\t{\n-\t check_link_section_attribute (attribute);\n+\t check_no_mangle_function (attribute, function);\n \t}\n }\n \n@@ -520,17 +548,7 @@ void\n BuiltinAttributeChecker::visit (AST::StaticItem &item)\n {\n for (auto &attr : item.get_outer_attrs ())\n- {\n- check_valid_attribute_for_item (attr, item);\n-\n- if (auto result = lookup_builtin (attr))\n-\t{\n-\t if (result->name == Attrs::LINK_SECTION)\n-\t check_link_section_attribute (attr);\n-\t else if (result->name == Attrs::EXPORT_NAME)\n-\t check_export_name_attribute (attr);\n-\t}\n- }\n+ check_valid_attribute_for_item (attr, item);\n \n AST::DefaultASTVisitor::visit (item);\n }\ndiff --git a/gcc/rust/checks/errors/rust-builtin-attribute-checker.h b/gcc/rust/checks/errors/rust-builtin-attribute-checker.h\nindex 957243a1a..4765e630d 100644\n--- a/gcc/rust/checks/errors/rust-builtin-attribute-checker.h\n+++ b/gcc/rust/checks/errors/rust-builtin-attribute-checker.h\n@@ -24,6 +24,9 @@\n namespace Rust {\n namespace Analysis {\n \n+void check_valid_attribute_for_item (const AST::Attribute &attr,\n+\t\t\t\t const AST::Item &item);\n+\n class BuiltinAttributeChecker : public AST::DefaultASTVisitor\n {\n using AST::DefaultASTVisitor::visit;\n", "prefixes": [ "gccrs", "COMMIT", "08/10" ] }