Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp14738042rwd; Sun, 25 Jun 2023 03:35:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Ob+Tu5CYEw8+NNqhkJ0yTJhVzAlUjHc6r33Y9xImXP+MV6uxR7kPCH/xvKgcXC6J7b4RV X-Received: by 2002:a17:90a:4bc7:b0:250:2384:120d with SMTP id u7-20020a17090a4bc700b002502384120dmr24451604pjl.19.1687689316255; Sun, 25 Jun 2023 03:35:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687689316; cv=none; d=google.com; s=arc-20160816; b=aN395sESvyzcPVyE46do1Eb2DLRPquHZA3D+CojNd3fVw3YTdlF5c8IYWeE6s/LOfx F/L+0/1mRnB463epUDkOdeftJHPcYDWvOWuQ4s+Qp9G4xmypvdp8JVYFzOtVc7WKRsD6 nuH4RnAu1qlZ9bgCR3lZuPsX20OE/fsPLpkccrRgC8ERX3Zq79ODFKZAw8RY2pnivAim QupQ2Py9lB6GS3XsqkbHhUz/+9A1LUwjCpZYM59hHSbg2In3IH33wk6qsbUhYf0+axhq 8yvGaTFH9H3sHA7gWmgpV/gvNe6D4EC8e7fAW2T3PzCSXxUjxdc/zTlHYL4DenGkSPLL QGLw== 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=k39oL5YOXLn4GMRTwjuG9qX93XSq1AYvlF1Zp8zdaRY=; fh=0+2VqqQPGT1n1Rb58kmUAg8hs8KvPmndH/Ev8fylct8=; b=i/dQoLcE09+dCBXNw3DpmGkkyjycYz67f1wNw2Cgm2VpUBNZqeV+HBIT5E2bCv1DP7 NwyFx4LKXPh++eiftxKfxco2CLoZdGrYleS4BdKgNcug1TXZskfF0EY5vkRjghcJfyNl K+MNuImYEDeha+UGe53jvlRcD/td23rwH0s4Fl8+V5pw7Rsb2jm/MrkHmPh/yIkvfzr/ 1v3uVvy/VuCYrMvk8ga43IE8F2+VVLW0YMMre7hh4nnr7eCzCyS7hnpptb2K6b3FbCYH VpxduB0xaMEvwpl+q8oNXhBGbTUuw/7m01oip1n+2Fl+4ZaH+b6HNKsFa49G+XB4BE/M tYPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@proton.me header.s=protonmail header.b=D5FjEe4x; 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=proton.me Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hi24-20020a17090b30d800b002563db5c4b0si2096662pjb.184.2023.06.25.03.35.03; Sun, 25 Jun 2023 03:35:16 -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=@proton.me header.s=protonmail header.b=D5FjEe4x; 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=proton.me Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231639AbjFYKOE (ORCPT + 99 others); Sun, 25 Jun 2023 06:14:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230058AbjFYKOD (ORCPT ); Sun, 25 Jun 2023 06:14:03 -0400 Received: from mail-4322.protonmail.ch (mail-4322.protonmail.ch [185.70.43.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 016FD1B8; Sun, 25 Jun 2023 03:13:57 -0700 (PDT) Date: Sun, 25 Jun 2023 10:13:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1687688036; x=1687947236; bh=k39oL5YOXLn4GMRTwjuG9qX93XSq1AYvlF1Zp8zdaRY=; 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=D5FjEe4xr7pKYA7BZBeOjWYeIlznYW4dAI8fpszRrITkSkiPQMQhb86TEFSaAUw/w r1YWkTRg6DvGDikuWlcBUx36fTL3plzCPuYlmLJKYrn1eptMiAmyB0MbkNRJQS2XDb AIz1UyOWHUarQ2vMLuSPvRlgQqcXRKtVVWbXfHAvytZ0z13K/zfTD+FSwKlIjvt2NO hznwHDGto7i6u6oU3Mm+vkS2QmsKm7OJtxKjQtQS7Ag3FO0796Z2lcg2lb5C0XPWtQ Q3PoBK9sveUIIO6HxwSd0mOVxGPEwoXEKPSbs9Y7xGo+Hui62BnGxbqvYQsQQpEWog BYDOlK0Ug/krQ== To: Miguel Ojeda , David Gow , Brendan Higgins , Wedson Almeida Filho , Alex Gaynor From: Benno Lossin Cc: Boqun Feng , Gary Guo , =?utf-8?Q?Bj=C3=B6rn_Roy_Baron?= , 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: <4bf1311c-6a13-736c-7de5-d5027e950977@proton.me> In-Reply-To: <20230614180837.630180-2-ojeda@kernel.org> References: <20230614180837.630180-1-ojeda@kernel.org> <20230614180837.630180-2-ojeda@kernel.org> Feedback-ID: 71780778:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 On 6/14/23 20:08, Miguel Ojeda wrote: > 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 Reviewed-by: Benno Lossin --=20 Cheers, Benno > --- > 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 = and 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, si= nce `_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::M= utex, 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::M= utex, 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], > -- > 2.41.0 >=20