public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-7817] gccrs: import: Load procedural macros into external crate
@ 2024-01-16 18:01 Arthur Cohen
  0 siblings, 0 replies; only message in thread
From: Arthur Cohen @ 2024-01-16 18:01 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:37451ad09f7edc081700909208f90b9eea1eb592

commit r14-7817-g37451ad09f7edc081700909208f90b9eea1eb592
Author: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Date:   Thu Jun 15 16:37:07 2023 +0200

    gccrs: import: Load procedural macros into external crate
    
    Load the procedural macro array into the external crate structure.
    
    gcc/rust/ChangeLog:
    
            * metadata/rust-imports.cc (Import::try_package_in_directory):
            Add call to load macros before loading metadatas.
            * expand/rust-proc-macro.cc: Return empty vector instead of
            panicking on error.
    
    Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>

Diff:
---
 gcc/rust/expand/rust-proc-macro.cc | 2 +-
 gcc/rust/metadata/rust-imports.cc  | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/gcc/rust/expand/rust-proc-macro.cc b/gcc/rust/expand/rust-proc-macro.cc
index 6ba87b6dd1b..acd7f711a28 100644
--- a/gcc/rust/expand/rust-proc-macro.cc
+++ b/gcc/rust/expand/rust-proc-macro.cc
@@ -115,7 +115,7 @@ load_macros (std::string path)
   const ProcMacro::ProcmacroArray *array = load_macros_array (path);
   // Did not load the proc macro
   if (array == nullptr)
-    rust_unreachable ();
+    return {};
 
   rust_debug ("Found %lu procedural macros", array->length);
 
diff --git a/gcc/rust/metadata/rust-imports.cc b/gcc/rust/metadata/rust-imports.cc
index 669cecb29c3..78b27eaa884 100644
--- a/gcc/rust/metadata/rust-imports.cc
+++ b/gcc/rust/metadata/rust-imports.cc
@@ -164,11 +164,13 @@ Import::try_package_in_directory (const std::string &filename,
 	return std::make_pair (nullptr, std::vector<ProcMacro::Procmacro>{});
     }
 
+  auto macros = load_macros (found_filename);
+
   // The export data may not be in this file.
   std::unique_ptr<Stream> s
     = Import::find_export_data (found_filename, fd, location);
   if (s != nullptr)
-    return std::make_pair (std::move (s), std::vector<ProcMacro::Procmacro>{});
+    return std::make_pair (std::move (s), macros);
 
   close (fd);
 
@@ -176,7 +178,7 @@ Import::try_package_in_directory (const std::string &filename,
 		 "%s exists but does not contain any Rust export data",
 		 found_filename.c_str ());
 
-  return std::make_pair (NULL, std::vector<ProcMacro::Procmacro>{});
+  return std::make_pair (NULL, macros);
 }
 
 // Given import "*PFILENAME", where *PFILENAME does not exist, try

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-01-16 18:01 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:01 [gcc r14-7817] gccrs: import: Load procedural macros into external crate 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).