Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2476950rwd; Fri, 16 Jun 2023 04:22:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5bmUIV4VrN+50U28guZ8FLPoEQFAejTjaUpHKE6kcXrB7cdxnYac3kC3fRgykg1dKtI6YY X-Received: by 2002:a05:6870:d412:b0:19f:adc8:5f5c with SMTP id i18-20020a056870d41200b0019fadc85f5cmr1766810oag.29.1686914521731; Fri, 16 Jun 2023 04:22:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686914521; cv=none; d=google.com; s=arc-20160816; b=UUcRvhWIRiGilTpkszk9b9EaD/LpkcBe5h8YvTf58u7zr2cj+DyqRA5R0jLkZCAkyZ 6ZN3KtN/Vx8W0xLWoIYWOHSyGH87g6yP1x8cWEawAJIbUDGrQvdwmTV2Wfa/sVoRspHI hlit42KhayCVgSAN7yGsijazwwZDpAmdJE8EP4GKbZxJXQmHoX+qS2191Zq7WE1xrmu4 p002fisDgnz3H2Bf/YgiAJxYxorQgNJY4R1pBtPxCy0QYBAeeTUzDYo+iBLK0KgYz/mW OHpqxhBJ71wmVjimLPDTRvYbBLd1nPeNLSATcB06UFQGhxfpNNzyE7+hVUE65duDIxKv BX9g== 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=K8zwE/89jLmnuxpuNw+S5SHrPmwSUdNY8GcOH7EyUOE=; b=kwvtqaPJ0Mbop5qwMeTEejhUxrCuWLIB05kghfBmMIl2LslWSxpcDtOQCI1sKM9uQ7 5T7mMeSvRO7+8YldNKhCMnpeq4BTmUxdSktnNZF5R4CbjkGEJtd7RZVDdgcRkEZaT86P UShw9pdU5aWIn/JWoUx/cu8HuOpdEH0AXIJBear/nH+QJZxdfRMIJcu2MQ+xUcPBoqUu l7nyM0+4ysdFkub9LYnoB33B7BOW5Du37v2MExEBSqzlnQPegd2hvig9C1LF/MKe/iZN 8799MLA4FlHjs/2NXZVX7hrdAf83Rh1+If9ntM0NyJ2mEXk4x3i0323+Yv7zCOTnvFLx 3gxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail3 header.b=RpliA5Cv; 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 y14-20020a17090a474e00b0025e81971635si1411812pjg.24.2023.06.16.04.21.39; Fri, 16 Jun 2023 04:22:01 -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=RpliA5Cv; 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 S232372AbjFPLO2 (ORCPT + 99 others); Fri, 16 Jun 2023 07:14:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244798AbjFPLO0 (ORCPT ); Fri, 16 Jun 2023 07:14:26 -0400 X-Greylist: delayed 76 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 16 Jun 2023 04:14:25 PDT Received: from mail-40141.protonmail.ch (mail-40141.protonmail.ch [185.70.40.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCF5C119 for ; Fri, 16 Jun 2023 04:14:25 -0700 (PDT) Date: Fri, 16 Jun 2023 11:14:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1686914063; x=1687173263; bh=K8zwE/89jLmnuxpuNw+S5SHrPmwSUdNY8GcOH7EyUOE=; 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=RpliA5Cvtu2XFnz6VCS9qwq36tF6QmERzkI+K+tW98dx7C6vg6Rz/5HILV8c7rnEG 8jNjxzMuIaAuA2zGHFc3btOBrYTeAdCF02XHBSvgrPaoUmIW6tQptom3HuHyhoI9eo lwOKJUeiFqq8G+YyvcwfNnFHYG7XF4+UFAMShwwPSadD/CnTTY1UGOmfsAAMTIOnQf q9HxIZsvG7VZDNssEpej+7sMJs5aZQvv0IL2ZuSnz/fD3amzqJFyPFBj8TAPtrsrIg 8CJU51l7xim49KodUKRwqRIfPthuhV4m8BBM3Grhoes55Cbo+vvoBNYd/0c9YMw6/w Ezwv/u9j8eyvg== To: Miguel Ojeda From: =?utf-8?Q?Bj=C3=B6rn_Roy_Baron?= Cc: David Gow , Brendan Higgins , Wedson Almeida Filho , Alex Gaynor , Boqun Feng , Gary Guo , Benno Lossin , Alice Ryhl , Andreas Hindborg , Philip Li , kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev Subject: Re: [PATCH 3/6] rust: sync: make doctests compilable/testable Message-ID: In-Reply-To: <20230614180837.630180-4-ojeda@kernel.org> References: <20230614180837.630180-1-ojeda@kernel.org> <20230614180837.630180-4-ojeda@kernel.org> Feedback-ID: 27884398:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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 ------- Original Message ------- On Wednesday, June 14th, 2023 at 20:08, Miguel Ojeda wro= te: > Rust documentation tests are going to be build/run-tested > with the KUnit integration added in a future patch, thus > update them to make them compilable/testable so that we > may start enforcing it. >=20 > Signed-off-by: Miguel Ojeda > --- > rust/kernel/sync/arc.rs | 9 +++++++-- > rust/kernel/sync/lock/mutex.rs | 1 + > rust/kernel/sync/lock/spinlock.rs | 1 + > 3 files changed, 9 insertions(+), 2 deletions(-) >=20 > diff --git a/rust/kernel/sync/arc.rs b/rust/kernel/sync/arc.rs > index a89843cacaad..1ecb2efab51e 100644 > --- a/rust/kernel/sync/arc.rs > +++ b/rust/kernel/sync/arc.rs > @@ -73,6 +73,7 @@ > /// assert_eq!(cloned.b, 20); > /// > /// // The refcount drops to zero when `cloned` goes out of scope, and t= he memory is freed. > +/// # Ok::<(), Error>(()) > /// ``` > /// > /// Using `Arc` as the type of `self`: > @@ -98,6 +99,7 @@ > /// let obj =3D Arc::try_new(Example { a: 10, b: 20 })?; > /// obj.use_reference(); > /// obj.take_over(); > +/// # Ok::<(), Error>(()) > /// ``` > /// > /// Coercion from `Arc` to `Arc`: > @@ -121,6 +123,7 @@ > /// > /// // `coerced` has type `Arc`. > /// let coerced: Arc =3D obj; > +/// # Ok::<(), Error>(()) > /// ``` > pub struct Arc { > ptr: NonNull>, > @@ -337,7 +340,7 @@ fn from(item: Pin>) -> Self { > /// # Example > /// > /// ``` > -/// use crate::sync::{Arc, ArcBorrow}; > +/// use kernel::sync::{Arc, ArcBorrow}; > /// > /// struct Example; > /// > @@ -350,12 +353,13 @@ fn from(item: Pin>) -> Self { > /// > /// // Assert that both `obj` and `cloned` point to the same underlying = object. > /// assert!(core::ptr::eq(&*obj, &*cloned)); > +/// # Ok::<(), Error>(()) > /// ``` > /// > /// Using `ArcBorrow` as the type of `self`: > /// > /// ``` > -/// use crate::sync::{Arc, ArcBorrow}; > +/// use kernel::sync::{Arc, ArcBorrow}; > /// > /// struct Example { > /// a: u32, > @@ -370,6 +374,7 @@ fn from(item: Pin>) -> Self { > /// > /// let obj =3D Arc::try_new(Example { a: 10, b: 20 })?; > /// obj.as_arc_borrow().use_reference(); > +/// # Ok::<(), Error>(()) > /// ``` > pub struct ArcBorrow<'a, T: ?Sized + 'a> { > inner: NonNull>, > diff --git a/rust/kernel/sync/lock/mutex.rs b/rust/kernel/sync/lock/mutex= .rs > index 923472f04af4..09276fedc091 100644 > --- a/rust/kernel/sync/lock/mutex.rs > +++ b/rust/kernel/sync/lock/mutex.rs > @@ -63,6 +63,7 @@ macro_rules! new_mutex { > /// assert_eq!(e.c, 10); > /// assert_eq!(e.d.lock().a, 20); > /// assert_eq!(e.d.lock().b, 30); > +/// # Ok::<(), Error>(()) > /// ``` > /// > /// The following example shows how to use interior mutability to modify= the contents of a struct > diff --git a/rust/kernel/sync/lock/spinlock.rs b/rust/kernel/sync/lock/sp= inlock.rs > index 979b56464a4e..91eb2c9e9123 100644 > --- a/rust/kernel/sync/lock/spinlock.rs > +++ b/rust/kernel/sync/lock/spinlock.rs > @@ -61,6 +61,7 @@ macro_rules! new_spinlock { > /// assert_eq!(e.c, 10); > /// assert_eq!(e.d.lock().a, 20); > /// assert_eq!(e.d.lock().b, 30); > +/// # Ok::<(), Error>(()) > /// ``` > /// > /// The following example shows how to use interior mutability to modify= the contents of a struct > --=20 > 2.41.0 Reviewed-by: Bj=C3=B6rn Roy Baron