Skip to content

Commit 5c80bfc

Browse files
committed
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]>
1 parent 72967d7 commit 5c80bfc

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

gcc/rust/expand/rust-macro-expand.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,11 @@ transcribe_expression (Parser<MacroInvocLexer> &parser)
963963
auto attrs = parser.parse_outer_attributes ();
964964
auto expr = parser.parse_expr (std::move (attrs));
965965
if (expr == nullptr)
966-
return AST::Fragment::create_error ();
966+
{
967+
for (auto error : parser.get_errors ())
968+
error.emit ();
969+
return AST::Fragment::create_error ();
970+
}
967971

968972
// FIXME: make this an error for some edititons
969973
if (parser.peek_current_token ()->get_id () == SEMICOLON)
@@ -1152,11 +1156,7 @@ MacroExpander::transcribe_rule (
11521156

11531157
// emit any errors
11541158
if (parser.has_errors ())
1155-
{
1156-
for (auto &err : parser.get_errors ())
1157-
rust_error_at (err.locus, "%s", err.message.c_str ());
1158-
return AST::Fragment::create_error ();
1159-
}
1159+
return AST::Fragment::create_error ();
11601160

11611161
// are all the tokens used?
11621162
bool did_delimit = parser.skip_token (last_token_id);

0 commit comments

Comments
 (0)