{"id":2223287,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2223287/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/20260414231905.191063-19-arthur.cohen@embecosm.com/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/1.2/projects/17/?format=json","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":"<20260414231905.191063-19-arthur.cohen@embecosm.com>","list_archive_url":null,"date":"2026-04-14T23:18:40","name":"[COMMITTED,19/43] gccrs: Disambiguate identifier and path patterns","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"66e4aa7a4aea02e04779ae8138fc9f7a53ba05c6","submitter":{"id":83476,"url":"http://patchwork.ozlabs.org/api/1.2/people/83476/?format=json","name":"Arthur Cohen","email":"arthur.cohen@embecosm.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/20260414231905.191063-19-arthur.cohen@embecosm.com/mbox/","series":[{"id":499900,"url":"http://patchwork.ozlabs.org/api/1.2/series/499900/?format=json","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/2223287/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2223287/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=embecosm.com header.i=@embecosm.com header.a=rsa-sha256\n header.s=google header.b=emh5buFA;\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=emh5buFA","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.66"],"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 4fwL1N2G34z1yHM\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 15 Apr 2026 09:23:20 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 527794BA23EA\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 14 Apr 2026 23:23:18 +0000 (GMT)","from mail-wm1-f66.google.com (mail-wm1-f66.google.com\n [209.85.128.66])\n by sourceware.org (Postfix) with ESMTPS id 1121B4BA2E0C\n for <gcc-patches@gcc.gnu.org>; Tue, 14 Apr 2026 23:14:38 +0000 (GMT)","by mail-wm1-f66.google.com with SMTP id\n 5b1f17b1804b1-488c2690057so61657105e9.0\n for <gcc-patches@gcc.gnu.org>; Tue, 14 Apr 2026 16:14:38 -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.34\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Tue, 14 Apr 2026 16:14:34 -0700 (PDT)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 527794BA23EA","OpenDKIM Filter v2.11.0 sourceware.org 1121B4BA2E0C"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 1121B4BA2E0C","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 1121B4BA2E0C","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776208478; cv=none;\n b=O8gfFHxhJdZN3A3HPYY7gQuhZEhSxrmkZ6j7rJcUoul8nIwVDMtMEIYTZ6DRHgn5L5UUOwzbsU+pAfx/I87Lx48TjHu5ThxvHOUPwy4Rnx7lC481djEgOWN1hBjDJtL+MiPB/ahqwsIe/npj/kZ2oJE28fMxCFi3iJs+jZ6LJcI=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776208478; c=relaxed/simple;\n bh=5sgLv9Za9pdSEFBFbgRi/4vhFf4rCeWPzrWuoGpvpLs=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=RbeUz7eQ/MygVbl9Qn7liI/QohNaPX2CsqHklcw77By4rA8giqMC7ai5N6KYNLb1/F2tlnoKSybgxlSd/qrY/kNh3AbHznST2p5nFf6aGDv3yq/aVXbhFQkbHmiMQ8wobB7ejt8LsFHeRMYpHDpuKOguXyo/iHJRYZ3RQTwCa8k=","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=1776208477; x=1776813277; 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=jqsf67irCbuWWm5TRe+/zhXUhAIHrCP8cI+TjYWkLDc=;\n b=emh5buFA3ZhADImAv/aajFkCP+7R2qBd9iCkVCYQbW4gvPrhpHW1dBfLdbWeiJBQB1\n 2/uJZwWrG8UFn2ZkGKMLRdB8q+kAkPjKXWvgP/QVTvHt72V5GmqUITdBfroIF2hw/54S\n HJBk/Y9S6ZoLwwHQDmX6uYh/k6/GL7W/Cef1i83WrIw6joRLB6dSeo5xRj7Sx8gfD+QF\n NknSrFJrFE/yOjP27TG8RqRfXsOBAsmZjzzOPGgfAn9rthFbgNSMXnxFh+byYa6aBB9J\n eBPhtvYkAaNFEZhwV4oWB31QsVRKBj4FEFWHMOe179rlMfw8d29W53WnNhsxlESrcYHJ\n 9geA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776208477; x=1776813277;\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=jqsf67irCbuWWm5TRe+/zhXUhAIHrCP8cI+TjYWkLDc=;\n b=I1OWZi6IBCjFydv8WfP4v+BHMC0De3U8fgQECWVyh6veXiO6JaAEOVrrM+JPkzxlKb\n /QeA+BQj0yLHti2+9UrdH3EZJDr3LEKx4AL6ygYLZKg+ZGlcAiUyk+frs7OaQBTahbFB\n urkqDWSbMNkNoIs9EdnwbLObX4r9JsWtFj8AcgHdCRTVa7oKewXZvAYz4hqPiNC0HAnn\n 4Sa6n8NoFnJsVlA7MvMxlPDo9baa1XBvLD8bd+lB9/o/U6/G57lZGOnSQBs6UXYfwsdR\n vWYvRRhrhPUhZaW/EKrhWE62Gbx/EZy8HVPwl2OyF2PZoOfoFdi9DrnbQ+GxtjVB0YSe\n QtIg==","X-Gm-Message-State":"AOJu0Yw9BBO4cQ0F74W0l4UvvWzb74/4FP5QM6D5pcuHHszUdywr0kbV\n 53PSMyV6bNYW1W4TsqU1qtMJIjlrIKIXLq/MoAnYJIi9A39/8dQXoZiowVeXucj8292QPuAFuEC\n k/OyGDUVL","X-Gm-Gg":"AeBDiet3trbWNRmXeUhol6j7xcU3EnJDMaU5Sai+DYKQlsClAE5ncAcjmgypDisYMWo\n IiWO/BIuH9KZcXAVj3fj8ZGIBRKZsKzFOArvTqZ2Y5NGFwxYu+Ec9DUactQk32/De2pwl5yJu8t\n Ix3ODB4ZMam315FWjo335QaBla/XuwqLpzN0eaBQFb8+zQniCxufSQBjB1ilBbbz5lr8yNWba1y\n pONG6/ddytjUoGEPwxibliQUpFkaV+TtmkQiQ0wrkL7PLOUpZwfDCDvabQSSKKHzMo61M1FJbk5\n IEZxwyTfgWqmtWhOEyvBEoUV0KuqiGLeW6118DoP2M+FXQmF4p4mGRk/K/B5GyJvKJDL5Nr5dC7\n EkoR1UCJ0QCG+/4c4DJlxGZAK8c/P0FA7/TH8eN+lDtpqo7eRa9MjjZmuQhB9tjHA6adNFTFHNl\n 2OYyaNv8NG5eL3OUA8gG+5Rb0wJ68Qgwol0sUWg47Z5S1rdMkKYF7s5wfv7qmKJG95Wv3YxJOj1\n OYkpEsnOjcGZnkG","X-Received":"by 2002:a05:600c:c173:b0:485:39d1:b4dd with SMTP id\n 5b1f17b1804b1-488d684b024mr258362905e9.10.1776208476648;\n Tue, 14 Apr 2026 16:14:36 -0700 (PDT)","From":"arthur.cohen@embecosm.com","To":"gcc-patches@gcc.gnu.org","Cc":"gcc-rust@gcc.gnu.org,\n\tOwen Avery <powerboat9.gamer@gmail.com>","Subject":"[COMMITTED 19/43] gccrs: Disambiguate identifier and path patterns","Date":"Wed, 15 Apr 2026 01:18:40 +0200","Message-ID":"<20260414231905.191063-19-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: Owen Avery <powerboat9.gamer@gmail.com>\n\ngcc/rust/ChangeLog:\n\n\t* Make-lang.in (GRS_OBJS): Add rust-identifier-path.o.\n\t* resolve/rust-early-name-resolver-2.0.cc: Include\n\t\"rust-identifier-path.h\".\n\t(Early::go): Use IdentifierPathPass.\n\t(Early::visit): Handle identifier patterns which should be path\n\tpatterns.\n\t* resolve/rust-early-name-resolver-2.0.h: Include\n\t\"rust-pattern.h\".\n\t(Early::visit): Add visiting function declaration for\n\tIdentifierPattern.\n\t(Early::ident_path_to_convert): New member variable.\n\t* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit):\n\tCall Mappings::add_function_node.\n\t* util/rust-hir-map.cc (Mappings::add_function_node): New\n\tmember function definition.\n\t(Mappings::is_function_node): Likewise.\n\t* util/rust-hir-map.h (Mappings::add_function_node): New\n\tmember function declaration.\n\t(Mappings::is_function_node): Likewise.\n\t(Mappings::function_nodes): New member variable.\n\t* resolve/rust-identifier-path.cc: New file.\n\t* resolve/rust-identifier-path.h: New file.\n\ngcc/testsuite/ChangeLog:\n\n\t* rust/execute/ident_pat_vs_path_1.rs: New test.\n\t* rust/execute/ident_pat_vs_path_2.rs: New test.\n\nSigned-off-by: Owen Avery <powerboat9.gamer@gmail.com>\n---\n gcc/rust/Make-lang.in                         |  1 +\n .../resolve/rust-early-name-resolver-2.0.cc   | 28 +++++++++\n .../resolve/rust-early-name-resolver-2.0.h    |  6 ++\n gcc/rust/resolve/rust-identifier-path.cc      | 61 +++++++++++++++++++\n gcc/rust/resolve/rust-identifier-path.h       | 50 +++++++++++++++\n .../rust-toplevel-name-resolver-2.0.cc        |  2 +\n gcc/rust/util/rust-hir-map.cc                 | 12 ++++\n gcc/rust/util/rust-hir-map.h                  |  5 ++\n .../rust/execute/ident_pat_vs_path_1.rs       | 27 ++++++++\n .../rust/execute/ident_pat_vs_path_2.rs       | 18 ++++++\n 10 files changed, 210 insertions(+)\n create mode 100644 gcc/rust/resolve/rust-identifier-path.cc\n create mode 100644 gcc/rust/resolve/rust-identifier-path.h\n create mode 100644 gcc/testsuite/rust/execute/ident_pat_vs_path_1.rs\n create mode 100644 gcc/testsuite/rust/execute/ident_pat_vs_path_2.rs","diff":"diff --git a/gcc/rust/Make-lang.in b/gcc/rust/Make-lang.in\nindex bd5646f7c37..4c394d39c0b 100644\n--- a/gcc/rust/Make-lang.in\n+++ b/gcc/rust/Make-lang.in\n@@ -146,6 +146,7 @@ GRS_OBJS = \\\n \trust/rust-finalize-imports-2.0.o \\\n \trust/rust-ice-finalizer.o \\\n     rust/rust-late-name-resolver-2.0.o \\\n+    rust/rust-identifier-path.o \\\n \trust/rust-immutable-name-resolution-context.o \\\n     rust/rust-name-resolver.o \\\n     rust/rust-resolve-builtins.o \\\ndiff --git a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc\nindex df29a55c8fb..91ad82c8966 100644\n--- a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc\n+++ b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc\n@@ -27,6 +27,7 @@\n #include \"rust-attributes.h\"\n #include \"rust-finalize-imports-2.0.h\"\n #include \"rust-attribute-values.h\"\n+#include \"rust-identifier-path.h\"\n \n namespace Rust {\n namespace Resolver2_0 {\n@@ -70,6 +71,9 @@ Early::go (AST::Crate &crate)\n   visit (crate);\n \n   textual_scope.pop ();\n+\n+  // handle IdentifierPattern vs PathInExpression disambiguation\n+  IdentifierPathPass::go (crate, ctx, std::move (ident_path_to_convert));\n }\n \n bool\n@@ -543,5 +547,29 @@ Early::visit (AST::UseTreeList &use_list)\n   DefaultResolver::visit (use_list);\n }\n \n+void\n+Early::visit (AST::IdentifierPattern &identifier)\n+{\n+  // check if this is *really* a path pattern\n+  if (!identifier.get_is_ref () && !identifier.get_is_mut ()\n+      && !identifier.has_subpattern ())\n+    {\n+      auto res = ctx.values.get (identifier.get_ident ());\n+      if (res)\n+\t{\n+\t  if (res->is_ambiguous ())\n+\t    rust_error_at (identifier.get_locus (), ErrorCode::E0659,\n+\t\t\t   \"%qs is ambiguous\",\n+\t\t\t   identifier.get_ident ().as_string ().c_str ());\n+\t  else\n+\t    {\n+\t      // HACK: bail out if the definition is a function\n+\t      if (!ctx.mappings.is_function_node (res->get_node_id ()))\n+\t\tident_path_to_convert.insert (identifier.get_node_id ());\n+\t    }\n+\t}\n+    }\n+}\n+\n } // namespace Resolver2_0\n } // namespace Rust\ndiff --git a/gcc/rust/resolve/rust-early-name-resolver-2.0.h b/gcc/rust/resolve/rust-early-name-resolver-2.0.h\nindex bd9ccf66dec..0fdf1436cbd 100644\n--- a/gcc/rust/resolve/rust-early-name-resolver-2.0.h\n+++ b/gcc/rust/resolve/rust-early-name-resolver-2.0.h\n@@ -26,6 +26,7 @@\n #include \"rust-default-resolver.h\"\n #include \"rust-rib.h\"\n #include \"rust-toplevel-name-resolver-2.0.h\"\n+#include \"rust-pattern.h\"\n \n namespace Rust {\n namespace Resolver2_0 {\n@@ -67,6 +68,8 @@ public:\n \n   void visit (AST::Attribute &) override;\n \n+  void visit (AST::IdentifierPattern &) override;\n+\n   struct ImportData\n   {\n     enum class Kind\n@@ -266,6 +269,9 @@ private:\n \t\t\t     const Early::ImportPair &mapping);\n \n   void finalize_rebind_import (const Early::ImportPair &mapping);\n+\n+  /* used to help conversion from IdentifierPattern to PathInExpression */\n+  std::set<NodeId> ident_path_to_convert;\n };\n \n } // namespace Resolver2_0\ndiff --git a/gcc/rust/resolve/rust-identifier-path.cc b/gcc/rust/resolve/rust-identifier-path.cc\nnew file mode 100644\nindex 00000000000..30223a7b3d6\n--- /dev/null\n+++ b/gcc/rust/resolve/rust-identifier-path.cc\n@@ -0,0 +1,61 @@\n+// Copyright (C) 2026 Free Software Foundation, Inc.\n+\n+// This file is part of GCC.\n+\n+// GCC is free software; you can redistribute it and/or modify it under\n+// the terms of the GNU General Public License as published by the Free\n+// Software Foundation; either version 3, or (at your option) any later\n+// version.\n+\n+// GCC is distributed in the hope that it will be useful, but WITHOUT ANY\n+// WARRANTY; without even the implied warranty of MERCHANTABILITY or\n+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License\n+// for more details.\n+\n+// You should have received a copy of the GNU General Public License\n+// along with GCC; see the file COPYING3.  If not see\n+// <http://www.gnu.org/licenses/>.\n+\n+#include \"rust-system.h\"\n+#include \"rust-identifier-path.h\"\n+#include \"rust-pattern.h\"\n+\n+namespace Rust {\n+namespace Resolver2_0 {\n+\n+IdentifierPathPass::IdentifierPathPass (NameResolutionContext &ctx,\n+\t\t\t\t\tstd::set<NodeId> ident_path_to_convert)\n+  : ctx (&ctx), ident_path_to_convert (std::move (ident_path_to_convert))\n+{}\n+\n+void\n+IdentifierPathPass::go (AST::Crate &crate, NameResolutionContext &ctx,\n+\t\t\tstd::set<NodeId> ident_path_to_convert)\n+{\n+  IdentifierPathPass pass (ctx, std::move (ident_path_to_convert));\n+  pass.visit (crate);\n+}\n+\n+void\n+IdentifierPathPass::reseat (std::unique_ptr<AST::Pattern> &ptr)\n+{\n+  AST::IdentifierPattern *ident_pat;\n+  if (ptr->get_pattern_kind () == AST::Pattern::Kind::Identifier)\n+    ident_pat = static_cast<AST::IdentifierPattern *> (ptr.get ());\n+  else\n+    return;\n+\n+  if (ident_path_to_convert.find (ident_pat->get_node_id ())\n+      != ident_path_to_convert.end ())\n+    {\n+      std::vector<AST::PathExprSegment> segments;\n+      segments.emplace_back (ident_pat->get_ident ().as_string (),\n+\t\t\t     ident_pat->get_locus ());\n+      ptr = std::make_unique<AST::PathInExpression> (\n+\tstd::move (segments), std::vector<AST::Attribute> (),\n+\tident_pat->get_locus ());\n+    }\n+}\n+\n+} // namespace Resolver2_0\n+} // namespace Rust\ndiff --git a/gcc/rust/resolve/rust-identifier-path.h b/gcc/rust/resolve/rust-identifier-path.h\nnew file mode 100644\nindex 00000000000..5363a5e87ef\n--- /dev/null\n+++ b/gcc/rust/resolve/rust-identifier-path.h\n@@ -0,0 +1,50 @@\n+// Copyright (C) 2026 Free Software Foundation, Inc.\n+\n+// This file is part of GCC.\n+\n+// GCC is free software; you can redistribute it and/or modify it under\n+// the terms of the GNU General Public License as published by the Free\n+// Software Foundation; either version 3, or (at your option) any later\n+// version.\n+\n+// GCC is distributed in the hope that it will be useful, but WITHOUT ANY\n+// WARRANTY; without even the implied warranty of MERCHANTABILITY or\n+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License\n+// for more details.\n+\n+// You should have received a copy of the GNU General Public License\n+// along with GCC; see the file COPYING3.  If not see\n+// <http://www.gnu.org/licenses/>.\n+\n+#ifndef RUST_RESOLVE_IDENTIFIER_PATH_H\n+#define RUST_RESOLVE_IDENTIFIER_PATH_H\n+\n+#include \"rust-ast-pointer-visitor.h\"\n+#include \"rust-name-resolution-context.h\"\n+\n+namespace Rust {\n+namespace Resolver2_0 {\n+\n+// changes IdentifierPattern instances to PathInExpression instances\n+class IdentifierPathPass : public AST::PointerVisitor\n+{\n+public:\n+  IdentifierPathPass (NameResolutionContext &ctx,\n+\t\t      std::set<NodeId> ident_path_to_convert);\n+\n+  static void go (AST::Crate &crate, NameResolutionContext &ctx,\n+\t\t  std::set<NodeId> ident_path_to_convert);\n+\n+  using AST::PointerVisitor::reseat;\n+\n+  void reseat (std::unique_ptr<AST::Pattern> &ptr) override;\n+\n+private:\n+  NameResolutionContext *ctx;\n+  std::set<NodeId> ident_path_to_convert;\n+};\n+\n+} // namespace Resolver2_0\n+} // namespace Rust\n+\n+#endif // ! RUST_RESOLVE_IDENTIFIER_PATH_H\ndiff --git a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc\nindex 2002df54596..630b5ab8b95 100644\n--- a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc\n+++ b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc\n@@ -241,6 +241,8 @@ TopLevel::visit (AST::Function &function)\n   insert_or_error_out (function.get_function_name (), function,\n \t\t       Namespace::Values);\n \n+  Analysis::Mappings::get ().add_function_node (function.get_node_id ());\n+\n   DefaultResolver::visit (function);\n }\n \ndiff --git a/gcc/rust/util/rust-hir-map.cc b/gcc/rust/util/rust-hir-map.cc\nindex a58fef00d46..89b95647861 100644\n--- a/gcc/rust/util/rust-hir-map.cc\n+++ b/gcc/rust/util/rust-hir-map.cc\n@@ -1382,5 +1382,17 @@ Mappings::is_derived_node (NodeId node_id)\n   return derived_nodes.find (node_id) != derived_nodes.end ();\n }\n \n+void\n+Mappings::add_function_node (NodeId node_id)\n+{\n+  function_nodes.insert (node_id);\n+}\n+\n+bool\n+Mappings::is_function_node (NodeId node_id)\n+{\n+  return function_nodes.find (node_id) != function_nodes.end ();\n+}\n+\n } // namespace Analysis\n } // namespace Rust\ndiff --git a/gcc/rust/util/rust-hir-map.h b/gcc/rust/util/rust-hir-map.h\nindex c04e2efb7a4..7012dd5c2e0 100644\n--- a/gcc/rust/util/rust-hir-map.h\n+++ b/gcc/rust/util/rust-hir-map.h\n@@ -353,6 +353,9 @@ public:\n   void add_derived_node (NodeId node_id);\n   bool is_derived_node (NodeId node_id);\n \n+  void add_function_node (NodeId node_id);\n+  bool is_function_node (NodeId node_id);\n+\n private:\n   Mappings ();\n \n@@ -450,6 +453,8 @@ private:\n   std::unordered_map<NodeId, std::vector<NodeId>> captures;\n \n   std::set<NodeId> derived_nodes;\n+\n+  std::set<NodeId> function_nodes;\n };\n \n } // namespace Analysis\ndiff --git a/gcc/testsuite/rust/execute/ident_pat_vs_path_1.rs b/gcc/testsuite/rust/execute/ident_pat_vs_path_1.rs\nnew file mode 100644\nindex 00000000000..479e8700bac\n--- /dev/null\n+++ b/gcc/testsuite/rust/execute/ident_pat_vs_path_1.rs\n@@ -0,0 +1,27 @@\n+// { dg-additional-options \"-w\" }\n+#![feature(no_core)]\n+#![no_core]\n+\n+enum E {\n+    A,\n+    B,\n+    C\n+}\n+\n+fn main() -> i32 {\n+    use E::C;\n+\n+    let v1 = match E::A {\n+        C => 1,\n+        E::A => 0,\n+        E::B => 1\n+    };\n+\n+    let v2 = match E::A {\n+        B => 0,\n+        E::A => 1,\n+        C => 1\n+    };\n+\n+    v1 + v2\n+}\ndiff --git a/gcc/testsuite/rust/execute/ident_pat_vs_path_2.rs b/gcc/testsuite/rust/execute/ident_pat_vs_path_2.rs\nnew file mode 100644\nindex 00000000000..bb6841f0ae4\n--- /dev/null\n+++ b/gcc/testsuite/rust/execute/ident_pat_vs_path_2.rs\n@@ -0,0 +1,18 @@\n+// { dg-additional-options \"-w\" }\n+#![feature(no_core)]\n+#![no_core]\n+\n+enum E {\n+    A,\n+    B,\n+    C\n+}\n+\n+fn main() -> i32 {\n+    use E::*;\n+\n+    match A {\n+        C => 1,\n+        _ => 0\n+    }\n+}\n","prefixes":["COMMITTED","19/43"]}