From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by sourceware.org (Postfix) with ESMTPS id 0B9CD385380F for ; Wed, 5 Apr 2023 14:05:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0B9CD385380F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-wm1-x333.google.com with SMTP id d11-20020a05600c3acb00b003ef6e6754c5so18371313wms.5 for ; Wed, 05 Apr 2023 07:05:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1680703542; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=wFsC4ZrvK5kPI6X14aA2eunQSHlGOe6V20FjAJ0hMdc=; b=Rkp2472dfczn+QVixUp4TMN3iOyOoHsOVE7N9u0vKeN9Y3MqnSCc1iGKspLyux1MYQ Ifl5IyH90qxsrZ4bUlXYoc0oR2nRLTVGTbNmO6V0yiAIbhujYEF52SS4EE/9c5rex75+ S4RRY1AjXHQvGfwSsX1rHSoEDLRcN/4j8uzx35USt8rBMBQYbsXudgdpyYjIlfxgrTQe l2DHPOlLhJgIR7Hwd6KALct7zp2bvLOhABoYw7FWaH0kJLT98e/JTOg2NBn4Mh6O0w9f JHZgl1gyBsr+5xu2+V5EhtVi+HaTu/Sp9KAYXcu998sPExAuiAxlFnNj4OTx5JjANCd4 ukug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680703542; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=wFsC4ZrvK5kPI6X14aA2eunQSHlGOe6V20FjAJ0hMdc=; b=JkMW+3onaK69cBGHCMcThTLyXs/YOVuNVOBA09jp+50UqRUMR9ZVHUmzumnOCrBMYE XogsmjPE4IV1Ph/fK1zAIT7EsZEJY8dqBeXYXc/L8Nn3jpnkfNSnyUphUQ7Qbk0iJN4b bznR7qr2ra9BBb9OvCDAJ59M4ZdlpDj37njB0eXN1LgoPizBfgQRy/jvC/l2BxNHLzML W5LF97ZoYhIAQ1P4AWX3GHxZ59l+751a1WPnryHWunaGTSQ4LNEqcnTGWjZ3RUzeK9zO bVkUY4ncXtQYUvRS+fKi7nw0DlbqfJxkReyODouyesoD2avK2PsEn4dLsRUQItPtsA38 /7Sg== X-Gm-Message-State: AAQBX9dXk8zp/cR6KFqnNoIMe59gqVyb8UVJewAln3axZec4OvgoNRuU GbZf4qXNID9APkn5NBP5cxnM X-Google-Smtp-Source: AKy350aU4+xIQlYSVTAVzeQXD5sdbg4nq/pPNpvyoHJwTTuJeaIcfPkCORrnOhTrWFt33FIryW6Wjg== X-Received: by 2002:a1c:f013:0:b0:3ed:29d9:56ae with SMTP id a19-20020a1cf013000000b003ed29d956aemr4629588wmb.6.1680703542636; Wed, 05 Apr 2023 07:05:42 -0700 (PDT) Received: from platypus.localdomain ([62.23.166.218]) by smtp.gmail.com with ESMTPSA id ay8-20020a05600c1e0800b003edddae1068sm2330150wmb.9.2023.04.05.07.05.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Apr 2023 07:05:42 -0700 (PDT) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Abdul Rafey Subject: [committed 21/88] gccrs: fixed compiler error message on wildcard pattern within expression Date: Wed, 5 Apr 2023 16:03:05 +0200 Message-Id: <20230405140411.3016563-22-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230405140411.3016563-1-arthur.cohen@embecosm.com> References: <20230405140411.3016563-1-arthur.cohen@embecosm.com> Reply-To: arthur.cohen@embecosm.com MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-14.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: From: Abdul Rafey 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 ++++++ gcc/testsuite/rust/compile/issue-867.rs | 8 ++++++++ 2 files changed, 14 insertions(+) create mode 100644 gcc/testsuite/rust/compile/issue-867.rs diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index d71bafded63..af749ca9200 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 } +} -- 2.40.0