get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/1.1/patches/2223297/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2223297,
    "url": "http://patchwork.ozlabs.org/api/1.1/patches/2223297/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/20260414231905.191063-28-arthur.cohen@embecosm.com/",
    "project": {
        "id": 17,
        "url": "http://patchwork.ozlabs.org/api/1.1/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
    },
    "msgid": "<20260414231905.191063-28-arthur.cohen@embecosm.com>",
    "date": "2026-04-14T23:18:49",
    "name": "[COMMITTED,28/43] gccrs: Clean up internal attribute checking",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "077dd10e178a1fc0bbdc41eaca978a8a3f44bd0f",
    "submitter": {
        "id": 83476,
        "url": "http://patchwork.ozlabs.org/api/1.1/people/83476/?format=api",
        "name": "Arthur Cohen",
        "email": "arthur.cohen@embecosm.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/20260414231905.191063-28-arthur.cohen@embecosm.com/mbox/",
    "series": [
        {
            "id": 499900,
            "url": "http://patchwork.ozlabs.org/api/1.1/series/499900/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=499900",
            "date": "2026-04-14T23:18:24",
            "name": "[COMMITTED,01/43] gccrs: testsuite:Add a testcase for setup_associated_types",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/499900/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2223297/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2223297/checks/",
    "tags": {},
    "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=embecosm.com header.i=@embecosm.com header.a=rsa-sha256\n header.s=google header.b=ajwAx12a;\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=embecosm.com header.i=@embecosm.com header.a=rsa-sha256\n header.s=google header.b=ajwAx12a",
            "sourceware.org;\n dmarc=none (p=none dis=none) header.from=embecosm.com",
            "sourceware.org; spf=pass smtp.mailfrom=embecosm.com",
            "server2.sourceware.org;\n arc=none smtp.remote-ip=209.85.128.65"
        ],
        "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 4fwL740RGyz1yCv\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 15 Apr 2026 09:28:16 +1000 (AEST)",
            "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 19C0D4BA23E9\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 14 Apr 2026 23:28:14 +0000 (GMT)",
            "from mail-wm1-f65.google.com (mail-wm1-f65.google.com\n [209.85.128.65])\n by sourceware.org (Postfix) with ESMTPS id 7286D4BA23EC\n for <gcc-patches@gcc.gnu.org>; Tue, 14 Apr 2026 23:14:52 +0000 (GMT)",
            "by mail-wm1-f65.google.com with SMTP id\n 5b1f17b1804b1-488a29e6110so66404275e9.3\n for <gcc-patches@gcc.gnu.org>; Tue, 14 Apr 2026 16:14:52 -0700 (PDT)",
            "from platypus.localdomain (176-147-231-59.abo.bbox.fr.\n [176.147.231.59]) by smtp.gmail.com with ESMTPSA id\n 5b1f17b1804b1-488f1dd8806sm3325945e9.3.2026.04.14.16.14.49\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Tue, 14 Apr 2026 16:14:49 -0700 (PDT)"
        ],
        "DKIM-Filter": [
            "OpenDKIM Filter v2.11.0 sourceware.org 19C0D4BA23E9",
            "OpenDKIM Filter v2.11.0 sourceware.org 7286D4BA23EC"
        ],
        "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 7286D4BA23EC",
        "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 7286D4BA23EC",
        "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776208492; cv=none;\n b=XC/W/0TftLQ7ei/hOu3y+CqDajMHNWbAfCEUNDhoYBfWrDDYF/04EP1SJxZoM/wQeNcNtzVG34QwmT4eq6DVeZ1xiv040M9+y74e1s1v9Gr97DgVixIlwB2GDGIDxtg0gw+pxwsfxSSAmZhMDSyDKAhSsJf08QgriRqJjZriHa0=",
        "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776208492; c=relaxed/simple;\n bh=7aoDFINIAAVO5p4EjjSD9DNiZfpNSYpYsncSVbFXkgE=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=wFND/TZPGqS/ZSusM/m8MwZ4bNy5sexjv4KgTanturUtAR02gnfYGwkWO/uHISlbbYo75GJVYxUUpOGJDGpwdPIhfUfKm4fTeuImxyjlJC7WPgEXHHTXw/SVCL0PMKGCOTXiQPxddN+1hPa9FPuE2vaRqyIddRK2Wc9sx+O49eg=",
        "ARC-Authentication-Results": "i=1; server2.sourceware.org",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=embecosm.com; s=google; t=1776208491; x=1776813291; 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=D6r4sKbJAN6kWe2Ne4NwXarwjzIeelxkLYO/gU1k97o=;\n b=ajwAx12aSmjxikZKFdIEAet6OnRqV1Cg+sEZjbKmJgVeLZyfOhn+9681oc2gsj/4sA\n QeVKAWhE8fDfXjxuWPHaIKjZuPtnqY3tFRyCIM7XaFG0mpFTBv2dH6IGx4JMAssDXZGx\n 3tZ1EFCB5vpK81ukIJnWQnLK4pHjgB2bKo0OwwGhztQNbhAmJOo3/TRVtkLM7zRR8phX\n cuvPy25V8Y1+TxTfJbORpsM7/aO2GCIj8NAg+mFm4KjaCy8Ff1UwU0Az24TtxS9Z+W2e\n v4K+nNWFeX2dttTqTM1b+NxAfXeeqno7oqRrqMIM06NBGEQvTvZQHd0lRhZfmOSc7IyL\n z15A==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776208491; x=1776813291;\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=D6r4sKbJAN6kWe2Ne4NwXarwjzIeelxkLYO/gU1k97o=;\n b=aGszXasNGH6K8dSd0oE9lkO8y56IQgs0pspTilFRHrf2smQmxu/UDTNHeu9dHw54YU\n +kyOT0/jqP3zNKu266rBY+TiPfcoLKTmrwULwKBKvk/XMi1FQ9QWjm2vnOew4EsXQSYX\n F3mSJP8UEryDhRg+351DKnww5O/CD/dUSIKOQYHvtPHeBx2xoa3JBw/PoRYarzNZHVFR\n 1ExYTmy1EGNqI/MGt+1KmpjzKaG7mgKTAdIh6ItIJ3d91r1Bo8wthTBJm0hhqj89Onh1\n Q4rOsU1g9yqFwvUHDsUbzx8Ztta2UlxeUAbX5eu1qy0n2Wc0fIW5Og8EiGB0raUeOBE3\n fxhw==",
        "X-Gm-Message-State": "AOJu0Yx3OQVcyfomaGE3TyrmNuVUyDaUWEWZOj40wLmpc3iRx2ajjwNE\n AbI3YHHsi2bqnSpjNJaqtZ/+MY5E3s0sEO3QQnIul5JfdTop/lFAGPvsFBh3y1WQCYbZ2ivkOGN\n no7IN9X3A",
        "X-Gm-Gg": "AeBDietTgp/1Pr+gZaq5E5YfsvWDb0i8A812lhRoxwiPVeIv0nwMBc428tegAUS+oRr\n aj8lmEOePVS9CuE54a8jJPLJaPg3nnM3nVMzGCF+ADkqiBEQRclN1W0eZz7+mHOZ7iwr0tW6FyX\n HqCVc1npzeazXNMKa9Djxj92nbOfKamOwtYs14N6k4HtzkZWOWz/3KhHC0wX3syMMI8Fvtj5rHy\n MLxbXql/o79MPZ0awp46oS5lSwKVYnnmD0jz8zSr2YU+vLXupHWL581bufvubHFHXJyQVc1d5q3\n jXMPD+qk5tvZzK7p9Yio+C4VJKrG4AFQMek7IrKcy1QMW+toC2Hkk4JFyqjQhM26PUOxzy1+Ezt\n FJLITYW0T6mTAs0yH5M9tYOvHWchyoJYzMcs/LJ/BA9FXmYXxRzxvsg6XnxDbScxp2mf0HVs9Fr\n lp0HNytD28oqi3SNOac+f40ukkwZAvCkqabNhFgLbAbZsRo+CHH3/TO+yVJ7iTgzOatIPOZx9Ka\n c8Zvg==",
        "X-Received": "by 2002:a05:600c:5306:b0:487:59c:2bb8 with SMTP id\n 5b1f17b1804b1-488d68c3385mr261278525e9.27.1776208491098;\n Tue, 14 Apr 2026 16:14:51 -0700 (PDT)",
        "From": "arthur.cohen@embecosm.com",
        "To": "gcc-patches@gcc.gnu.org",
        "Cc": "gcc-rust@gcc.gnu.org,\n Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>",
        "Subject": "[COMMITTED 28/43] gccrs: Clean up internal attribute checking",
        "Date": "Wed, 15 Apr 2026 01:18:49 +0200",
        "Message-ID": "<20260414231905.191063-28-arthur.cohen@embecosm.com>",
        "X-Mailer": "git-send-email 2.50.1",
        "In-Reply-To": "<20260414231905.191063-1-arthur.cohen@embecosm.com>",
        "References": "<20260414231905.191063-1-arthur.cohen@embecosm.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---\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 a2bf83f93cd..f6a2e2c836d 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 957243a1a21..4765e630d35 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": [
        "COMMITTED",
        "28/43"
    ]
}