From f88af6176e24e62670f33f3d119db02850c11af2 Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Mon, 24 Feb 2025 13:09:17 +0100 Subject: expansion: Correctly expand $crate metavar gcc/rust/ChangeLog: * expand/rust-macro-expand.cc: Use new SubstituteCtx API. * expand/rust-macro-expand.h: Likewise. * expand/rust-macro-substitute-ctx.cc: Implement proper expansion of $crate. * expand/rust-macro-substitute-ctx.h: Adapt APIs to take macro definition when substituting. * util/rust-hir-map.cc (Mappings::insert_macro_def): Store crate information when inserting macro definition in mappings. (Mappings::lookup_macro_def_crate): New. * util/rust-hir-map.h: Adapt mappings to store crate in which macros were defined. gcc/testsuite/ChangeLog: * rust/execute/crate-metavar1.rs: New test. * rust/compile/crate-metavar1.rs: New test. --- gcc/rust/expand/rust-macro-expand.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gcc/rust/expand/rust-macro-expand.h') diff --git a/gcc/rust/expand/rust-macro-expand.h b/gcc/rust/expand/rust-macro-expand.h index c186f3d..3948e44 100644 --- a/gcc/rust/expand/rust-macro-expand.h +++ b/gcc/rust/expand/rust-macro-expand.h @@ -331,7 +331,8 @@ struct MacroExpander AST::DelimTokenTree &invoc_token_tree); AST::Fragment transcribe_rule ( - AST::MacroRule &match_rule, AST::DelimTokenTree &invoc_token_tree, + AST::MacroRulesDefinition &definition, AST::MacroRule &match_rule, + AST::DelimTokenTree &invoc_token_tree, std::map &matched_fragments, AST::InvocKind invoc_kind, ContextType ctx); -- cgit v1.1