From e2682fd7cc878839c6ea6ffecfeca842d24a42c5 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Fri, 28 Nov 2025 14:11:51 +0100 Subject: [PATCH] Remove non-leaf error message in delimited tt gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_delim_token_tree): Remove error message. (Parser::parse_token_tree): Split error message. gcc/testsuite/ChangeLog: * rust/compile/macros/mbe/macro-issue3608.rs: Remove error. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/parse/rust-parse-impl.h | 22 ++++++------------- .../compile/macros/mbe/macro-issue3608.rs | 3 +-- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 1ffddabf74d6..42e004428846 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -978,16 +978,7 @@ Parser::parse_delim_token_tree () std::unique_ptr tok_tree = parse_token_tree (); if (tok_tree == nullptr) - { - // TODO: is this error handling appropriate? - Error error ( - t->get_locus (), - "failed to parse token tree in delimited token tree - found %qs", - t->get_token_description ()); - add_error (std::move (error)); - - return AST::DelimTokenTree::create_empty (); - } + return AST::DelimTokenTree::create_empty (); token_trees_in_tree.push_back (std::move (tok_tree)); @@ -1075,11 +1066,12 @@ Parser::parse_token_tree () case RIGHT_SQUARE: case RIGHT_CURLY: // error - should not be called when this a token - add_error ( - Error (t->get_locus (), - "unexpected closing delimiter %qs - token tree requires " - "either paired delimiters or non-delimiter tokens", - t->get_token_description ())); + add_error (Error (t->get_locus (), "unexpected closing delimiter %qs", + t->get_token_description ())); + + add_error (Error (Error::Kind::Hint, t->get_locus (), + "token tree requires either paired delimiters or " + "non-delimiter tokens")); lexer.skip_token (); return nullptr; diff --git a/gcc/testsuite/rust/compile/macros/mbe/macro-issue3608.rs b/gcc/testsuite/rust/compile/macros/mbe/macro-issue3608.rs index 381f1210afdf..b081d456a450 100644 --- a/gcc/testsuite/rust/compile/macros/mbe/macro-issue3608.rs +++ b/gcc/testsuite/rust/compile/macros/mbe/macro-issue3608.rs @@ -5,7 +5,6 @@ struct Baz { impl Bar for -fn main() { )// { dg-error "unexpected closing delimiter .\\). - token tree requires either paired delimiters or non-delimiter tokens" } - // { dg-error "failed to parse token tree in delimited token tree - found .\\)." "" { target *-*-* } .-1 } +fn main() { )// { dg-error "unexpected closing delimiter .\\)." } // { dg-error "unexpected token .end of file. - expecting closing delimiter .\}. .for a delimited token tree." "" { target *-*-* } .+2 } // { dg-error "unexpected token .end of file. - expecting closing delimiter .\\). .for a macro invocation semi." "" { target *-*-* } .+1 }