]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Handle crate metavariable
authorOwen Avery <powerboat9.gamer@gmail.com>
Sat, 3 Jun 2023 23:57:33 +0000 (19:57 -0400)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:46:24 +0000 (18:46 +0100)
gcc/rust/ChangeLog:

* expand/rust-macro-substitute-ctx.cc
(SubstituteCtx::substitute_metavar): Substitute crate metavar.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
gcc/rust/expand/rust-macro-substitute-ctx.cc

index ed7cf1b2ab507fe9e489f8fcaaf0480476e08300..60e9b63de9470100b2bc6de8d82d539928b4f566 100644 (file)
@@ -31,7 +31,13 @@ SubstituteCtx::substitute_metavar (
   if (it == fragments.end ())
     {
       // fail to substitute
-      return false;
+
+      // HACK: substitute ($ crate) => (crate)
+      if (metavar->get_id () != CRATE)
+       return false;
+
+      expanded.push_back (metavar->clone_token ());
+      return true;
     }
   else
     {