From 760f529d8138b8b6afb6f17274af194d6fd5de12 Mon Sep 17 00:00:00 2001 From: Abdul Rafey Date: Sun, 29 Jan 2023 17:05:23 +0530 Subject: gccrs: fixed compiler error message on wildcard pattern within expression gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::null_denotation): Add proper error when seeing wildcard var on right side of assignment. gcc/testsuite/ChangeLog: * rust/compile/issue-867.rs: New test. Signed-off-by: Abdul Rafey --- gcc/rust/parse/rust-parse-impl.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/rust') diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index d71bafd..af749ca 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -13021,6 +13021,12 @@ Parser::null_denotation (const_TokenPtr tok, case UNSAFE: return parse_unsafe_block_expr (std::move (outer_attrs), tok->get_locus ()); + case UNDERSCORE: + add_error ( + Error (tok->get_locus (), + "use of %qs is not allowed on the right-side of an assignment", + tok->get_token_description ())); + return nullptr; default: if (!restrictions.expr_can_be_null) add_error (Error (tok->get_locus (), -- cgit v1.1