]> git.ipfire.org Git - thirdparty/gcc.git/commit
gccrs: expansion: Correctly expand $crate metavar
authorArthur Cohen <arthur.cohen@embecosm.com>
Mon, 24 Feb 2025 12:09:17 +0000 (13:09 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Mon, 24 Mar 2025 12:07:13 +0000 (13:07 +0100)
commit1181104e1ffd8c8e963b59d206d9168d470e68f6
tree1ce8ff93e9fd411972f41f880941ad58e71ed4cf
parent0d8b4920da205ecb091155c54b84bd58a0f6710d
gccrs: 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.cc
gcc/rust/expand/rust-macro-expand.h
gcc/rust/expand/rust-macro-substitute-ctx.cc
gcc/rust/expand/rust-macro-substitute-ctx.h
gcc/rust/util/rust-hir-map.cc
gcc/rust/util/rust-hir-map.h
gcc/testsuite/rust/compile/crate-metavar1.rs [new file with mode: 0644]
gcc/testsuite/rust/execute/crate-metavar1.rs [new file with mode: 0644]