Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp6393136rwp; Mon, 17 Jul 2023 22:33:00 -0700 (PDT) X-Google-Smtp-Source: APBJJlHodPnXu3qPLcKbMgTXyiqyUxpOLsoRIJ5xV+bAXH8Y5AoNC5oCtinTWzt36i5EttNKaiT6 X-Received: by 2002:a17:906:68c9:b0:992:b1b2:9bf4 with SMTP id y9-20020a17090668c900b00992b1b29bf4mr12041599ejr.35.1689658380555; Mon, 17 Jul 2023 22:33:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689658380; cv=none; d=google.com; s=arc-20160816; b=xon9bcI4cT7LM1uD1G9WZ+Xbr09snTuaVqkpHktBgvk6otRXokyshFEmWKcBAHqnuO sI1FRW+v2ETOJVAr1sYHi5CZnMC1uhzzz7VJuenfVhngkebDnSvyyYbxXzXRY0JtaVdt Rieg4iYVEojJ117VjIug1OR1tKg6/adTOdARqSvgHxYapAn95oTZ/chB9RbIN8Tl9LHQ Yi9Y/C53sUcB7UUj8pS4rfiSsnemj4tvRFZTSbSv11t5Z3PhIk5bOXOJvFqEMbYkR3g4 S64uWztF19wGCIrgI62dc//fLHqWq0ofYitxv3ddB71bzs0TPKpQju/fUA6w3snFDl3d TFCw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uV4E+c9dBmGstJYuPcH/eDtLtl6gy94kxbCUAYpiOY4=; fh=idY8ZpQobwn4LBSZ5YdQwasJlU+OywLSGnM0rkTCwe0=; b=cFQUK5Gx067FPnVGE8n4QgbRZ56iTLeZezYDIxkDOxV0TK2AluQZw+eW/Njf8UnH+T BvT4wf2Kl6xnqk79bnGeBBDHTN1ptn1wzLqSa+WQmKm9xRRY4OS+YKGcw5CPqMJMtlbH WYhSfhCg+Jf9VWqdZnXE8Qkm262iWp6qvrXa3LfftImd3Sf5JnZzL06FR41QIkv83aPy I46LqYIOD5v0/GfXuiGlwEB02ETiNkgxP4q94/a8I87bP8/HDKOhykV1DbwKNpWSoySd X36Z8xEXfT3oAi3Dpsp9zAkVDiP2/ipkiYiHru08B2pJ2kMO5BRHGWCBmIxNdEqzHHs0 Vuxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TpXWXHzo; 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 ju11-20020a17090798ab00b00991f5560a1dsi694611ejc.32.2023.07.17.22.32.36; Mon, 17 Jul 2023 22:33:00 -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=@kernel.org header.s=k20201202 header.b=TpXWXHzo; 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 S230443AbjGRF2z (ORCPT + 99 others); Tue, 18 Jul 2023 01:28:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230379AbjGRF2t (ORCPT ); Tue, 18 Jul 2023 01:28:49 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E0181737; Mon, 17 Jul 2023 22:28:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EF7A16144A; Tue, 18 Jul 2023 05:28:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A18F8C433CA; Tue, 18 Jul 2023 05:28:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689658115; bh=kbTYD/XHSLwWeaw9PdvZppJ7Vxhric46YCXiOC0rb7Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TpXWXHzomibZLxv1UpxZchEbd5njAUz1GR3pxZBw4eP0lOOPTJfuprkjv9Vnx8LyS d5FL/iTrjuxUnwidjnNKZ9cUcNxX/b0Y1i9+tr6aARA2a1pZ4iesoQ/1mwpErfPg1Z Qd34M0ydPtf4LHDgpZ2riK9LG/1BosVKFvnwhJx/Dy/3N1xVvyQJmUr2bxtalrJyIs OvJShMv7iQbfmVgnljGj6YQSnEK15aKora5+xq1DVMTmUEkHf41ykTQngxzR1RuYUR uguZn3i4Gb9oJqAYCtev8R0UVnlGbQgAY+yffxfXmUPFR7jLj4WgKNpzn4kgr2PsaW iar/JX8uH3ndA== From: Miguel Ojeda To: David Gow , Brendan Higgins , Miguel Ojeda , Wedson Almeida Filho , Alex Gaynor Cc: Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Alice Ryhl , Andreas Hindborg , kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Martin Rodriguez Reboredo Subject: [PATCH v2 4/7] rust: sync: make doctests compilable/testable Date: Tue, 18 Jul 2023 07:27:49 +0200 Message-ID: <20230718052752.1045248-5-ojeda@kernel.org> In-Reply-To: <20230718052752.1045248-1-ojeda@kernel.org> References: <20230718052752.1045248-1-ojeda@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,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 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. Reviewed-by: Martin Rodriguez Reboredo Reviewed-by: Björn Roy Baron Reviewed-by: Alice Ryhl Reviewed-by: David Gow 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(-) 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 the memory is freed. +/// # Ok::<(), Error>(()) /// ``` /// /// Using `Arc` as the type of `self`: @@ -98,6 +99,7 @@ /// let obj = 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 = 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 = 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/spinlock.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 -- 2.41.0