]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Move cli inner attribute injection to injection
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Wed, 11 Mar 2026 12:35:08 +0000 (13:35 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Fri, 20 Mar 2026 17:10:58 +0000 (18:10 +0100)
Inner attribute injection was not within the injection function where
the other things get injected within a crate.

gcc/rust/ChangeLog:

* rust-session-manager.cc (Session::compile_crate): Use additional
cli attributes for the injection function. Move additional attribute
injection from here...
(Session::injection): ... to here.
* rust-session-manager.h: Update injection fonction prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/rust-session-manager.cc
gcc/rust/rust-session-manager.h

index 0c88e894ef0978ed47dcdb59eb3c2954f4adae76..12e076d1df02d6a99591cdf4fbf986ac7c640a73 100644 (file)
@@ -666,9 +666,6 @@ Session::compile_crate (const char *filename)
   AST::Crate &parsed_crate
     = mappings.insert_ast_crate (std::move (ast_crate), current_crate);
 
-  for (auto attribute : cli_attributes)
-    parsed_crate.inject_inner_attribute (attribute);
-
   /* basic pipeline:
    *  - lex
    *  - parse
@@ -699,7 +696,7 @@ Session::compile_crate (const char *filename)
     }
 
   // injection pipeline stage
-  injection (parsed_crate);
+  injection (parsed_crate, cli_attributes);
   rust_debug ("\033[0;31mSUCCESSFULLY FINISHED INJECTION \033[0m");
   if (options.dump_option_enabled (CompileOptions::INJECTION_DUMP))
     {
@@ -908,7 +905,7 @@ contains_name (const AST::AttrVec &attrs, std::string name)
 }
 
 void
-Session::injection (AST::Crate &crate)
+Session::injection (AST::Crate &crate, AST::AttrVec cli_attributes)
 {
   rust_debug ("started injection");
 
@@ -963,6 +960,9 @@ Session::injection (AST::Crate &crate)
    * macros, cfg, and test should be prioritised since they seem to be used
    * the most. */
 
+  for (auto attribute : cli_attributes)
+    crate.inject_inner_attribute (attribute);
+
   // crate injection
   std::vector<std::string> names;
   if (contains_name (crate.inner_attrs, "no_core"))
index 4e30ac6580e202c39daaf5de7dee55cf8e0a1fd0..3d109112c47684a79b283b439e30d8c0ce571b21 100644 (file)
@@ -459,7 +459,7 @@ private:
   /* Injection pipeline stage. TODO maybe move to another object? Maybe have
    * some lint checks (in future, obviously), register builtin macros, crate
    * injection. */
-  void injection (AST::Crate &crate);
+  void injection (AST::Crate &crate, AST::AttrVec cli_attributes);
 
   /* Expansion pipeline stage. TODO maybe move to another object? Expands all
    * macros, maybe build test harness in future, AST validation, maybe create