public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-7991] gccrs: Clarify package import procedure
@ 2024-01-16 18:11 Arthur Cohen
0 siblings, 0 replies; only message in thread
From: Arthur Cohen @ 2024-01-16 18:11 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:3713338d986b750a56ca60c9683727d972c47f90
commit r14-7991-g3713338d986b750a56ca60c9683727d972c47f90
Author: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Date: Mon Sep 4 12:19:13 2023 +0200
gccrs: Clarify package import procedure
This part of the code is a bit tricky as it calls multiple functions
with almost the same name and slightly different behaviors. It was even
more with a meaningless variable name.
gcc/rust/ChangeLog:
* rust-session-manager.cc (Session::load_extern_crate): Change
variable name, add temporaries and comments.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diff:
---
gcc/rust/rust-session-manager.cc | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc
index 2a8ef972131..63f839e7c9d 100644
--- a/gcc/rust/rust-session-manager.cc
+++ b/gcc/rust/rust-session-manager.cc
@@ -1008,27 +1008,35 @@ Session::load_extern_crate (const std::string &crate_name, location_t locus)
auto cli_extern_crate = extern_crates.find (crate_name);
std::pair<std::unique_ptr<Import::Stream>, std::vector<ProcMacro::Procmacro>>
- s;
+ package_result;
if (cli_extern_crate != extern_crates.end ())
{
auto path = cli_extern_crate->second;
- s = Import::try_package_in_directory (path, locus);
+ package_result = Import::try_package_in_directory (path, locus);
}
else
{
- s = Import::open_package (import_name, locus, relative_import_path);
+ package_result
+ = Import::open_package (import_name, locus, relative_import_path);
}
- if (s.first == NULL && s.second.empty ())
+
+ auto stream = std::move (package_result.first);
+ auto proc_macros = std::move (package_result.second);
+
+ if (stream == NULL // No stream and
+ && proc_macros.empty ()) // no proc macros
{
rust_error_at (locus, "failed to locate crate %<%s%>",
import_name.c_str ());
return UNKNOWN_NODEID;
}
- auto extern_crate = s.first == nullptr
- ? Imports::ExternCrate (crate_name, s.second)
- : Imports::ExternCrate (*s.first);
- if (s.first != nullptr)
+ auto extern_crate
+ = stream == nullptr
+ ? Imports::ExternCrate (crate_name,
+ proc_macros) // Import proc macros
+ : Imports::ExternCrate (*stream); // Import from stream
+ if (stream != nullptr)
{
bool ok = extern_crate.load (locus);
if (!ok)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-01-16 18:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-16 18:11 [gcc r14-7991] gccrs: Clarify package import procedure Arthur Cohen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).