From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by sourceware.org (Postfix) with ESMTPS id 34A32395249D for ; Tue, 31 Jan 2023 13:22:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 34A32395249D 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-x32d.google.com with SMTP id l8so10323609wms.3 for ; Tue, 31 Jan 2023 05:22:08 -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=EjB5+BF+QdgnTeSFAAmUBQ25CNL6mNd3+NsVHssfGf1HGVCKQGTFL+VzDvbiQGB+Uv VHSPCKOSEUcX5+7Ui2zoroK/fI+CPaq+0/axMhiek8MbEgJMcAoOpXgDzXhgTC6jWyAh puVYex04O12swiDGpFYyeI7S/OWmeY+EAjHBd69MDxZPVWxLeF56QwHUCE4u5wUEHgF0 ksOejdh2XFgm5o/OdyYtCAjzfGES0xm2MHGpryPcYM90ZIoesfTWE+fb4bU5wx2NwmQC zVhxH49tEp1aBMELOK9PKKe3q8q6YC6KdRuUh8Aklmw6uFVmQ39Dpqs/W+ZhhfZv5RZu WAig== X-Gm-Message-State: AO0yUKWwC5KaIR4sIrbeJUodnytrtDH6Oe/D99OC+c2H+Mxt1FS5R+61 uOSpcPtPfc6B62bQUFWjQcJ6 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-15.5 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: 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; +} -- 2.39.1