From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by sourceware.org (Postfix) with ESMTPS id 6CD24386101B for ; Thu, 1 Aug 2024 14:59:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6CD24386101B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6CD24386101B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::533 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722524427; cv=none; b=DK9lDAbQ5FwzVOCnbuWbekstWP7vbcJziNXG+FI7hKDjYb8t3xpY3rC+sEVTHBPBhZNTX+Fu1ErxmzBGZ3GML72i9Nf8gFQwS43HcStiuTmFEq/K82ZS0za+E5fK+TF7aHYnvdn5emfJdQ6msTXgs38qDuoCC1eTUZ1EPI4bT1I= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722524427; c=relaxed/simple; bh=NF2tQGsz51Qb6fXlvs2SeDRPXHOOt/kUBZJWupeQbIM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=hpnyagQtcjwmyqCeLUQ0U4PeF45fwmlTlvhnTN/3ujVtnOX5oxiP9J/n3xGM7EaBzoFBE9Wmp6+h/9Y9oNQUEsWUNUSbLo6ZWsyQ0FvOv354lEXCTxNQWek7klkIMvzigFzrMYRp3J8LdxDX+lGGH2PDHhNuOmEyfnVDYO9hwbc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-59f9f59b827so10437579a12.1 for ; Thu, 01 Aug 2024 07:59:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1722524380; x=1723129180; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mjaz8ZjPgZRnxS7jRIJdSVCuNeQP6CeV2swk0El0sqM=; b=PhXTMB/i0VtsM5ketaeyuOxd+moDFMwqAJyUOYJX+8doB/i+Kwq75WAOl+tRoGYL/r FXsGTzL9rJFXzIzEhkBT9bMBHjvfhviMfnZHuvAPN37o0hilgsMuQ8ZFkUj8LsRjuWxF VoJYuggUjyK3KtA9icy1MH3wfP/XEWLdCfgUV8K9vRMiyE0sWR4tx1UuK+TRVX48sI5U vP9fu/zGSjohdDgOLsUl2wFbXSChkSfrqvPepPxhuk4TouH47PeynfnxC2wKL2Nf+avw VMqZc4V0cUtjqFIrpjPXj/k8yVjBxi4Wf/KPUdPa1M406NCe4+gZJDsf+mAP2azX4INx r1zA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722524380; x=1723129180; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mjaz8ZjPgZRnxS7jRIJdSVCuNeQP6CeV2swk0El0sqM=; b=WJoHN64jM0RVw68FeJeF2jL1B2cKnUExmOOlr+BtoRp4n2rPYDgpNB7iwxTlJgcacp ZKcRL8wjnm+7BDKgcy/E0s+ogJxPcUCHq6Fb9PLlrRtx1XfHqizdAdQyyMITyXb6wVsh Ni9KbUtqhRcln4zwFtVf2vBtyt0NFXge8OIkyes4pXPlfgyYHa4ICHr/bAsxvjfvNaHB ZsvFvZLmsAKtRL8Ei+I0i6UYvKbStfiQop+xOoDIEU7XXhhK7lJjGLBoxSytlQTJTojI 7+btzAaZ6sJBqH4QLRdDT+eaE5ZfOUTjiTO7HWR4IrC7+CvSPKht50y5yQh4dJraB/MM bFqA== X-Gm-Message-State: AOJu0Yyt9tdYX280XGri3sCaTB4O7aQpQqndIdRywV/t+tjf8/qpFc78 Ezyrkh4NwcHLVJmwEHNVvlR6SRHjL+chYR8vOE8HXkQs6FHfMykbJUScDk2a6sgf4rC9f3210ui NXKtI X-Google-Smtp-Source: AGHT+IHSeA+jPp6isxjhAGvWHg6RnYpAXVVWhnS3cOIeaiZcxcv3W3jYJdbkHFScTlbtE0Ad/gROVg== X-Received: by 2002:aa7:c996:0:b0:5af:30d9:e2b6 with SMTP id 4fb4d7f45d1cf-5b7f5413f64mr399475a12.23.1722524379843; Thu, 01 Aug 2024 07:59:39 -0700 (PDT) Received: from platypus.lan ([2a04:cec2:9:dc84:3622:6733:ff49:ee91]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5ac63590592sm10252456a12.25.2024.08.01.07.59.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 07:59:39 -0700 (PDT) From: Arthur Cohen To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Pierre-Emmanuel Patry Subject: [PATCH 075/125] gccrs: Shape up name resolver for normal direct calls Date: Thu, 1 Aug 2024 16:57:11 +0200 Message-ID: <20240801145809.366388-77-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801145809.366388-2-arthur.cohen@embecosm.com> References: <20240801145809.366388-2-arthur.cohen@embecosm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: From: Pierre-Emmanuel Patry Direct function calls did not work anymore due to the transition to the new resolver. gcc/rust/ChangeLog: * checks/lints/rust-lint-marklive.cc (MarkLive::find_ref_node_id): Add code path for the resolver 2.0 * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Remove failing label context resolve call. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/checks/lints/rust-lint-marklive.cc | 23 +++++++++++++++---- .../resolve/rust-late-name-resolver-2.0.cc | 3 ++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/gcc/rust/checks/lints/rust-lint-marklive.cc b/gcc/rust/checks/lints/rust-lint-marklive.cc index 8787a9d8550..1a0a0a2b904 100644 --- a/gcc/rust/checks/lints/rust-lint-marklive.cc +++ b/gcc/rust/checks/lints/rust-lint-marklive.cc @@ -20,8 +20,10 @@ // from live codes are live, and everything else is dead. #include "rust-lint-marklive.h" +#include "options.h" #include "rust-hir-full.h" #include "rust-name-resolver.h" +#include "rust-immutable-name-resolution-context.h" namespace Rust { namespace Analysis { @@ -270,12 +272,25 @@ MarkLive::mark_hir_id (HirId id) void MarkLive::find_ref_node_id (NodeId ast_node_id, NodeId &ref_node_id) { - if (!resolver->lookup_resolved_name (ast_node_id, &ref_node_id)) + if (flag_name_resolution_2_0) { - if (!resolver->lookup_resolved_type (ast_node_id, &ref_node_id)) + auto nr_ctx + = Resolver2_0::ImmutableNameResolutionContext::get ().resolver (); + + nr_ctx.lookup (ast_node_id).map ([&ref_node_id] (NodeId resolved) { + ref_node_id = resolved; + }); + } + else + { + if (!resolver->lookup_resolved_name (ast_node_id, &ref_node_id)) { - bool ok = resolver->lookup_resolved_misc (ast_node_id, &ref_node_id); - rust_assert (ok); + if (!resolver->lookup_resolved_type (ast_node_id, &ref_node_id)) + { + bool ok + = resolver->lookup_resolved_misc (ast_node_id, &ref_node_id); + rust_assert (ok); + } } } } diff --git a/gcc/rust/resolve/rust-late-name-resolver-2.0.cc b/gcc/rust/resolve/rust-late-name-resolver-2.0.cc index ee06c4efc2e..68eb88a1e4c 100644 --- a/gcc/rust/resolve/rust-late-name-resolver-2.0.cc +++ b/gcc/rust/resolve/rust-late-name-resolver-2.0.cc @@ -196,8 +196,9 @@ Late::visit (AST::PathInExpression &expr) // in a function item` error here? // do we emit it in `get`? - auto label = ctx.labels.resolve_path (expr.get_segments ()); auto value = ctx.values.resolve_path (expr.get_segments ()); + + ctx.map_usage (Usage (expr.get_node_id ()), Definition (*value)); } void -- 2.45.2