From patchwork Wed Apr 5 14:03:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 79687 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp353916vqo; Wed, 5 Apr 2023 07:33:53 -0700 (PDT) X-Google-Smtp-Source: AKy350YkkdcSlCdpz0b7LddPDB2qEU26GxSPaZ+4Vhj8GW6ZCVvp/0cXFrh7opTJANRD0RjEFd98 X-Received: by 2002:a17:906:389a:b0:926:4e16:a551 with SMTP id q26-20020a170906389a00b009264e16a551mr2277134ejd.30.1680705233014; Wed, 05 Apr 2023 07:33:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680705233; cv=none; d=google.com; s=arc-20160816; b=SPtB6PZju5snDw5jwTrPxeZDr3HVCpG3Zvk6Njgl5cX43zNaAk3M3yr2LG+R5xztg3 EvnoR16BdilmImJd1/efVnv+2vvL5psVc6fv3Yjr9zd7yQEFxBeBCmbKSMOpxU5HkRcI yuofp1JzevECWz6SSMk+aX1Cud59gXB7eEM1wP19rNLUzqfDpAbJwznWa1Lql+JcSXEr VcjA/F/SJlxxLXhXLbZiIn5Wt+DpNZWYwENc09tftexh+QV2K4OzpxXXT5Z6YMSIUKDL /+XIns23m/IUCa6xDaAgU7449f4/h2kG+FQvGPKpFSsKkqHme8fixlWdTE0zVpw6FwHx 2r9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender: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:dmarc-filter :delivered-to; bh=/cQSnI9jvcpfGvmqgitCi3DRuYQVR0oTJA4GWcgg+rw=; b=aXMhes7bbuWTryxi7OCxwtTQA63TcZJjK2Mm4EO0HG7DLV8bqIF5pMsLOmOTg9DT6u ON1qRFInzW+6fx9o4bXVTkd4a/Np1UTnbKyE5LWqOwdOA31ZS55H8inwvTT1dXB+BgM9 Hs2NdOJS46gfRityrv+OWNxdGiAOQUB8bBSnLHD8nBCZckq9/GDxEr5WhfwBwurZZm6o wHWu1fmF23scaq5xMXXysZY/gPeWIxdNZD5udsOktsdjbOs3QLpbwCt1n+nFvzTlk89R nTxeUos7gvhJX9L+PsN1kynNz0IZPXroUTkkEa84YvxsdSQcOv0PLgEbrVPl8PoEU7Tz Ftwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=CoMKIaa0; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id i16-20020aa7c9d0000000b004bf976a1b56si2461105edt.627.2023.04.05.07.33.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Apr 2023 07:33:52 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=CoMKIaa0; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 0E0D4388DC50 for ; Wed, 5 Apr 2023 14:13:12 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by sourceware.org (Postfix) with ESMTPS id 3DE583853557 for ; Wed, 5 Apr 2023 14:05:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3DE583853557 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-x32c.google.com with SMTP id m8so10052480wmq.5 for ; Wed, 05 Apr 2023 07:05:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1680703552; 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=/cQSnI9jvcpfGvmqgitCi3DRuYQVR0oTJA4GWcgg+rw=; b=CoMKIaa0Z5KGqlmv72kesiMzMbb6wgTcPKMG0+mmTKDPt+W6TfCO5ZHmkiFJ90XKYO 213w3HmC7GDYW/EkEruUhdZlLNnjgKtOGvItUq0O1F/BN4t2Yv9JOAzX7Kz4434DcN/7 WN17OQma5AXrhZ66l1PRs4xPXZ5UT2VubMHPAM50q5rKZDXrYD+jiznUocX5IZa/lI7Z 4lSKJpL/aZwKsZ1czCjTHgmGwo5l2Vvw/Rn4gkF83aBuLb0hzh1DXak96x4VsbfzmdwY aQAaPwAa3eMOdVuCdUzjM7LNb0I/uVpunThjy+x9iCx64lHrcfeN044TtNVbtFOLr29+ wvcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680703552; 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=/cQSnI9jvcpfGvmqgitCi3DRuYQVR0oTJA4GWcgg+rw=; b=B5C45VLvp8fZON4r2FpvOjMmMhD6sliC86HCBzVDbSf5B0RtCq/fyVvsybQupwCGFg kWkY3VC896nbDD12dIiVC5j/wosdF8FuQGi06S8WHuaOr9QAbIv6vqy9/n0iypR1nMl+ LjHpIgQKBDYS0Urru0JZuCQewd9VTPWOJ39YqGYj0/KrCm3PzL58AAhBSr1s7qqS4ZRx KUc4mYzMaqz87o9HFB9SH780a9G0TAua0sSKAtFVoN816zLlbwDhfrvDucQi6trYiqnS VGhuhW0XJNVDlok8N7BO4uaz+sE3om4vkoxzMNYPo+ZcxC7yVGBt94lW5f0Tiirl9zfa zu5w== X-Gm-Message-State: AAQBX9fxjrlwrM1AUYPhtQ+PL1r09sRDlNexSajETQNMjkq/ZnY6RHoy n1QXy02s6Xri+4FzR1coqG/hICYP6J9+CnBwPg== X-Received: by 2002:a05:600c:4da5:b0:3ee:93d2:c915 with SMTP id v37-20020a05600c4da500b003ee93d2c915mr2019032wmp.6.1680703552588; Wed, 05 Apr 2023 07:05:52 -0700 (PDT) Received: from platypus.localdomain ([62.23.166.218]) by smtp.gmail.com with ESMTPSA id ay8-20020a05600c1e0800b003edddae1068sm2330150wmb.9.2023.04.05.07.05.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Apr 2023 07:05:52 -0700 (PDT) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Philip Herron Subject: [committed 35/88] gccrs: Add another test case for passing associated type-bounds Date: Wed, 5 Apr 2023 16:03:19 +0200 Message-Id: <20230405140411.3016563-36-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230405140411.3016563-1-arthur.cohen@embecosm.com> References: <20230405140411.3016563-1-arthur.cohen@embecosm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-14.6 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 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: , Reply-To: arthur.cohen@embecosm.com 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?1762347170797005647?= X-GMAIL-MSGID: =?utf-8?q?1762347170797005647?= From: Philip Herron This demonstrates that this also works for custom algebraic data types too. gcc/testsuite/ChangeLog: * rust/execute/torture/issue-1720-2.rs: New test. Signed-off-by: Philip Herron --- .../rust/execute/torture/issue-1720-2.rs | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 gcc/testsuite/rust/execute/torture/issue-1720-2.rs diff --git a/gcc/testsuite/rust/execute/torture/issue-1720-2.rs b/gcc/testsuite/rust/execute/torture/issue-1720-2.rs new file mode 100644 index 00000000000..35833dbb813 --- /dev/null +++ b/gcc/testsuite/rust/execute/torture/issue-1720-2.rs @@ -0,0 +1,30 @@ +mod core { + mod ops { + #[lang = "add"] + pub trait Add { + type Output; + + fn add(self, rhs: Rhs) -> Self::Output; + } + } +} + +struct Foo(i32); + +impl core::ops::Add for Foo { + type Output = i32; + + fn add(self, rhs: Foo) -> Self::Output { + self.0 + rhs.0 + } +} + +pub fn bar>(a: T) -> i32 { + a + a +} + +pub fn main() -> i32 { + let a = Foo(1); + + bar(a) - 2 +}