Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7772583rwb; Tue, 6 Dec 2022 09:38:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf4dAYWRU+MFLQ4ueRUH1GTzDqL4MgzvSNYcSKdDJSl+lyhm4uBCcn6VFy9THK940RcIilhN X-Received: by 2002:a17:906:a157:b0:7a5:7e25:5b11 with SMTP id bu23-20020a170906a15700b007a57e255b11mr8161204ejb.254.1670348294238; Tue, 06 Dec 2022 09:38:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670348294; cv=none; d=google.com; s=arc-20160816; b=hC7P2m75jZPxdKG3p8K7znk+0EY/psQYV+U7uJkyU9EY34ieHD6kR9UnNYsLBjP79p kxKWUoA42KJI1rC9ct6KQb6o2d4tutMRo6y5pIQRkk8oGkfRb3vCmQdbxCoG7DddRsAD RU9VOxjLTAJKmZyvHo2Jq9XSF/FeJ65ONO/qwIupzdDcXfYAoHwXh84PmA78Ju4inWku ehnAweBSX6K3Zf11aodDUeZIvszVrZTFxB1OyuY1XmVaZCcIxzMw6sIcnUGGbGd3DVUf Gm3eRbeTM/1WQKlrPqCd9GY1+3nHF5qmXHj/sEGt9MzxxDAd9tbzG4LnHMGRMsa4KWml btlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=h458RF1zVZ1EV5DsW5Ozll8gVo7xVTHiPN8UW60GA68=; b=yuwmHAGLyyVgaLLgC2dL2lDO/gqDfMIQus1EUlznrQN0Uex3g4lm7yV6We10M4Z1NA 5kRwKiwouumY8i3sIDkB7NTD6EOcU4ei98cdSk6VtZqTzpBqI3KHiUGQrPeTURCUSeNz NK0JIxdoCm1voSpMBTj/Fr1E8Hy4DOGbIG2g12vNoagJuz8xUFN41GH2XGxYmYOk3iWF DP1i+fZpvDgo+HxVXuFFKddv6V34lAYFsemRQMEsR2PQMncZ+ziNVhtBIXGCYVlH8pDR Ijn6VC57h/lGI+SDNWX1MNRCGwg2ChQHvWFfG2IOz/SmamfflbC+Sl2OzlaQ/zwoQWB6 AiVA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qb28-20020a1709077e9c00b007c0f114b370si5602742ejc.955.2022.12.06.09.37.54; Tue, 06 Dec 2022 09:38:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229968AbiLFRWx (ORCPT + 78 others); Tue, 6 Dec 2022 12:22:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234194AbiLFRWv (ORCPT ); Tue, 6 Dec 2022 12:22:51 -0500 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48507303F5; Tue, 6 Dec 2022 09:22:50 -0800 (PST) Received: by mail-wr1-f49.google.com with SMTP id u12so23523565wrr.11; Tue, 06 Dec 2022 09:22:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=h458RF1zVZ1EV5DsW5Ozll8gVo7xVTHiPN8UW60GA68=; b=MAdwXevRAeZXm9ebxFKC37IdNfLB8qCjRWWBrM8437ruIZ5E7cRHqxnnWwNUKLKS/A ZV1JwKU7L2n1LIN9PDqIdnd2hb0fm32HJeadSu13D/nXBkYPFU9j8j95fe6e7bOgLeyv gBo6MF2OouZon21KzCukqIHCSz2+P0ewnj0Zyt5dMqjWf2XhfXORaKFz5DV4nyAaXCFc WKpSMHgNwImlsv/6Buk9EguUXxjkC89xTmc41GG5c5yQG2IXw3BtwNRtDE5wvskIzYMf LYHeskFTK23tvoT1TOxMw4fWFC9txj6FcAt0WeYc1g9jtFa/cK6zm7M8KK/L1fryGOAd RiNA== X-Gm-Message-State: ANoB5pkkInLqtKF/L+jiAZXL2K0FBI0o6qBTF0y4tMAB36TgzyqxfDe4 fwPF4fVRx+J3G/XeupmA4EQIQiP32sk= X-Received: by 2002:adf:f94f:0:b0:241:f467:f885 with SMTP id q15-20020adff94f000000b00241f467f885mr37985303wrr.482.1670347368751; Tue, 06 Dec 2022 09:22:48 -0800 (PST) Received: from liuwe-devbox-debian-v2 ([51.145.34.42]) by smtp.gmail.com with ESMTPSA id e14-20020adff34e000000b0024228b0b932sm21286544wrp.27.2022.12.06.09.22.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 09:22:48 -0800 (PST) Date: Tue, 6 Dec 2022 17:22:46 +0000 From: Wei Liu To: ojeda@kernel.org Cc: Wedson Almeida Filho , Alex Gaynor , Boqun Feng , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Josh Triplett , Wei Liu Subject: Re: [PATCH v1] rust: alloc: remove the `borrow` module (`ToOwned`, `Cow`) Message-ID: References: <20221206010519.39075-1-ojeda@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221206010519.39075-1-ojeda@kernel.org> X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 06, 2022 at 02:05:19AM +0100, ojeda@kernel.org wrote: > From: Miguel Ojeda > > The `Cow` type [1] requires that its generic parameter type implements > the `ToOwned` trait [2], which provides a method to create owned data > from borrowed data, usually by cloning. > > However, it is infallible, and thus in most cases it is not useful for > the kernel. [3] > > Therefore, introduce `cfg(no_borrow)` to remove the `borrow` module > (which contains `ToOwned` and `Cow`) from `alloc`. > > Link: https://doc.rust-lang.org/alloc/borrow/enum.Cow.html [1] > Link: https://doc.rust-lang.org/alloc/borrow/trait.ToOwned.html [2] > Link: https://lore.kernel.org/rust-for-linux/20221204103153.117675b1@GaryWorkstation/ [3] > Cc: Gary Guo > Cc: Wedson Almeida Filho > Cc: Josh Triplett > Signed-off-by: Miguel Ojeda Reviewed-by: Wei Liu