From: Pierre-Emmanuel Patry <[email protected]>
We need macros from both the std lib as well as the core library. In
order to do so we need to add the macro_use attribute on their
declaration.
gcc/rust/ChangeLog:
* ast/rust-ast.cc (Crate::inject_extern_crate): Inject the macro_use
attribute when injecting the crate.
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/2edd40a63888ca2475da3ff522f34d6ccf140423
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/5105
gcc/rust/ast/rust-ast.cc | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/gcc/rust/ast/rust-ast.cc b/gcc/rust/ast/rust-ast.cc
index 18b4cf4f0..0995ca866 100644
--- a/gcc/rust/ast/rust-ast.cc
+++ b/gcc/rust/ast/rust-ast.cc
@@ -238,9 +238,11 @@ Crate::as_string () const
NodeId
Crate::inject_extern_crate (std::string name)
{
+ auto macro_use_attribute
+ = Attribute (SimplePath (Identifier ("macro_use")), nullptr);
auto extern_crate = std::make_unique<AST::ExternCrate> (
AST::ExternCrate (name, AST::Visibility::create_public (UNKNOWN_LOCATION),
- {}, UNKNOWN_LOCATION));
+ {std::move (macro_use_attribute)}, UNKNOWN_LOCATION));
auto node_id = extern_crate->get_node_id ();
// We need to insert the new crate at the top of the file as its
// definition must be resolved before any module.
--
2.56.1