From patchwork Wed Apr 5 14:03:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 79686 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp353837vqo; Wed, 5 Apr 2023 07:33:45 -0700 (PDT) X-Google-Smtp-Source: AKy350Z+MyJvkLW5ae2rtdh48ikhtrKHN9pdjWvPELrGJDVrEsCuxib+ehAro7WsoLYWIL9QETJL X-Received: by 2002:a05:6402:b33:b0:502:a6b3:6de with SMTP id bo19-20020a0564020b3300b00502a6b306demr2256507edb.17.1680705225809; Wed, 05 Apr 2023 07:33:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680705225; cv=none; d=google.com; s=arc-20160816; b=EUanCN0n5MVHtqw45uvmw5h3qEQhHRRqNZnV/ZxSVEUUWrzQO7faKzfD7qh4rVCzrI SOEPQR36aagwbqS/ElIyZEps45pJktxEOTskDrJQk9TkU/Q9HeZ5TCySjfPKsNIRiWMY t+IlhmUPQIzorhk9zJONdDTfJOU2JLSrBcuB19+SaGhyp1VmaPfeUc2qCkmMrlFexmC0 8g7f/6QdgIEfP/xT+rjkDSQ1yPRW610pK22vZLaxT8a/7Sbm51UW9nQpLD5cAt98/trf SnCDi7Vxo0ONLvTrpwPokKyj6blqam5y3sOg6i65qAv+1cpnXzMsL6fbuCMVBzQ0nFeh ZXLQ== 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=0Ruhi0YVCTS0PZIDwZd2lXBkluzz5LJvgOYcNswll30=; b=iwVVuy12MgeMhVP/Tr8wZpLMjgNR/uNvsW5mrFkhBM1351kCRBTCxp0wRnk/9FDvU/ UW841im/2oejGcuc/jKh1hymUE/E4ihinmzEQtFPjypTXyB1U0xCcLGnTRyaod3/kSa7 h94YV22jELkdNZTYx9eyaMnfQK4qrcWStunje9YxvlmxTclpkQ2G5uCeRq45FFPf4k5G VUfLq+Wgeblti/jnUIlcFeK/j2DVHhuGUiwoWv/5K1fgPR2NtdqSpO5eh4xhR3g/js45 tjwz9+vRVtHBnLMLa3TDuMbnPNJxALoM30hHiJVIgOnJ1m0x6whcndoRWvEE+6S5cMCn Nogg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=XsrWV1+h; 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 gq15-20020a170906e24f00b00928b3b7d509si4990451ejb.90.2023.04.05.07.33.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Apr 2023 07:33:45 -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=XsrWV1+h; 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 BF122388D721 for ; Wed, 5 Apr 2023 14:13:10 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by sourceware.org (Postfix) with ESMTPS id 87BFA38708EC for ; Wed, 5 Apr 2023 14:06:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 87BFA38708EC 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-x331.google.com with SMTP id v6-20020a05600c470600b003f034269c96so11821917wmo.4 for ; Wed, 05 Apr 2023 07:06:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1680703565; 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=0Ruhi0YVCTS0PZIDwZd2lXBkluzz5LJvgOYcNswll30=; b=XsrWV1+h/XFd5S2uGcpIRHK+YJ/iKkVR1AHNpAHpZVgDv2vacaNuyhYxJVDBKPHrgK Dce1AIYP5/TwZcTgbHYhYHx+Ge3L4ZQFv4LM3MgImySL+jWIQ+hkvSAFuDb+QarOH89E /Pyz9ddEcQyg/K+CN9uwKtXWyzDl0k50rIvvMnN0v3+sIzclC/vbi0NcHclhfOBx6fTa zi4lPGXMAfynvmPJ/CrbOqme3DlSf8+xVXuxX8Rv1hS1UTc7/MMeO3XbH0MC7nVhNeVC bvo12pRntAuMdp/wstYkTY4AKbUYV3TIo7012PXiPzp54DMsAIpG7vYfWDRIB9lhPcF+ gGOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680703565; 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=0Ruhi0YVCTS0PZIDwZd2lXBkluzz5LJvgOYcNswll30=; b=Ql5UOu/gOWFsuHR+GNZcVpO9Plj8HhIAs7CdtlYHilSSPy25NVFWUQwBn3uZdnWzWV TWYQlHHRL2S4y91bYy1S/D6JBcLx5f54MG8QCPxPHNlqJ7qw+x5UWTGwckbOR35I0g5z tg9y6x9DdEec92vYpZJQpik/pUsQDY2dsk4zcq3BiiB5YpkQh7CsbjhgP6aYxAf1t08n kLn4DIzSy7v7jNPwMAWtKnWw5pJAFCFG7XijSsA2lT92UQAVcx8GA6A2CO1Yws5kV55O CB/z9EkobDAEzHXHVPpJ4bRKk8IxZYkyI2zbAX/FAtx46CPmoQ5y4IeB+vgzTAuVIfW0 0xMQ== X-Gm-Message-State: AAQBX9cZZ0MmMjcq0PNrTi4voqCETIPLL+V2M3N1weCRFRZIj8O7VqX4 2VCjnAfMkjIYe1Tn4aTxSutXweW0b19dxUGFlw== X-Received: by 2002:a7b:cbcc:0:b0:3ed:2eb5:c2e8 with SMTP id n12-20020a7bcbcc000000b003ed2eb5c2e8mr5301927wmi.10.1680703564926; Wed, 05 Apr 2023 07:06:04 -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.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Apr 2023 07:06:04 -0700 (PDT) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Philip Herron Subject: [committed 52/88] gccrs: Add missing Sized, Copy and Clone lang item mappings Date: Wed, 5 Apr 2023 16:03:36 +0200 Message-Id: <20230405140411.3016563-53-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.3 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?1762347162920218711?= X-GMAIL-MSGID: =?utf-8?q?1762347162920218711?= From: Philip Herron We need these lang items to be defined and later down the line the mappings will be used to implement proper copy and clone logic. Fixes #1786 Signed-off-by: Philip Herron gcc/rust/ChangeLog: * util/rust-lang-item.h: gcc/testsuite/ChangeLog: * rust/compile/issue-1786.rs: New test. --- gcc/rust/util/rust-lang-item.h | 24 ++++++++++++++++++++++++ gcc/testsuite/rust/compile/issue-1786.rs | 23 +++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 gcc/testsuite/rust/compile/issue-1786.rs diff --git a/gcc/rust/util/rust-lang-item.h b/gcc/rust/util/rust-lang-item.h index 29c364bad61..c5ef6200fb4 100644 --- a/gcc/rust/util/rust-lang-item.h +++ b/gcc/rust/util/rust-lang-item.h @@ -80,6 +80,12 @@ public: FN_ONCE, FN_ONCE_OUTPUT, + // markers + COPY, + CLONE, + SIZED, + + // delimiter UNKNOWN, }; @@ -237,6 +243,18 @@ public: { return ItemType::FN_ONCE_OUTPUT; } + else if (item.compare ("copy") == 0) + { + return ItemType::COPY; + } + else if (item.compare ("clone") == 0) + { + return ItemType::CLONE; + } + else if (item.compare ("sized") == 0) + { + return ItemType::SIZED; + } return ItemType::UNKNOWN; } @@ -321,6 +339,12 @@ public: return "fn_once"; case FN_ONCE_OUTPUT: return "fn_once_output"; + case COPY: + return "copy"; + case CLONE: + return "clone"; + case SIZED: + return "sized"; case UNKNOWN: return ""; diff --git a/gcc/testsuite/rust/compile/issue-1786.rs b/gcc/testsuite/rust/compile/issue-1786.rs new file mode 100644 index 00000000000..f73b63d0cb6 --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-1786.rs @@ -0,0 +1,23 @@ +#[lang = "clone"] +trait Clone { + fn clone(&self) -> Self; + + fn clone_from(&mut self, source: &Self) { + *self = source.clone() + } +} + +#[lang = "copy"] +pub trait Copy: Clone { + // Empty. +} + +mod impls { + use super::Clone; + + impl Clone for char { + fn clone(&self) -> Self { + *self + } + } +}