From patchwork Wed Apr 5 14:04:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 79732 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp368427vqo; Wed, 5 Apr 2023 07:56:42 -0700 (PDT) X-Google-Smtp-Source: AKy350bDKSVHaxxBE/XXWfrN5tHbuFRWnUMUqbPg7tlif8Z9bQL2//6z0b1Vt6QrcSHHedAD/I+j X-Received: by 2002:a17:906:a107:b0:93f:50c7:2f5f with SMTP id t7-20020a170906a10700b0093f50c72f5fmr3540207ejy.63.1680706601912; Wed, 05 Apr 2023 07:56:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680706601; cv=none; d=google.com; s=arc-20160816; b=OyAXlHtZIHK3x0H1+rXl3VMGG3pkXoF8+LYbD7hIvsdEdJZPPqeMdDXHyjhRoIOD52 8KseUMCDWVFiYkIawW0OH8ZQLuoI99PAofwmwuRhbSDfF+AFi7uQPb4G5KB06vA5NEA9 mC/uXN/PbWKCkNgeQZHGNFi4FOwSeC8vH/LeHuiq2q+2KSTvebJPAiBOfxGdGMl5nEYG Z78UDh3ZMIHQtO0cVtjSt+UiUF9hNlC/nrW7060msrUsYw1fAYyFNl8RvE+4iRpaDve0 b4ItfAo0mAWeYJ8DTHCS2ecOfPWRmf0M5XbDf7cBHJuO4Ro0vExoOgWu2FZYxtjsXYgK Rt6A== 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=pd1LW5kF+OVTppK0uwtkvuvfwUqH2Okyajo7DuJVbXA=; b=nLtR5FatLdTDk/MNpjPWHIAXVwttxI9wmOmuCZ5OXavI16uj2vjCD+fQu0QDX/mJWV Q4WIWWQYTKz+gfSIZf7cYKRAJY40uL2u1XO0reNn4ga1GeZL0WbpN5uWHjE50sVmx7hP LFD7Ko3TGgPizzVhkr3JnWq094wGyjMqkMJdfyGIAZ4pqTWxPKtYrAXxEtufHU7KySlW VGqvoPMGd4F/brFqQ0diqS6zmbXfyodzEH/3Tm/Wr6cgx0qVswTZ/pVuD3nRxz/eBUP6 qs8Il6zryJaUbSGfCZUnJ8CLHlxM0fM+PwPgBiFwaP1a895whNBfYmp0M8zXe4K9qyNY pAgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=ZSq6VViO; 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 y22-20020a50e616000000b004c007c7905asi1080511edm.484.2023.04.05.07.56.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Apr 2023 07:56:41 -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=ZSq6VViO; 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 6668538E2EAA for ; Wed, 5 Apr 2023 14:21:07 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by sourceware.org (Postfix) with ESMTPS id 293493853828 for ; Wed, 5 Apr 2023 14:06:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 293493853828 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-x334.google.com with SMTP id n19-20020a05600c501300b003f064936c3eso1253142wmr.0 for ; Wed, 05 Apr 2023 07:06:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1680703581; 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=pd1LW5kF+OVTppK0uwtkvuvfwUqH2Okyajo7DuJVbXA=; b=ZSq6VViO9uSf9di2sUDQCykYTBXD9UvR2UN9aFfMfyg3X5TSX3MH5bYgZcQEtE2ZtD gKChfbP+opxTBonqKrq+GtcEn+xHq/5dE3iUCeHfHdZ09olwieZKitdHZ5xA1g4NycLn v2BnIjzaOfbqz5K54xDXM3swQH9+sDGeWS94OrhHUmQfbA4DeLnwNZn0QsAsYhXJtQVF juKCkx6yVVi03B/zfT4NTHjk0N52Fob23XNzw3z4UzbckDitFuTENhtqkf78XPuK9SRb u2L4JXyCHgOpNF1V8CVi/bypU4CQUONIDnMIjzMYvc6RSKf5kzzqGTaoRF4N9a4EiGhG eRZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680703581; 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=pd1LW5kF+OVTppK0uwtkvuvfwUqH2Okyajo7DuJVbXA=; b=I7u8o3vNVtZu+5bWukEUtkRLj5joSLCRnr9v2ELmWqEi9BO6nj3rnfD5olVyu8/wmm Esb/S74c09l95rSLV7EVKg+jc5D0j3Z1tf/kNsxr4Fc5iUSfh/4wXyC7j/Rv9VoQoXeS lTD6omBiAfW6Lgu1GiFtvnDg5/BfMSHWI0/aVIuU0yRrT2nekAmTpbsyOktbHHoAW33s URsJBskfsFwapjCmaB+QT+b1HADqPXs7Pf2vmi+fPzo2mZ1ECM8/LHYnTg8Hy5mSwjWb nuEP3UNTYClQlRKDSCHASsHw9hcL3YpcOTZEgG/GobZdIzWSR3nbax8to4f3upEP2S4C bCVQ== X-Gm-Message-State: AAQBX9eb52pGkDy7CCDaYm5anzntqwQs/cTYVo1l6RhGMvQgDEH20Skh u6wR+g8h6k3WJV4P0+xSynq25F+2a1Fwe7fBUw== X-Received: by 2002:a05:600c:215:b0:3eb:f5a2:2d67 with SMTP id 21-20020a05600c021500b003ebf5a22d67mr4837584wmi.33.1680703581421; Wed, 05 Apr 2023 07:06:21 -0700 (PDT) Received: from platypus.localdomain ([62.23.166.218]) by smtp.gmail.com with ESMTPSA id ay8-20020a05600c1e0800b003edddae1068sm2330150wmb.9.2023.04.05.07.06.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Apr 2023 07:06:21 -0700 (PDT) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Philip Herron Subject: [committed 76/88] gccrs: Fix regression in testcase Date: Wed, 5 Apr 2023 16:04:00 +0200 Message-Id: <20230405140411.3016563-77-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.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=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: , 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?1762348605349261918?= X-GMAIL-MSGID: =?utf-8?q?1762348605349261918?= From: Philip Herron Fixes #776 Signed-off-by: Philip Herron gcc/testsuite/ChangeLog: * rust/compile/torture/traits10.rs: Fix test-case --- .../rust/compile/torture/traits10.rs | 64 ++++++++++++++++++- 1 file changed, 62 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/rust/compile/torture/traits10.rs b/gcc/testsuite/rust/compile/torture/traits10.rs index a02927007b3..4cf36e3c6f1 100644 --- a/gcc/testsuite/rust/compile/torture/traits10.rs +++ b/gcc/testsuite/rust/compile/torture/traits10.rs @@ -1,5 +1,65 @@ -trait Foo // where -// Self: Sized, +#[lang = "sized"] +pub trait Sized {} + +#[lang = "clone"] +pub trait Clone: Sized { + fn clone(&self) -> Self; + + fn clone_from(&mut self, source: &Self) { + *self = source.clone() + } +} + +mod impls { + use super::Clone; + + macro_rules! impl_clone { + ($($t:ty)*) => { + $( + impl Clone for $t { + fn clone(&self) -> Self { + *self + } + } + )* + } + } + + impl_clone! { + usize u8 u16 u32 u64 // u128 + isize i8 i16 i32 i64 // i128 + f32 f64 + bool char + } +} + +#[lang = "copy"] +pub trait Copy: Clone { + // Empty. +} + +mod copy_impls { + use super::Copy; + + macro_rules! impl_copy { + ($($t:ty)*) => { + $( + impl Copy for $t {} + )* + } + } + + impl_copy! { + usize u8 u16 u32 u64 // u128 + isize i8 i16 i32 i64 // i128 + f32 f64 + bool char + } +} + +trait Foo +where + Self: Sized, { fn get(self) -> i32;