From: Pierre-Emmanuel Patry <[email protected]>
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 <[email protected]>
---
gcc/rust/rust-session-manager.cc | 10 +++++-----
gcc/rust/rust-session-manager.h | 2 +-
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc
index 0c88e894ef0..12e076d1df0 100644
--- a/gcc/rust/rust-session-manager.cc
+++ b/gcc/rust/rust-session-manager.cc
@@ -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"))
diff --git a/gcc/rust/rust-session-manager.h b/gcc/rust/rust-session-manager.h
index 4e30ac6580e..3d109112c47 100644
--- a/gcc/rust/rust-session-manager.h
+++ b/gcc/rust/rust-session-manager.h
@@ -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
--
2.50.1