Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp1934869rdh; Sat, 25 Nov 2023 07:39:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IGnYYhfh3A4cxnJ05rP5WSJIqYm6zmBC7JUwH9/IsQJ3tHWShloHAeOR4LdyRKPot4royAr X-Received: by 2002:a05:6e02:1a28:b0:35b:1108:d84 with SMTP id g8-20020a056e021a2800b0035b11080d84mr9109277ile.17.1700926784353; Sat, 25 Nov 2023 07:39:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700926784; cv=none; d=google.com; s=arc-20160816; b=R22pVWoyihTfcyUsMFnVPmGpCgmevYlWWvgMgrBqdWjNYZHzTeebbyKx41jWMVLHd+ ZpJjJOhwOzbkr+9h/SHoKsiWDlcvDXWNg7J2PL9fp9sY/KfY5fP49xZivkYxMBQBcgoF 2Pxf2tRA+0lxa4gVvmKXP/21m5K47oeIkytUzM6ciFmZWdTcY6Z8s1tCC+VlprkBaVkw PavCLzDayfP2TzWVIDuVctzKdHzNLF5/23YgpF6S2wX5NzX3fsX4KUcpy/5xDyfSZTI3 RvKDjolY5IEgM00GpRMlCdlSjyYtPu5xumbiLU0CsHfHTwDRtPl6sdx2tRAhNVnWPI+u 9gpA== 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=Kz2T8+59cYjJd++rzjqYUDUtJC+blHipACJHnv+d/Qk=; fh=k+PGXO67taJuvXZQgEjpG6YF/ZKxNCNQmaSddsvAWXI=; b=0DTAA2g7/N42dXXIU+KmVhmOIG049tsWp7GyHrFkvHUih+7Ist2c7ZmpH4uJZk5RuQ RWHnrVyxAKapTJEbdKXOBgIunjmdHCRY7TKJF2o1l6eH7HrorkgzdJtHGUNuYnXTh5pa 6sO4PmnDO0AVLK56E7kYffbBxWEWtEZJ1f/+UTGdRJ6wxytfUDBnC+47CR0+z3UakGU7 x/e8znQZLJvmqKnu9XTOG0VlC2Q/zeDtZBrDvJPaxf03bcY7/WF9t1Xk1M+HYDHOUBtI 33YTFxKl3U7GGUTZdNaCJonXgS6LRgoheH0BNS2eBOeZ9r+LNdhnsdVsIb/geYG1lXH7 Ouog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@proton.me header.s=pf7ord5zsjfgpoi3hkrv27egte.protonmail header.b=BTBwkG5v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id z18-20020a056a001d9200b006cbf70da0bbsi3910194pfw.54.2023.11.25.07.39.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Nov 2023 07:39:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@proton.me header.s=pf7ord5zsjfgpoi3hkrv27egte.protonmail header.b=BTBwkG5v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 4F8F38020907; Sat, 25 Nov 2023 07:39:41 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232139AbjKYPj0 (ORCPT + 99 others); Sat, 25 Nov 2023 10:39:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230030AbjKYPjZ (ORCPT ); Sat, 25 Nov 2023 10:39:25 -0500 Received: from mail-40133.protonmail.ch (mail-40133.protonmail.ch [185.70.40.133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 615B1FD; Sat, 25 Nov 2023 07:39:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=pf7ord5zsjfgpoi3hkrv27egte.protonmail; t=1700926768; x=1701185968; bh=Kz2T8+59cYjJd++rzjqYUDUtJC+blHipACJHnv+d/Qk=; 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=BTBwkG5vnt6MhOLd0vLxgWbJKacoreT0WcfZNBnO/0CszCR3s36clhfCLzhDGCBqD mKw6x4pctdXmkdWOf0CIHhZ5Os5fu5N9vYPgOyfMyyWr9I6N8OeO/66kyZNjYkhjtR jbObaAmBPRYIeLlncHbAELLhiiROpaHW+GJAvG1KzL7zsZYzqoT6+20KkGOQXkU7nw iTR7XGqFOum2H8aohVYeMHM1DOOBHjHXcRes8DajkP9bbKAtyvSKtSdWStkuxfdGjx Jl5RYpGKKmBxXyrQb70XtFfH7crcALCEs8KmDpo6ic/Xynintdy3GjorP1Lh4Lox7B 3MdhXTeqelnIg== Date: Sat, 25 Nov 2023 15:39:09 +0000 To: Jarkko Sakkinen , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?utf-8?Q?Bj=C3=B6rn_Roy_Baron?= , Andreas Hindborg , Alice Ryhl , Martin Rodriguez Reboredo , Asahi Lina From: Benno Lossin Cc: Sumera Priyadarsini , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3] rust: macros: `parse_generics` add `decl_generics` Message-ID: <84da128f-17b3-4193-8389-176a8c961d64@proton.me> In-Reply-To: References: <20231125125024.1235933-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.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.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 (howler.vger.email [0.0.0.0]); Sat, 25 Nov 2023 07:39:41 -0800 (PST) On 25.11.23 14:39, Jarkko Sakkinen wrote: > Sorry, just went through my eyes, hope you don't mind I nitpick > a bit. And maybe learn a bit in the process. >=20 > On Sat, 2023-11-25 at 12:50 +0000, Benno Lossin wrote: >> When parsing generics of a type definition, default values can be >> specified. This syntax is however only available on type definitions >> and >> not e.g. impl blocks. >=20 > Is "impl block" equivalent to a trait implementation? Maybe then just > write in better English "trait implementation? Would be IMHO better > to use commonly know terminology here. "impl block" refers to the syntactic item of Implementation [1]. It might be a trait implementation, or an inherent implementation. To me "impl block" is known terminology. [1]: https://doc.rust-lang.org/stable/reference/items/implementations.html > Also for any commit, including any Rust commit. "When parsing" does > not map to anything concrete. There always should be a concrete > scenario where the parser its used. Especially since Rust is a new > thing in the kernel, these commits should really have more in-depth > information of the context. This commit is tagged `rust: macros:`, which means that it affects the proc macros. So when I wrote "When parsing", I meant "When parsing Rust code in proc macros". I will change this for v2. > I neither really grasped why trait implementations (if that is meant > by "impl block") not having this support connects to the code change. > Maybe just say that this patch adds the support and drop the whole > story about traits. It is sort of unnecessary context. Rust does not syntactically support writing impl Foo { } This is because it does not make sense. The syntax `=3D 0` only makes sense on type definitions: struct Foo { } Because then you can just write `Foo` and it will be the same type as `Foo<0>`. > Finally, why this change is needed? Any commit should have existential > reason why it exists. So what will happen if "decl_generics" is not > taken to the upstream kernel? How does it make life more difficult? > You should be able to answer to this (in the commit message). Does this explain it?: In order to allow `#[pin_data]` on structs with default values for const generic parameters, the `#[pin_data]` macro needs to parse them and have access to the generics as they are written on the type definition. This commit adds support for parsing them to the already present generics parsing code in the macros crate. >> parameters. This patch also changes how `impl_generics` are made up, >> as >> these should be used with `impl<$impl_generics>`, they will omit the >> default values. >=20 > What is decl_generics and what are the other _generics variables? > This lacks explanation what sort of change is implemented and why. The terms `impl_generics` and `ty_generics` are taken from [2]. This patch adds a third kind which also contains any default values of const generic parameters. I named them `decl_generics`, because they only appear on type declarations. [2]: https://docs.rs/syn/latest/syn/struct.Generics.html#method.split_for_i= mpl --=20 Cheers, Benno