From patchwork Tue Jan 31 13:25:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 64016 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 47B203945C36 for ; Tue, 31 Jan 2023 13:29:53 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by sourceware.org (Postfix) with ESMTPS id 02A6A3951400 for ; Tue, 31 Jan 2023 13:29:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 02A6A3951400 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-ej1-x635.google.com with SMTP id ud5so41614111ejc.4 for ; Tue, 31 Jan 2023 05:29:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=zphQj/pye7hKgHpTnTj9j12SNWCeEYuDBV2cPwhLG9c=; b=JVV30VR034dQ4blhhHtan/o11EHpGWZT9lqRFlwDDiPSchDI3IXR7PjxwsUId6hK+0 FfV7ISRn2lfkgrSjchDvzjPfM8nrppuX0hK5/5gxJD8y64hAlW2KL8hnBprNza5oC1qn UhpmHKV8WJBJRyX+Xl7U3u4p5kRaG5SApVn+u7yLHcdqCDg9YRsgSlM7l+ePPI5lwtBb 0DYhZiCELJ2SBPKH031+if1ZXg7SnxysdyNn+cVccPzA1Ama7vxBtvvzvSop5qq7mcAg fALy0uF4wtxLR546dfM/E8gc95U9fC27ayZE22CgH82d2o4mb1he2ydxC25nTnGJhgzu KwOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=zphQj/pye7hKgHpTnTj9j12SNWCeEYuDBV2cPwhLG9c=; b=TO6Edb0bPQAl/zN5tBeUmiMp0Lvvv0QA1IVSQ4K8L9vfAyxg3E0lEK4QhOlc/ucJEo uo6jqj+ogz4T9lius957cQAE1Vm49NwbGo69QHUtG5CeN8iKuR0WPAIFQjVBPyRGlH9B aMF/J1ss7yGOBbb1abjmDVF1Qw8/z0fNPXSmTiiIdMbNz/hRJW14dr/IaAClKNBpSA7t 0wmdtqFk1RuAzeyzxna0sEUXoywfDK1FdSYwe5xO8JVuLO8LBIKEqvchTpWfsCFEqc7Y BX+I/+ZDZ935e75i7hILDaAIN1Xx15U4bZT0UPhmwnCJnJjmH5mP1zP4jF1rZ6/+5hO5 L3sA== X-Gm-Message-State: AO0yUKXE3zSd0H9e/UhqZTIEWf9KPJz6Iz6VmcaZJ612zDm3jLZbiQgB ByiIxtVLU/lV80X7nWGI/rhaaMzb/2x2pXbhHQ== X-Google-Smtp-Source: AK7set+xY2s1DUj2NtFNBMjbNxCPWDXgWsEWgcpV0kgLt5NPyuRBkdrWnocatxoZ8Iz8xmUK4/dc3g== X-Received: by 2002:a05:600c:1ca0:b0:3dc:433a:e952 with SMTP id k32-20020a05600c1ca000b003dc433ae952mr14044188wms.33.1675171327793; Tue, 31 Jan 2023 05:22:07 -0800 (PST) Received: from platypus.lan ([2001:861:5e4c:3bb0:6424:328a:1734:3249]) by smtp.gmail.com with ESMTPSA id d33-20020a05600c4c2100b003dc41a9836esm11936288wmp.43.2023.01.31.05.22.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 05:22:07 -0800 (PST) From: Arthur Cohen To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Faisal Abbas <90.abbasfaisal@gmail.com> Subject: [COMMITTED] gccrs: bugfix: initialize slice from array in const context Date: Tue, 31 Jan 2023 14:25:53 +0100 Message-Id: <20230131132553.662602-1-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-Spam-Status: No, score=-15.2 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=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" From: Faisal Abbas <90.abbasfaisal@gmail.com> gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-stmt.cc (TypeCheckStmt::visit): Turn constant item typechecking into a coercion site instead of a unify site. gcc/testsuite/ChangeLog: * rust/compile/const6.rs: New test. Signed-off-by: Faisal Abbas <90.abbasfaisal@gmail.com> Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/rust/typecheck/rust-hir-type-check-stmt.cc | 2 +- gcc/testsuite/rust/compile/const6.rs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/rust/compile/const6.rs diff --git a/gcc/rust/typecheck/rust-hir-type-check-stmt.cc b/gcc/rust/typecheck/rust-hir-type-check-stmt.cc index e82dd8e5300..a55cf22ba23 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-stmt.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-stmt.cc @@ -68,7 +68,7 @@ TypeCheckStmt::visit (HIR::ConstantItem &constant) TyTy::BaseType *type = TypeCheckType::Resolve (constant.get_type ()); TyTy::BaseType *expr_type = TypeCheckExpr::Resolve (constant.get_expr ()); - infered = unify_site ( + infered = coercion_site ( constant.get_mappings ().get_hirid (), TyTy::TyWithLocation (type, constant.get_type ()->get_locus ()), TyTy::TyWithLocation (expr_type, constant.get_expr ()->get_locus ()), diff --git a/gcc/testsuite/rust/compile/const6.rs b/gcc/testsuite/rust/compile/const6.rs new file mode 100644 index 00000000000..8f0dc320129 --- /dev/null +++ b/gcc/testsuite/rust/compile/const6.rs @@ -0,0 +1,4 @@ +fn main() { + const array:[i32; 1] = [1]; + const slice:&[i32] = &array; +}