From patchwork Tue Jan 31 13:26:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 63998 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 470403897634 for ; Tue, 31 Jan 2023 13:25:19 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by sourceware.org (Postfix) with ESMTPS id 241F33AA800D for ; Tue, 31 Jan 2023 13:22:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 241F33AA800D 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-x32a.google.com with SMTP id k8-20020a05600c1c8800b003dc57ea0dfeso4461396wms.0 for ; Tue, 31 Jan 2023 05:22:54 -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=HpW4NwAcCbOVh6lyC7GPbvJa27IQ4H3lps395+OQNcM=; b=Ua3t9j7o0cjMoy4+bVAlOUfGh+tIbAkgpnElt3oog6lpX03Zes0uThC99fxOdcrMVh GuPtsZ+yotsXMLS8DCMtCI2rbD8uhXMB1nu76HMNdtJAltXOvT6CK5RGl/tFWnNWWwdI MUkRZa1B0ks9xVuqVsypwlNzSh6GsrMYCZX8UjRBGuqceynyDx0esmIGvHvfo7sLFv+d WJjIF4GkOIxCWifThD94VWPhVO/+mHW2iVDFYHGq73WkoLpKptwB0rKWJ3mPFPCw8Czv tzxScTyvZehfeeKiF2he59PvqnEiEYu+ZKGm7220OC2lxpaRmAnZE4+dKAfTfohzL+WN otaw== 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=HpW4NwAcCbOVh6lyC7GPbvJa27IQ4H3lps395+OQNcM=; b=CivspsW926cRj0ETJKmpx7H7FGw2KwwPoQutX8KPj0/iGqZQrHMMhs46u+NW9iwksl yNAfStGlrEsg5bJsGHmYh7QYgPWjdgxdQqEnyGJzxK1pitPbQy/khIYrE/6rjgHq20XB rqCOF9zfzNP02k95ChOk/l2JuI9FTVIl478eMrbTxru3A7OVoLpy3AJKKoVBbu2mPhnL D1yWFX8WfOocgEsHLtmwPnODC4Nw8do3c7kFV1/GBAdWAOMpuNPPuqyUqaOzuVJg1xq3 YKaz3bZivAS0ErOt6gGL7Vm9vEpzFCJD0/tGk+vxQydlArBVX2WdQitUDoJXJgCodsis yX7Q== X-Gm-Message-State: AO0yUKX4nDHg/D8+lCrykZ1Z1wLt4SY5x/OPw8S54WFzKISepf0zD+nr HKl5SqeoGZfwTstixZLX7lvhDpm3I2zO45ZdNw== X-Google-Smtp-Source: AK7set/qEjT33Q/u/OxMcs1oe2rzeItddrN37J8oJq1H1DT/MGP01eUCI8qcxsiYBUjwIHxiFRORKg== X-Received: by 2002:a05:600c:3c86:b0:3dd:1b76:347f with SMTP id bg6-20020a05600c3c8600b003dd1b76347fmr3615837wmb.18.1675171372529; Tue, 31 Jan 2023 05:22:52 -0800 (PST) Received: from platypus.lan ([2001:861:5e4c:3bb0:6424:328a:1734:3249]) by smtp.gmail.com with ESMTPSA id i19-20020a05600c2d9300b003dc4fd6e624sm9075222wmg.19.2023.01.31.05.22.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 05:22:52 -0800 (PST) From: Arthur Cohen To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Philip Herron Subject: [COMMITTED] gccrs: Statics are a coercion site Date: Tue, 31 Jan 2023 14:26:33 +0100 Message-Id: <20230131132633.663363-1-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-Spam-Status: No, score=-15.4 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: Philip Herron Statics can be assigned to a block expression meaning they need to behave similarly to constant items. gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-toplevel.cc (TypeCheckTopLevel::visit): Make static items behave more similarly to const items. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/rust/typecheck/rust-hir-type-check-toplevel.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gcc/rust/typecheck/rust-hir-type-check-toplevel.cc b/gcc/rust/typecheck/rust-hir-type-check-toplevel.cc index b0ee292df10..594e527fdcf 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-toplevel.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-toplevel.cc @@ -261,11 +261,11 @@ TypeCheckTopLevel::visit (HIR::StaticItem &var) TyTy::BaseType *expr_type = TypeCheckExpr::Resolve (var.get_expr ()); TyTy::BaseType *unified - = unify_site (var.get_mappings ().get_hirid (), - TyTy::TyWithLocation (type, var.get_type ()->get_locus ()), - TyTy::TyWithLocation (expr_type, - var.get_expr ()->get_locus ()), - var.get_locus ()); + = coercion_site (var.get_mappings ().get_hirid (), + TyTy::TyWithLocation (type, var.get_type ()->get_locus ()), + TyTy::TyWithLocation (expr_type, + var.get_expr ()->get_locus ()), + var.get_locus ()); context->insert_type (var.get_mappings (), unified); }