aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/rust/execute
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2025-02-24 13:09:17 +0100
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-24 13:07:13 +0100
commit1181104e1ffd8c8e963b59d206d9168d470e68f6 (patch)
tree1ce8ff93e9fd411972f41f880941ad58e71ed4cf /gcc/testsuite/rust/execute
parent0d8b4920da205ecb091155c54b84bd58a0f6710d (diff)
downloadgcc-1181104e1ffd8c8e963b59d206d9168d470e68f6.zip
gcc-1181104e1ffd8c8e963b59d206d9168d470e68f6.tar.gz
gcc-1181104e1ffd8c8e963b59d206d9168d470e68f6.tar.bz2
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.
Diffstat (limited to 'gcc/testsuite/rust/execute')
-rw-r--r--gcc/testsuite/rust/execute/crate-metavar1.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/testsuite/rust/execute/crate-metavar1.rs b/gcc/testsuite/rust/execute/crate-metavar1.rs
new file mode 100644
index 0000000..8418308
--- /dev/null
+++ b/gcc/testsuite/rust/execute/crate-metavar1.rs
@@ -0,0 +1,11 @@
+macro_rules! foo {
+ () => {
+ $crate::bar()
+ }
+}
+
+pub fn bar() -> i32 { 1 }
+
+fn main() -> i32 {
+ foo!() - crate::bar()
+}