https://gcc.gnu.org/g:53e7cb37c936d1463bcdfc6ed0bcb6beced11341

commit r16-4872-g53e7cb37c936d1463bcdfc6ed0bcb6beced11341
Author: Pierre-Emmanuel Patry <[email protected]>
Date:   Thu Sep 18 16:57:15 2025 +0200

    gccrs: Emit errors from the transcriber when they occur
    
    Emitting the errors later means some error could be emitted multiple
    times.
    
    gcc/rust/ChangeLog:
    
            * expand/rust-macro-expand.cc (transcribe_expression): Emit error
            early.
    
    Signed-off-by: Pierre-Emmanuel Patry <[email protected]>

Diff:
---
 gcc/rust/expand/rust-macro-expand.cc | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/gcc/rust/expand/rust-macro-expand.cc 
b/gcc/rust/expand/rust-macro-expand.cc
index 662cc61fb860..ec4f666dc7b3 100644
--- a/gcc/rust/expand/rust-macro-expand.cc
+++ b/gcc/rust/expand/rust-macro-expand.cc
@@ -963,7 +963,11 @@ transcribe_expression (Parser<MacroInvocLexer> &parser)
   auto attrs = parser.parse_outer_attributes ();
   auto expr = parser.parse_expr (std::move (attrs));
   if (expr == nullptr)
-    return AST::Fragment::create_error ();
+    {
+      for (auto error : parser.get_errors ())
+       error.emit ();
+      return AST::Fragment::create_error ();
+    }
 
   // FIXME: make this an error for some edititons
   if (parser.peek_current_token ()->get_id () == SEMICOLON)
@@ -1152,11 +1156,7 @@ MacroExpander::transcribe_rule (
 
   // emit any errors
   if (parser.has_errors ())
-    {
-      for (auto &err : parser.get_errors ())
-       rust_error_at (err.locus, "%s", err.message.c_str ());
-      return AST::Fragment::create_error ();
-    }
+    return AST::Fragment::create_error ();
 
   // are all the tokens used?
   bool did_delimit = parser.skip_token (last_token_id);

Reply via email to