From: Pierre-Emmanuel Patry <[email protected]>
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 <[email protected]>
---
This change was merged into the gccrs repository and is posted here for
upstream visibility and potential drive-by review, as requested by GCC
release managers.
Each commit email contains a link to its details on github from where you can
find the Pull-Request and associated discussions.
Commit on github:
https://github.com/Rust-GCC/gccrs/commit/8f265ddce78410a52b93689998b2a267d7ceb8e8
The commit has been mentioned in the following pull-request(s):
- https://github.com/Rust-GCC/gccrs/pull/4315
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 1ffddabf7..42e004428 100644
--- a/gcc/rust/parse/rust-parse-impl.h
+++ b/gcc/rust/parse/rust-parse-impl.h
@@ -978,16 +978,7 @@ Parser<ManagedTokenSource>::parse_delim_token_tree ()
std::unique_ptr<AST::TokenTree> 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<ManagedTokenSource>::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 381f1210a..b081d456a 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 }
base-commit: 3a2432a8bf6b32bff7096f653ddc2629ccfec2ca
--
2.51.2