https://gcc.gnu.org/g:bea8ce86ae1d1aea0bf0387a032d11bfffcbe986

commit r17-5693-gbea8ce86ae1d1aea0bf0387a032d11bfffcbe986
Author: Pierre-Emmanuel Patry <[email protected]>
Date:   Tue Aug 4 10:08:47 2026 +0200

    gccrs: Change crate injection API
    
    Return the injected crate's node id.
    
    gcc/rust/ChangeLog:
    
            * ast/rust-ast.cc (Crate::inject_extern_crate): Return the injected
            crate's node id.
            * ast/rust-ast.h: Update the function's prototype.
    
    Signed-off-by: Pierre-Emmanuel Patry <[email protected]>

Diff:
---
 gcc/rust/ast/rust-ast.cc | 9 ++++++---
 gcc/rust/ast/rust-ast.h  | 2 +-
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/gcc/rust/ast/rust-ast.cc b/gcc/rust/ast/rust-ast.cc
index 091cdf5ac459..97f575d3075a 100644
--- a/gcc/rust/ast/rust-ast.cc
+++ b/gcc/rust/ast/rust-ast.cc
@@ -235,12 +235,15 @@ Crate::as_string () const
   return str + "\n";
 }
 
-void
+NodeId
 Crate::inject_extern_crate (std::string name)
 {
-  items.push_back (std::make_unique<AST::ExternCrate> (
+  auto extern_crate = std::make_unique<AST::ExternCrate> (
     AST::ExternCrate (name, AST::Visibility::create_public (UNKNOWN_LOCATION),
-                     {}, UNKNOWN_LOCATION)));
+                     {}, UNKNOWN_LOCATION));
+  auto node_id = extern_crate->get_node_id ();
+  items.push_back (std::move (extern_crate));
+  return node_id;
 }
 
 void
diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h
index bbba4a5c33c5..50778bcaffe8 100644
--- a/gcc/rust/ast/rust-ast.h
+++ b/gcc/rust/ast/rust-ast.h
@@ -2092,7 +2092,7 @@ public:
     // TODO: is this the best way to do this?
   }
 
-  void inject_extern_crate (std::string name);
+  NodeId inject_extern_crate (std::string name);
   void inject_inner_attribute (Attribute attribute);
 
   NodeId get_node_id () const { return node_id; }

Reply via email to