From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id 625643858D28; Mon, 30 Jan 2023 17:24:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 625643858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675099489; bh=VzFp09A+DUfcWWxgouj3hYt/vdCwZfm+yAgk3Vdo7/Q=; h=From:To:Subject:Date:From; b=BcQqQfIYOPy5lF7zfjaYEVtgQcb89Is3dwXqPM98FeyI11YtN3wEPUkmWwsfRsCVe l8p/LtEs190RsKDLcWRhuxH+YGlEw7oMe8DOLq4dQQHMeXt4xxwFINwJfBetYWx8mN sjO4Zj4zY+yYbTkOc/n5wsooVtOXIi3pN8/2h5Xk= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Thomas Schwinge To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] fixed compiler error message on wildcard pattern within expression X-Act-Checkin: gcc X-Git-Author: Abdul Rafey X-Git-Refname: refs/heads/devel/rust/master X-Git-Oldrev: d12a38da686e39952e083821f1d77116f3ed91af X-Git-Newrev: d17212591af78ba9894d1ca7aa457ec2340ca461 Message-Id: <20230130172449.625643858D28@sourceware.org> Date: Mon, 30 Jan 2023 17:24:49 +0000 (GMT) List-Id: https://gcc.gnu.org/g:d17212591af78ba9894d1ca7aa457ec2340ca461 commit d17212591af78ba9894d1ca7aa457ec2340ca461 Author: Abdul Rafey Date: Sun Jan 29 17:05:23 2023 +0530 fixed compiler error message on wildcard pattern within expression Signed-off-by: Abdul Rafey Diff: --- gcc/rust/parse/rust-parse-impl.h | 6 ++++++ gcc/testsuite/rust/compile/issue-867.rs | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index c19fe9b6ec4..17ca6bb49d7 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 (), diff --git a/gcc/testsuite/rust/compile/issue-867.rs b/gcc/testsuite/rust/compile/issue-867.rs new file mode 100644 index 00000000000..8e120685c1a --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-867.rs @@ -0,0 +1,8 @@ +fn main() { + let _ = 42; + let a = _ + 123; // { dg-error "use of '_' is not allowed on the right-side of an assignment" } + // { dg-error {failed to parse expression in let statement} "" { target *-*-* } .-1 } + // { dg-error {failed to parse statement or expression without block in block expression} "" { target *-*-* } .-2 } + // { dg-error {unrecognised token '\}' for start of item} "" { target *-*-* } .+2 } + // { dg-error {failed to parse item in crate} "" { target *-*-* } .+1 } +}