From: Pierre-Emmanuel Patry <[email protected]>

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]>
---
This change was merged into the gccrs repository and is posted here for
upstream visibility and potential drive-by review, as requested by GCC
release managers.
Each commit email contains a link to its details on github from where you can
find the Pull-Request and associated discussions.


Commit on github: 
https://github.com/Rust-GCC/gccrs/commit/cf919cd1ba958b6361af3cea76c23c2b012244a7

The commit has NOT been mentioned in any issue.

The commit has been mentioned in the following pull-request(s):
 - https://github.com/Rust-GCC/gccrs/pull/4758

 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 091cdf5ac..97f575d30 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 bbba4a5c3..50778bcaf 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; }
-- 
2.55.0

Reply via email to