Message ID | 20240130121026.807464-80-arthur.cohen@embecosm.com |
---|---|
State | Unresolved |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1188927dyb; Tue, 30 Jan 2024 04:38:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IHdL3I/ilAZ9vYouD55ylL2wqGcgHhS+dghz2199FGLMGMhGofvKtOe67p4G4KWS9ruCzLB X-Received: by 2002:a05:620a:2629:b0:783:fbc1:9c25 with SMTP id z41-20020a05620a262900b00783fbc19c25mr5325286qko.36.1706618337142; Tue, 30 Jan 2024 04:38:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706618337; cv=pass; d=google.com; s=arc-20160816; b=YKStf2xIVnsekuYcbrnW2HA4mfQv06TxTLc7l5g8owYCN7OPjH+rpQ34rf8BCx17fM o8srfFcA1vcIHlW6Dv0L6bJhhrsoTjN/7zYsYx902MvdhRDFkbSgiNl0MUb2L3cJz226 kAU0kgk1PXKk2aMpJrzxZVXyE7a71lz4r7cyB8I5gHrmhd4SLOu9hlWYRTlzCEEDOjZa t5qoUSOPsMmpQ5ukgzDgJMabhqA9smzoL1HmunwqmkP9DL52rv8maHQdVxXrHKLQI5hS PNWoadOM1Bz57H/XPscFx6qQvD5IKEDdPkHQcOPHGrsQ0kjYvlXGAUMPhZazxkHLcos3 XXWQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:reply-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=c5ar4ANHt3rVdOEEMWvgAQjfr27lyOrmBWniB8yo1S0=; fh=tF/FjG7igJhcOEGq79wqr3ldeoZUVk5V7TNEGxaLUD4=; b=kJnbo4ExUdWaAz+QcW/7XF6KAPZdM5nxX2xVM7uN4+lhSpPTNzz4IaVQBsoykMcoqh JYEPMUXrs9CrIv9sRCpyM3npTVqHEJ7wXfc8L6qC/OgS/NDzqwE9MbRd58uPK99cfq7A 80uGgyIWmjarzXU10iIHDtgzeGPfszLf28joxhW5iZG9ISa93pFAANd6WxV+M/2AgCgz Wxu+KMUO7bxhNoy14dohybfgFRG0PW4AOvnqNfgXt0xsrQoDxMeNYqE/c7S2MSt32ewz lmTOrk46FVof/slLKmZbB5/F6YMsWLYpVLUZin9Ft0iorgiqFakt4Hlfy3EZdl45lCWh 693g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=QDO3PUzO; arc=pass (i=1); 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 (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id az20-20020a05620a171400b00783fed2e896si4693006qkb.55.2024.01.30.04.38.57 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 04:38:57 -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=QDO3PUzO; arc=pass (i=1); 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 68C7338323FF for <ouuuleilei@gmail.com>; Tue, 30 Jan 2024 12:38:10 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by sourceware.org (Postfix) with ESMTPS id 7278B3858014 for <gcc-patches@gcc.gnu.org>; Tue, 30 Jan 2024 12:11:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7278B3858014 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7278B3858014 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::432 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706616748; cv=none; b=TEbSKIOkt7txtdFJ+Ms1k82cTozNbEL8Bde8BX13OC2vq3NYK8zyN7T0mWD++Iq7WdXaJt4hmB4bJDv3wT8RgIBwQBKZ17M+cc/gUCPX72vnIV/Ix/eoYkxsc9ZH+q3obgkXh5rBNiMTWLd18aeD6WyIOWJj8AueqlcB6TkX+p4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706616748; c=relaxed/simple; bh=2XF/Y3sgZjX6r70VvOG9SocX1lMF8PISH21OwbdgADo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=ncYslH9qXuu47FTExZWN6fMYVPSZz71l90PW7wRvuxDXvJIT5TSC4BtGLdz/lb3Tvm//j2x99mAnFCyo6HAToBAECYsdB1zuN5Gm0O9ARTT/al+pWQOtcBCbhNnPElC5fYmEFnGJ7HDRN06P+XaOPmP0cQmwbJmAEVoQ2GO1fdE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-3392b12dd21so2802198f8f.0 for <gcc-patches@gcc.gnu.org>; Tue, 30 Jan 2024 04:11:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1706616706; x=1707221506; darn=gcc.gnu.org; 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=c5ar4ANHt3rVdOEEMWvgAQjfr27lyOrmBWniB8yo1S0=; b=QDO3PUzOaZLVyjNciKAGxLozJb7V4VPxHrMMBmCM9/2HqIbhSupBKpgNalAjubWryu m5w077wO1WafOKaa4XaUua9rDJ2SPCkCgHNtRsCb03KDCMdYpVV6aLO8y7Te84Uww6Zl 4XK67Nzai8AS24JkgdjKkYk9QJCrh91Lx72wtrqVbVjXcTJXN9jpp0jkkqH1wJX2U7gg /k0uNzWOVTfEEJs1FPqF1oJ4Y0iKsXQPnTkzaXGgZxe8QWYhE4LhsSpjkIN74QDMXBFw oyzO8XLa+Q2Oa4VRLS60kK7uKQG8X6EtpPlOYCecQlvTL1CX7aMSGp8Hmb2mBt8ScknR uphg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706616706; x=1707221506; 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=c5ar4ANHt3rVdOEEMWvgAQjfr27lyOrmBWniB8yo1S0=; b=OXF7XeYNXNbMX5c8iZEEd0xPUJwnvqJlF38YgJ3Vb6gS8JP8Wbj32NzOO2WXhGVMsQ AA/OLINFfDmtWXuilm3uRjkQVNkqurNMgG1q/oxtsE+HifwZBtJ/CaTYhys50irC5MyM PZUiqCcNTxWOLM/ISesMN4QhiB+L/7Z30dwYWgWCqgawKQYNveqn7adC2Omq2bKno+3k 9/QOsDq0FPVsu7QOy6qz9/608k5Gn75W2cI1fGNLdBWpWoTzWlGQHs0KR1U52kk8oB23 5JKCVN+m0uHR7iJOsWjUJJOgNpiA7kFEDgk6xS60k0+eT2ms6hkgA9P4nls7mqsPEHSn s/4A== X-Gm-Message-State: AOJu0YzZUSWmLJxsneZ99QBFPoDpugkx4s5wVOwiufO4BotZzeSTSK0r XyBKRs7OQ8nN9n1Wm9clkOOXBkOtcs6Z1BtMJ2UPGj7iSOv4vxvVA0zw2YHY0u4J0OU7ALAvhPY fBQ== X-Received: by 2002:a05:6000:cc5:b0:337:6948:1309 with SMTP id dq5-20020a0560000cc500b0033769481309mr5704393wrb.38.1706616706440; Tue, 30 Jan 2024 04:11:46 -0800 (PST) Received: from platypus.localdomain ([62.23.166.218]) by smtp.gmail.com with ESMTPSA id f9-20020a056000036900b00339307d9d31sm10569894wrf.112.2024.01.30.04.11.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 04:11:46 -0800 (PST) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Jakub Dupak <dev@jakubdupak.com> Subject: [COMMITTED 077/101] gccrs: TyTy: SubstitutionRef cast specialization Date: Tue, 30 Jan 2024 13:07:33 +0100 Message-ID: <20240130121026.807464-80-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20240130121026.807464-2-arthur.cohen@embecosm.com> References: <20240130121026.807464-2-arthur.cohen@embecosm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-14.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, T_SCC_BODY_TEXT_LINE autolearn=ham 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.30 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Reply-To: arthur.cohen@embecosm.com Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789519029513314875 X-GMAIL-MSGID: 1789519029513314875 |
Series |
[COMMITTED,001/101] gccrs: Add visibility to trait item
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | warning | Git am fail log |
Commit Message
Arthur Cohen
Jan. 30, 2024, 12:07 p.m. UTC
From: Jakub Dupak <dev@jakubdupak.com> Allows skipping parent check when casting. gcc/rust/ChangeLog: * typecheck/rust-tyty.h (BaseType::is): Cast API. (SubstitutionRef>): Cast API. (BaseType::as): Cast API. (BaseType::try_as): Cast API. Signed-off-by: Jakub Dupak <dev@jakubdupak.com> --- gcc/rust/typecheck/rust-tyty.h | 78 ++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+)
diff --git a/gcc/rust/typecheck/rust-tyty.h b/gcc/rust/typecheck/rust-tyty.h index 6ce760df66e..2ed407ee169 100644 --- a/gcc/rust/typecheck/rust-tyty.h +++ b/gcc/rust/typecheck/rust-tyty.h @@ -1575,6 +1575,84 @@ BaseType::is<const CallableTypeInterface> () const return this->is<CallableTypeInterface> (); } +template <> +WARN_UNUSED_RESULT inline bool +BaseType::is<SubstitutionRef> () const +{ + auto kind = this->get_kind (); + return kind == FNPTR || kind == FNDEF || kind == CLOSURE || kind == ADT + || kind == PROJECTION; +} + +template <> +WARN_UNUSED_RESULT inline bool +BaseType::is<const SubstitutionRef> () const +{ + return this->is<SubstitutionRef> (); +} + +template <> +WARN_UNUSED_RESULT inline SubstitutionRef * +BaseType::as<SubstitutionRef> () +{ + auto kind = this->get_kind (); + switch (kind) + { + case FNDEF: + return static_cast<FnType *> (this); + case CLOSURE: + return static_cast<ClosureType *> (this); + case ADT: + return static_cast<ADTType *> (this); + case PROJECTION: + return static_cast<ProjectionType *> (this); + default: + rust_unreachable (); + } +} + +template <> +WARN_UNUSED_RESULT inline const SubstitutionRef * +BaseType::as<const SubstitutionRef> () const +{ + auto kind = this->get_kind (); + switch (kind) + { + case FNDEF: + return static_cast<const FnType *> (this); + case CLOSURE: + return static_cast<const ClosureType *> (this); + case ADT: + return static_cast<const ADTType *> (this); + case PROJECTION: + return static_cast<const ProjectionType *> (this); + default: + rust_unreachable (); + } +} + +template <> +WARN_UNUSED_RESULT inline SubstitutionRef * +BaseType::try_as<SubstitutionRef> () +{ + if (this->is<SubstitutionRef> ()) + { + return this->as<SubstitutionRef> (); + } + return nullptr; +} + +template <> +WARN_UNUSED_RESULT inline const SubstitutionRef * +BaseType::try_as<const SubstitutionRef> () const +{ + if (this->is<const SubstitutionRef> ()) + { + return this->as<const SubstitutionRef> (); + } + return nullptr; +} + } // namespace TyTy } // namespace Rust