From: Pierre-Emmanuel Patry Date: Thu, 18 Sep 2025 14:57:15 +0000 (+0200) Subject: gccrs: Emit errors from the transcriber when they occur X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=53e7cb37c936d1463bcdfc6ed0bcb6beced11341;p=thirdparty%2Fgcc.git 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 --- diff --git a/gcc/rust/expand/rust-macro-expand.cc b/gcc/rust/expand/rust-macro-expand.cc index 662cc61fb86..ec4f666dc7b 100644 --- a/gcc/rust/expand/rust-macro-expand.cc +++ b/gcc/rust/expand/rust-macro-expand.cc @@ -963,7 +963,11 @@ transcribe_expression (Parser &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);