Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2082771rwl; Sat, 1 Apr 2023 01:04:10 -0700 (PDT) X-Google-Smtp-Source: AKy350ZVyXVvR4ujTY8IwTFXNGpPyqUSiMSIuDZr+or0uCJCSVgoD+VGNxUVLf4bF069acGrWLXb X-Received: by 2002:a05:6a21:3381:b0:e3:e236:bbd4 with SMTP id yy1-20020a056a21338100b000e3e236bbd4mr10422827pzb.2.1680336249768; Sat, 01 Apr 2023 01:04:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680336249; cv=none; d=google.com; s=arc-20160816; b=ut9Our7fyi7puNiBhroo5IDgkMn7cEQ6SYkt5QzfvxW16G5VuA8bzP8LMfwkuPLJTs 1F06V/caWyO8NU8wASh8eeS3Rq0m+eoH9cgj1U93EXisNbdN079wGhiW3F+j1Og/KaDb auSuDytk64VTi6PTJrSgyP6jGb8evgDrNa44zhQLXaphOc8r2QzLnLIa8AdPnbeJ0MLo nfqH3yW+BWJi+0vU50ICbsauwETKODuGpmha2KXYWXeRSNnqFYUaW/Dh4Be03MJnoxPy j4rewA5GUKRta9CVrjK0CxrNiGTlrc7I37AUefiZJmVVZTvune48oUEVEj0BYVeZ17Sd SQbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :feedback-id:references:in-reply-to:message-id:subject:cc:from:to :dkim-signature:date; bh=BzUT7zsUCdXVuuD2ZphbRGXxHROe8Fo8blx0Pe9lD9Q=; b=nMlk1Rrpp1xPYdXSq71lIB1cjUX09Sxzzc9UyfrvRq0tq/ADtYeT/5CWRBccw67127 WX8HDM+WydjMzIAxQqDP8lrKmcXdzDtsa26La3AVgD5CCmi3huSm9p4Boq4pPw8X4ZYY K6ARmi4wvtxdbu3mSJeZfHs7X1LEULH6m3hffhjdexCfjeTrz3trMaBM1OScgzQkY7qP loL630wQSdgBS5Rb+neScIWeR/z6aokcBgwQaTqL6yAJ+YISg/uuWhy15SHlt9+Plo7N ygHEN7NSfQa/hD53NgvRX2GKl5WQ4P6fit3twUx7tJwywYqBGhqxz4xfdtFjzVcVmPVw exzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail3 header.b=GZ4I6tVW; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 190-20020a6309c7000000b0050bd8dd1b5asi4279719pgj.43.2023.04.01.01.03.55; Sat, 01 Apr 2023 01:04:09 -0700 (PDT) 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; dkim=pass header.i=@protonmail.com header.s=protonmail3 header.b=GZ4I6tVW; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233574AbjDAHoj (ORCPT + 99 others); Sat, 1 Apr 2023 03:44:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233230AbjDAHoh (ORCPT ); Sat, 1 Apr 2023 03:44:37 -0400 Received: from mail-40131.protonmail.ch (mail-40131.protonmail.ch [185.70.40.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B27361C1E8; Sat, 1 Apr 2023 00:44:36 -0700 (PDT) Date: Sat, 01 Apr 2023 07:44:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1680335074; x=1680594274; bh=BzUT7zsUCdXVuuD2ZphbRGXxHROe8Fo8blx0Pe9lD9Q=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=GZ4I6tVWzNX4hRwAd1PBqs8dy+u1NBMxbCam00+1/+54RQCV1HJGS0k3DxmMQ2XXA r4/X55+6ERiY9/LKehCjz8mxOi2fSyR2SplInuStik9N3a6VIkeLI/Y14HLLdpsY0j +40XxjAfoD5cbcB54y6fUG3+PUpNS9DkA9rVqBbG0XAb7sbe9oWIecFe4bEcj4dNbf Br9IOXDpkpMGCP7Sl+iL2AQ9cSlC86n6zQO3sH7AJ183YIac7Fo0uJ8FqbPheTvdJR m5S5aLYe8rvV5mM/rOKaSbJRC/lgXDha9ozVLqV5Jo84pkWn231frSVXFuIPXd5BO0 Nlwh5sPPfBW/A== To: Boqun Feng From: Benno Lossin Cc: Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Gary Guo , =?utf-8?Q?Bj=C3=B6rn_Roy_Baron?= , Alice Ryhl , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Andreas Hindborg , Alice Ryhl Subject: Re: [PATCH v4 08/15] rust: init/sync: add `InPlaceInit` trait to pin-initialize smart pointers Message-ID: <90c7c075-255e-33ef-527e-32be5e9a6fc3@protonmail.com> In-Reply-To: References: <20230331215053.585759-9-y86-dev@protonmail.com> Feedback-ID: 40624463:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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 01.04.23 00:42, Boqun Feng wrote: > On Fri, Mar 31, 2023 at 09:53:25PM +0000, y86-dev@protonmail.com wrote: > [...] >> diff --git a/rust/kernel/sync/arc.rs b/rust/kernel/sync/arc.rs >> index eee7008e5e3e..24dc96603090 100644 >> --- a/rust/kernel/sync/arc.rs >> +++ b/rust/kernel/sync/arc.rs >> @@ -17,6 +17,7 @@ >> >> use crate::{ >> bindings, >> + init::{InPlaceInit, Init, PinInit}, >> types::{ForeignOwnable, Opaque}, >> }; >> use alloc::boxed::Box; >> @@ -163,6 +164,28 @@ impl Arc { >> // `Arc` object. >> Ok(unsafe { Self::from_inner(Box::leak(inner).into()) }) >> } >> + >> + /// Use the given initializer to in-place initialize a `T`. >> + /// >> + /// If `T: !Unpin` it will not be able to move afterwards. >> + #[inline] >> + pub fn pin_init(init: impl PinInit) -> Result > > `Result` became `core::result::Result` after patch #3, so you will need > to refer to `crate::error::Result` here. Alternatively you can change > patch #3 to use the full path i.e. `core::result::Result`. > >> + where >> + Error: From, > > In my env, looks like the compiler doesn't know which `Error` it > is after removing use of `crate::error::Result` in patch #3, you > probably need to deal with this as well. > > Regards, > Boqun > >> + { >> + UniqueArc::pin_init(init).map(|u| u.into()) >> + } >> + >> + /// Use the given initializer to in-place initialize a `T`. >> + /// >> + /// This is equivalent to [`pin_init`], since an [`Arc`] is always = pinned. >> + #[inline] >> + pub fn init(init: impl Init) -> Result >> + where >> + Error: From, >> + { >> + UniqueArc::init(init).map(|u| u.into()) >> + } >> } >> >> impl Arc { >> -- >> 2.39.2 >> >> Sorry, forgot to compile check that. -- Cheers, Benno