Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp324300rdg; Thu, 12 Oct 2023 06:52:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEScO0GdfPqEF9Ftzgq0ITD4EmTZfJA29Bbcith1CaMZulQ2FHp1NP2sivWKFOmyR+6YP8f X-Received: by 2002:a05:6a20:3212:b0:15d:b699:5521 with SMTP id hl18-20020a056a20321200b0015db6995521mr20071813pzc.35.1697118730901; Thu, 12 Oct 2023 06:52:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697118730; cv=none; d=google.com; s=arc-20160816; b=IxgZgfS4Tdb0zlJFWrc6KE3ud0w17HKz3ehkNzr10cu+bsOVaXLd5buFXbeJo0zNT8 TGwA5zGbAvEjD8+1YGWDyjJtffhbexD9y2MBUf6mfcjqTYUI7Pn+/US6v8g3aQ8MK4wB b3tteR8vLglhzfKF00aP0dXhGeF+TcIC7m1YeuwIVksevD8mGfe4pGykGlQXUNnu+l2o qkAtBDEICFA+jSyETPSRwow+0pLmmxsI2+TBiWE1hGXPWKYvtlVGZVQF1jxq/qnWwY/2 mX/8jUBH76/JhyLIwKzIy471U8G/5nq6Xx4XN7kBhqHznXFrbI5Hvl464ldlpwe5pUrg 2Vzw== 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 :date:dkim-signature; bh=sZo92moLqUkqI0jI/dO0Y971ELJaGFGAmjX34V13s3M=; fh=6Ryp4TGKqeDeCFkUS6UUFJ+L86GjR6Z7QEaM4Rjdqy4=; b=s5l8GeKHpedJErCz49FjeHrkh2z1NBWhesHmI7vy9D7A5D5tZRzTRpZH67EtU21flF an/seZOd2rCEwssu8ZLeoURvAd8foovpgQkkoYyPEjYkqpfYyaHwoPjnQVeUIDCAsU1s amx32qQFp6s4y2HwFX2nLMJpIowFFkm3qP2BS7kQvwRnKqMxCLH5SbsGusnXdDoy4puK rxSPZlG4pA2pXj7CZxWItVzcPSXRuSHElszW0uFLsmOagUWVsmw3IucxL8IoVYBvefdO vv8AkXvAolXEXZDz7rHy8rULwDjcerg9c0wJiuXI6zGJbE5LEmLHWTNzmbyAJzsAv1Ql XPNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@proton.me header.s=protonmail header.b=LGoqwnxG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id ls10-20020a17090b350a00b0027d1c7092c2si2321871pjb.110.2023.10.12.06.52.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 06:52:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@proton.me header.s=protonmail header.b=LGoqwnxG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 1BCA3806E5DD; Thu, 12 Oct 2023 06:52:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378198AbjJLNv4 (ORCPT + 99 others); Thu, 12 Oct 2023 09:51:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344014AbjJLNvz (ORCPT ); Thu, 12 Oct 2023 09:51:55 -0400 Received: from mail-4322.protonmail.ch (mail-4322.protonmail.ch [185.70.43.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FD80B7; Thu, 12 Oct 2023 06:51:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1697118711; x=1697377911; bh=sZo92moLqUkqI0jI/dO0Y971ELJaGFGAmjX34V13s3M=; 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=LGoqwnxGIuYi04S470BbjvsEpFTxGMwJcZodOcbmnhMjw0RlmUkpixCAFHjXnRnQC /1RAgIlquVemum5j+lEiTKz8/+dZy3RPostUAQ2jIF9V2qOGfgJ1ch1gqWpSmoeCpt 03Wce6EiJ7hRQ2XeDfIWWnZLoKc8b0N0/NGe7sLXRdPwBf1xLbEEj/7z3fyO//xVoR GU/ZD9yfMk+1bHGqFTDVNcHpGYfx1SMgqfo8fjxGnMupHsrb7f38npJrmVRG8KsPTO AqYrHnhi/GGKVscoqlWDL2wwLUZ96ncz4ieOjAYO6o+eS1zUe6lLot17ajy9Mswxpi 1U3GV4cUnoVCA== Date: Thu, 12 Oct 2023 13:51:39 +0000 To: Wedson Almeida Filho From: Benno Lossin Cc: Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?Q?Bj=C3=B6rn_Roy_Baron?= , Alice Ryhl , Andreas Hindborg , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] rust: macros: improve `#[vtable]` documentation Message-ID: <64542ca3-180a-483d-9e86-bf03f0533254@proton.me> In-Reply-To: References: <20231012132131.300014-1-benno.lossin@proton.me> 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=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 12 Oct 2023 06:52:08 -0700 (PDT) On 12.10.23 15:48, Wedson Almeida Filho wrote: > On Thu, 12 Oct 2023 at 10:22, Benno Lossin wrote= : >> + >> +/// Error message for calling a default function of a [`#[vtable]`](mac= ros::vtable) trait. >> +pub const VTABLE_DEFAULT_ERROR: &str =3D >> + "This function must not be called, see the #[vtable] documentation.= "; >> diff --git a/rust/macros/lib.rs b/rust/macros/lib.rs >> index c42105c2ff96..dab9a1080b82 100644 >> --- a/rust/macros/lib.rs >> +++ b/rust/macros/lib.rs >> @@ -87,27 +87,41 @@ pub fn module(ts: TokenStream) -> TokenStream { >> /// implementation could just return `Error::EINVAL`); Linux typically= use C >> /// `NULL` pointers to represent these functions. >> /// >> -/// This attribute is intended to close the gap. Traits can be declared= and >> -/// implemented with the `#[vtable]` attribute, and a `HAS_*` associate= d constant >> -/// will be generated for each method in the trait, indicating if the i= mplementor >> -/// has overridden a method. >> +/// This attribute closes that gap. A trait can be annotated with the `= #[vtable]` attribute. >> +/// Implementers of the trait will then also have to annotate the trait= with `#[vtable]`. This >> +/// attribute generates a `HAS_*` associated constant bool for each met= hod in the trait that is set >> +/// to true if the implementer has overridden the associated method. >> +/// >> +/// If you want to make a function optional, you must provide a default= implementation. But this >=20 > We should standardise how we write our documentation. In the `rust` > branch, we avoided using the imperative mood like you have here; the > rationale was that the documentation was describing how things > are/work, so we shouldn't be giving orders to readers (they may be > authors of traits, implementers of some vtable trait, or neither, just > someone learning about things, etc.). >=20 > In the paragraph above, you'll find an example: "Implementers of the > trait will then also have to...". >=20 > For the specific case above, I'd suggest: 'For a function to be > optional, it must have a default implementation.', or using the > passive voice, 'To make a function optional, a default implementation > must be provided'. I agree, I also think we should just fix this now, so I will send a v2. --=20 Cheers, Benno