Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2494260rwd; Fri, 16 Jun 2023 04:37:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5bJ2aVuUsi1t1yz/8flRLAGq++n5I8ePCu4U/2aqP8Ta7l5cFFMs9MPkyR2bSoh3Ym72i/ X-Received: by 2002:a17:903:41c1:b0:1a9:8ba4:d0d3 with SMTP id u1-20020a17090341c100b001a98ba4d0d3mr1787281ple.8.1686915442554; Fri, 16 Jun 2023 04:37:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686915442; cv=none; d=google.com; s=arc-20160816; b=0GIy1MbWG8tLiyBQmRgB5jM4ehhIkH4urSkAOcfhSNL1F2cH4M0EHS26TDi4SOJKaW DfcwgqvXMWZXWK7FYjTcZ4h83vvan+bOfEBZzGxeMgQa4JqAgsTvnu1HKAEwTIClMywz z6Igdp8S7OSoI3d7YSv75uK+K2CGlo1h8XA3at6qcFfNk9TcSwGX/FLs6D2/e3YmLbWB tVHOHuweu25NJmEIdhrs8yz6tfDBUY25U9LaxvtZjH7HScHfavrvKsxDbLDW/8qpN1He QkKPENBIEaIJcSNP8WGj7RRw0SjubHhu6A5cfqiqZUvJj5F6sR3EtEWRw5O3mdFLNu8v 1GGw== 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=hwa4RzwbOoukv59i8gRCTS8obOBodrvYgH1zylyxQNs=; b=C2kNO0zevA9D2yCFslNtNE/sxxEv6cSIArBGKCxvQvKBKYNdkuNmhoiacfwHXyCCYI oxbjvwCVNiIEt4oNl6//vGyGqSG/mb5eLpcSHyuj5uTVH5Fu8eLyhOPoA8T3q0U3Ho61 ALFYIZtnD8TzTKL55B6v/TqXpdgr73lPaAUGWSVv/8hbEjn9+Astdnc2sW/HkbBntvEZ 4lgmw5RAHaUDj2+7bDiUlQVsy6Bmtv6ebpSZMYTKruYJIk7HB6XaE14SKMxbslJY/rR0 v90aSNhUwSh1tO7Eqr7Nkf5rOvc3Z9wH9oxs3/8ITknSrv3Er/v40ZytqB44jNjLUDgs 0byg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail3 header.b=GsZLeP+1; 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 l5-20020a170903120500b001b3e02ba991si8686688plh.242.2023.06.16.04.37.09; Fri, 16 Jun 2023 04:37:22 -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=GsZLeP+1; 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 S1344782AbjFPLNS (ORCPT + 99 others); Fri, 16 Jun 2023 07:13:18 -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 S1344729AbjFPLNN (ORCPT ); Fri, 16 Jun 2023 07:13:13 -0400 Received: from mail-0201.mail-europe.com (mail-0201.mail-europe.com [51.77.79.158]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01426195; Fri, 16 Jun 2023 04:13:11 -0700 (PDT) Date: Fri, 16 Jun 2023 11:12:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1686913987; x=1687173187; bh=hwa4RzwbOoukv59i8gRCTS8obOBodrvYgH1zylyxQNs=; 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=GsZLeP+1y01B8aDMn1LZl+uObnYw0SpM/hdB2CUlYMti5FJOtg6RgHMRa1MthCMLj UxqvrIKF6YURbliOf9rS2PdoVoItvbObImpKVdSB7IyI4e8maYfprk76ARJ1vg/6H2 8lVvaYyN2CXCG116DKVcra0qimAN5HKrUZJ2wDimeWn6KKkDW2PU/CQQLjvinruUX8 VnL/n02i6PSDECmElLlCrqEtMdpusXrNWG3NvEaRGl6ZXwNa8LZHky0noSbZ+VbTP6 gkU/tJ6APV4hEUewsRjCtTy2YXQ7CBGiMLFs/3Yznj2WnXk2LCCoq6Q8P3SHgwq17D RguEWvKM5KY9w== 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 1/6] rust: init: make doctests compilable/testable Message-ID: In-Reply-To: <20230614180837.630180-2-ojeda@kernel.org> References: <20230614180837.630180-1-ojeda@kernel.org> <20230614180837.630180-2-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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 ------- 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/init.rs | 25 ++++++++++++++++--------- > 1 file changed, 16 insertions(+), 9 deletions(-) >=20 > diff --git a/rust/kernel/init.rs b/rust/kernel/init.rs > index b4332a4ec1f4..1073515ed40e 100644 > --- a/rust/kernel/init.rs > +++ b/rust/kernel/init.rs > @@ -120,14 +120,23 @@ > //! `slot` gets called. > //! > //! ```rust > -//! use kernel::{prelude::*, init}; > +//! # #![allow(unreachable_pub, clippy::disallowed_names)] > +//! use kernel::{prelude::*, init, types::Opaque}; > //! use core::{ptr::addr_of_mut, marker::PhantomPinned, pin::Pin}; > //! # mod bindings { > +//! # #![allow(non_camel_case_types)] > //! # pub struct foo; > //! # pub unsafe fn init_foo(_ptr: *mut foo) {} > //! # pub unsafe fn destroy_foo(_ptr: *mut foo) {} > //! # pub unsafe fn enable_foo(_ptr: *mut foo, _flags: u32) -> i32 {= 0 } > //! # } > +//! # trait FromErrno { > +//! # fn from_errno(errno: core::ffi::c_int) -> Error { > +//! # // Dummy error that can be constructed outside the `kernel= ` crate. > +//! # Error::from(core::fmt::Error) > +//! # } > +//! # } > +//! # impl FromErrno for Error {} > //! /// # Invariants > //! /// > //! /// `foo` is always initialized > @@ -158,7 +167,7 @@ > //! if err !=3D 0 { > //! // Enabling has failed, first clean up the foo a= nd then return the error. > //! bindings::destroy_foo(Opaque::raw_get(foo)); > -//! return Err(Error::from_kernel_errno(err)); > +//! return Err(Error::from_errno(err)); > //! } > //! > //! // All fields of `RawFoo` have been initialized, sin= ce `_p` is a ZST. > @@ -226,8 +235,7 @@ > /// > /// ```rust > /// # #![allow(clippy::disallowed_names, clippy::new_ret_no_self)] > -/// # use kernel::{init, pin_init, stack_pin_init, init::*, sync::Mutex,= new_mutex}; > -/// # use macros::pin_data; > +/// # use kernel::{init, macros::pin_data, pin_init, stack_pin_init, ini= t::*, sync::Mutex, new_mutex}; > /// # use core::pin::Pin; > /// #[pin_data] > /// struct Foo { > @@ -277,7 +285,7 @@ macro_rules! stack_pin_init { > /// > /// # Examples > /// > -/// ```rust > +/// ```rust,ignore > /// # #![allow(clippy::disallowed_names, clippy::new_ret_no_self)] > /// # use kernel::{init, pin_init, stack_try_pin_init, init::*, sync::Mu= tex, new_mutex}; > /// # use macros::pin_data; > @@ -303,7 +311,7 @@ macro_rules! stack_pin_init { > /// pr_info!("a: {}", &*foo.a.lock()); > /// ``` > /// > -/// ```rust > +/// ```rust,ignore > /// # #![allow(clippy::disallowed_names, clippy::new_ret_no_self)] > /// # use kernel::{init, pin_init, stack_try_pin_init, init::*, sync::Mu= tex, new_mutex}; > /// # use macros::pin_data; > @@ -513,8 +521,7 @@ macro_rules! stack_try_pin_init { > /// For instance: > /// > /// ```rust > -/// # use kernel::pin_init; > -/// # use macros::pin_data; > +/// # use kernel::{macros::pin_data, pin_init}; > /// # use core::{ptr::addr_of_mut, marker::PhantomPinned}; > /// #[pin_data] > /// struct Buf { > @@ -841,7 +848,7 @@ macro_rules! init { > /// # Examples > /// > /// ```rust > -/// use kernel::{init::PinInit, error::Error, InPlaceInit}; > +/// use kernel::{init::{PinInit, zeroed}, error::Error}; > /// struct BigBuf { > /// big: Box<[u8; 1024 * 1024 * 1024]>, > /// small: [u8; 1024 * 1024], > --=20 > 2.41.0 Reviewed-by: Bj=C3=B6rn Roy Baron