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: 50911 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2803795wrn; Tue, 31 Jan 2023 07:10:14 -0800 (PST) X-Google-Smtp-Source: AK7set9brkgOFniQ30/4jwxG7dr4zMxLKAy0smWUOSuEH0TkjJgd6Kduq5qGajbt5sgrkP6ekX5s X-Received: by 2002:a17:907:d085:b0:879:ec1a:4ac with SMTP id vc5-20020a170907d08500b00879ec1a04acmr17637727ejc.76.1675177814509; Tue, 31 Jan 2023 07:10:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675177814; cv=none; d=google.com; s=arc-20160816; b=PAX9nVAiWYFcwhtDWtYkr6nTJrC1elzjI9dP4GG1bdmAUg60F9T04GaSsS/mvu1O9J aZdWwNdhystUFEAqomcvcnAtXMWw8hItkTC82Ew0bJaZcBjxpf0mIOXZo2SGBVtTK3LA /M/rENlfQgIbcRaXe5U6zZoOPterKLJWCTtvAioVAZYf9NvJqbhKfSQXYWRbOYgiCDlu P3p19UC6MKVEA3QkbOxBqOKQAGRcZMuyRXGDDXnjQ7Jh2JKyRWZ9Lmxm4zCRrTQm7SIQ sv8ZKeXUdZx7wZ4QrQLQv5L/OoSwF4a8oal2V5PySrwk+SpAUU4jc3j01+cUCL8S2tFx +M1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dmarc-filter:delivered-to; bh=zphQj/pye7hKgHpTnTj9j12SNWCeEYuDBV2cPwhLG9c=; b=htoaPASAdTIBgiVdZT8TDpOimke14DxXFLgiun4fP6KawTcsHXORNM2Vf77kO9Pv1i 7gIxkqcxnKcYnH0u2rbWprHCGNMe4+zbmiQooeYDx9SQEXVB0AeckH4Hq1QWXc0no9Ix 7o9Ao6uDDRwoOnmUi4hCM7I2C0WRipt6fnDnMJETB3d5opwDeLAsaqwznJEXB+Lv9/+1 FOXzEHM41qX2TVcSX+unUl6tDFsEar4+7HXAqgE5803V8hwM0SORWuPQaA6fV3ls7tQN oOE9wi4t0zAhszp/gLZ+0DgjO7jzwlD3uVE6yc4drXJmA2jFfb/Tsqzi0z4rja0gpefw /KpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=JVV30VR0; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id 26-20020a170906015a00b007c1727f7c57si21405542ejh.243.2023.01.31.07.10.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 07:10:14 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=JVV30VR0; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 60836384FFE7 for ; Tue, 31 Jan 2023 13:30:01 +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-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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756551251670118531?= X-GMAIL-MSGID: =?utf-8?q?1756551251670118531?= 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; +}