From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by sourceware.org (Postfix) with ESMTPS id C3CF9385F027 for ; Thu, 1 Aug 2024 14:59:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C3CF9385F027 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 C3CF9385F027 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::529 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722524398; cv=none; b=xVEsig+qv66H93qgzFtemOoGtdZ2V/qjSR3DRPdjUF5tjnf92Wbu9+A+5qnKCLWc80odgBdY5fIuk2YP5FTO/FTPpZ+FZcd+jvEk/vpGS2E51lol3oPqPvy//Oytt3oMu7zqZ3a1RPAtBgndscadZONumSx/HZkVYimSwrY6hjg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722524398; c=relaxed/simple; bh=ObDIjYvFKT1qLF+BEBK/DEg0jr+SoyfpJ5Wrn1OwHuY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=qfem1mL7Yy0cS7/svj1EDdtZH/Og6Eu7AVwWY3D+9MITbGA1cXPWk89gN+Fe7OXZCS8LzxK1qkjFsWE8WUO6CRcRzn2/7eOU4t08P7/u5kws4CyyAjj/dpslWsBHLnM+1BrRoCpIL6RddOBs9BZaeCsAZeJT15CvcVxdd4XptnA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-5a3b866ebc9so9942417a12.3 for ; Thu, 01 Aug 2024 07:59:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1722524368; x=1723129168; 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=kg37N9Fl1nIR2Aw7Y6bIRFbGuU+skJb6UQ+46gEqR0I=; b=AXOFSrFBnkuqr2BeLGG4C6rjuscni02ZGQR/ZRfX2ZZncWLewu0NEXfNgVm6hmC73d PJPXCiS1omun5gFFprdftObkWQCJo7N0DCaykIARkb0lSUqopAddLR6QhF8Aq3ezTa9h D978lneQVi/UOV+iKgjn64/Rmek2qzBXruaJSasEDwUYLbtpoBqs/MfEg82MzmwOqFt3 GIeKfl+2GBmchP8I/F8oyzUvASy+UmTEvHGfzeGJXypvKh98GAPxt5d8uo65cw2Ceyyn X158fxFq36fZxr2bE9bhnWNW0dT/HzJOGnJOdw8ovFEjG7BYvB0gO4074T4TVYhAxZ0Q e5uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722524368; x=1723129168; 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=kg37N9Fl1nIR2Aw7Y6bIRFbGuU+skJb6UQ+46gEqR0I=; b=ufjg9G1lP0G25+IvlhlK9DN9I+rXGi1XIzJgUq3Uai71XWnrqrUdYqlTW7XJ71hrEr ihBxhjX6UNfVKTmlXqYudKPCcLtzqJJj2JePJyAOmBz9sb+VzgU70nOAofeXO34f70cR 9FsOcQynZvDEz24pDQRLl5Q3K912fD38c/aXUoqkrbEJQfEu3EhYsrHIxRjBFvJl0BfI VQ93kuOWcaD6sDE8ZFHPO5TfykuK4DxnPLO97W8QpwjaCiw16fVRGlMkWTFD0dayySog FE02CUq9UyP1tTJgpI0fFHaaGFqvSXn1GNKxWHIYreK67spWg/ktDsbw09nc0F95C0vZ 3dIQ== X-Gm-Message-State: AOJu0YyFpLe1MwmDTQ6E8wQ/bXmQ5tg2jTXFoxQBQr93oT+ujDM3Vr2O c5UABjHd7ZnGU8FaGYYhAIII2SyUmCknfOUegRBpdjR1ST+WUedrVoWb5nvmdid+fji+QUp8xsx x5nmi X-Google-Smtp-Source: AGHT+IGIwblwFtjj1SKAdJu1kH/f6ReV3tiqr4wufEanMzbjTy8jsste2Xxiol+okXx8lFcBQzTH4Q== X-Received: by 2002:a05:6402:1ade:b0:5a2:fc48:db2d with SMTP id 4fb4d7f45d1cf-5b7f59e0696mr333972a12.31.1722524368277; Thu, 01 Aug 2024 07:59:28 -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.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 07:59:28 -0700 (PDT) From: Arthur Cohen To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Arthur Cohen Subject: [PATCH 060/125] gccrs: sesh: Add late name resolution 2.0 Date: Thu, 1 Aug 2024 16:56:56 +0200 Message-ID: <20240801145809.366388-62-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=-13.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_NUMSUBJECT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: gcc/rust/ChangeLog: * rust-session-manager.cc (Session::compile_crate): Create name resolution context for Session::expansion and subsequent name resolution passes. (Session::expansion): Take name resolution context as a parameter instead. * rust-session-manager.h (Session::expansion): Fix declaration. --- gcc/rust/rust-session-manager.cc | 14 +++++++++----- gcc/rust/rust-session-manager.h | 3 ++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc index ea99d019f64..40adeb20de4 100644 --- a/gcc/rust/rust-session-manager.cc +++ b/gcc/rust/rust-session-manager.cc @@ -42,6 +42,7 @@ #include "rust-early-name-resolver.h" #include "rust-name-resolution-context.h" #include "rust-early-name-resolver-2.0.h" +#include "rust-late-name-resolver-2.0.h" #include "rust-cfg-strip.h" #include "rust-expand-visitor.h" #include "rust-unicode.h" @@ -591,8 +592,10 @@ Session::compile_crate (const char *filename) if (last_step == CompileOptions::CompileStep::Expansion) return; + auto name_resolution_ctx = Resolver2_0::NameResolutionContext (); // expansion pipeline stage - expansion (parsed_crate); + + expansion (parsed_crate, name_resolution_ctx); rust_debug ("\033[0;31mSUCCESSFULLY FINISHED EXPANSION \033[0m"); if (options.dump_option_enabled (CompileOptions::EXPANSION_DUMP)) { @@ -617,7 +620,10 @@ Session::compile_crate (const char *filename) return; // resolution pipeline stage - Resolver::NameResolution::Resolve (parsed_crate); + if (flag_name_resolution_2_0) + Resolver2_0::Late (name_resolution_ctx).go (parsed_crate); + else + Resolver::NameResolution::Resolve (parsed_crate); if (options.dump_option_enabled (CompileOptions::RESOLUTION_DUMP)) { @@ -881,7 +887,7 @@ Session::injection (AST::Crate &crate) } void -Session::expansion (AST::Crate &crate) +Session::expansion (AST::Crate &crate, Resolver2_0::NameResolutionContext &ctx) { rust_debug ("started expansion"); @@ -908,8 +914,6 @@ Session::expansion (AST::Crate &crate) if (saw_errors ()) break; - auto ctx = Resolver2_0::NameResolutionContext (); - if (flag_name_resolution_2_0) { Resolver2_0::Early early (ctx); diff --git a/gcc/rust/rust-session-manager.h b/gcc/rust/rust-session-manager.h index 41aad607905..9a5691f45ee 100644 --- a/gcc/rust/rust-session-manager.h +++ b/gcc/rust/rust-session-manager.h @@ -24,6 +24,7 @@ #include "rust-backend.h" #include "rust-hir-map.h" #include "safe-ctype.h" +#include "rust-name-resolution-context.h" #include "config.h" #include "rust-system.h" @@ -413,7 +414,7 @@ private: /* Expansion pipeline stage. TODO maybe move to another object? Expands all * macros, maybe build test harness in future, AST validation, maybe create * macro crate (if not rustdoc).*/ - void expansion (AST::Crate &crate); + void expansion (AST::Crate &crate, Resolver2_0::NameResolutionContext &ctx); // handle cfg_option bool handle_cfg_option (std::string &data); -- 2.45.2