From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 16581E9271F for ; Sat, 27 Dec 2025 22:25:36 +0000 (UTC) Received: from kara.freedesktop.org (unknown [131.252.210.166]) by gabe.freedesktop.org (Postfix) with ESMTPS id 583DA113A9B; Sat, 27 Dec 2025 22:25:36 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="AyQvmqNv"; dkim-atps=neutral Received: from kara.freedesktop.org (localhost [127.0.0.1]) by kara.freedesktop.org (Postfix) with ESMTP id 954B644C6F; Sat, 27 Dec 2025 22:17:44 +0000 (UTC) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=lists.freedesktop.org; s=20240201; t=1766873864; b=Mbq54R786MoijjMSPSYDB6WoRCT3Q5V0DYUioeksmjw/t4S1ISR3CEuWAoXHWgF1+zM9Y JI5yHXF/+3BPALCTjBP0oJ8+f1nBGAmpMc/wmmJbdYuwDQEfVOaot0yVpMLy1JJfqQczFGl hZTC4vGWZCrMlytMumopN/yDSPPDL4EJPehh/L01ruxsmW1zeCYyeK1KM/sY2DXbhv3Ov2s u1v5uH6kB2h6LBraBoWXD0Iwf75uangjMIGs2osy3pwSDf2sOJYZQw6lhk/PwmcH4BZL6uj weC0Q5+DE3+Bhl+RepSrFgQhfeg0EUEFwAum4zcSvUXJX4+1y9d3o6Zes8sQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.freedesktop.org; s=20240201; t=1766873864; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=Xy3RQdM6OLRr8Nyts+LLw5Iqr9Ocpy+EJ/pQF7/vWrU=; b=Kpen0bJEiTKmBo1ecNmIJWXFm/Ead4k/2Hf/P+bSiu9XwPAyu2zOWqUbw0OnxR3h3eyu9 uHmqv7ahh3VYZr+bUjeuOll7F0mIGunpw2VhRRafv6Gih1/6WQHEK2xGva0YP/7mzVmhz/L 3ZlDl7ukYVcV0W+vI5HtgWgjmF/pw3YI//th4650ieXEiWAB67eVga1Dy9NL6uzGP0IPI3m WYdgsRzedQr5CmQBdyRCXz97qKdeosgP6XJ9kV1xTSwl9SpFe1gIuYoB+cgIHmo2mopiaq/ SUKKbXBy3MaJpZTyqiTUOf1lcCgnNkVwunBcFlcBZ/prR3+j+TJZAqSAEmKQ== ARC-Authentication-Results: i=1; mail.freedesktop.org; dkim=pass header.d=kernel.org; arc=none (Message is not ARC signed); dmarc=pass (Used From Domain Record) header.from=kernel.org policy.dmarc=quarantine Authentication-Results: mail.freedesktop.org; dkim=pass header.d=kernel.org; arc=none (Message is not ARC signed); dmarc=pass (Used From Domain Record) header.from=kernel.org policy.dmarc=quarantine Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by kara.freedesktop.org (Postfix) with ESMTPS id 20CE9401CB for ; Sat, 27 Dec 2025 22:17:42 +0000 (UTC) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by gabe.freedesktop.org (Postfix) with ESMTPS id 876C0113A2C for ; Sat, 27 Dec 2025 22:25:33 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 8C60760010; Sat, 27 Dec 2025 22:25:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A5A6DC4CEF1; Sat, 27 Dec 2025 22:25:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1766874332; bh=ve418wM/XyEWbfmF9fZaylARcLvP8lDozBBpjRZ5o+8=; h=Date:Cc:Subject:From:To:References:In-Reply-To:From; b=AyQvmqNvp7aFQkxu9SD9KvqD0VPsY4RmdEyFYtNitIJA85tSgEOywKmb0jorw0lxS IjpVlVP9LPMRay+Sec3vC3A2AkCG8ydTk+EL7v5/Rvbgy92vXOCxmp4AnxnUzsDgcO Jf3ipoz5wiJvSNAeLP2N8LtwbR9BJHnhNVa7YBuDEXNYGFjtgZzNmQMNNpuIk8XkgL Vr6b69aJIulzkcnfZIHt2KyLLUyA7pee51MsvXVSXYIskVTmpFlkET4Oo8zsg6feEb i+ZT0v0mPlqtqFG9/Erz5tLI9V2JGKahlDqs0C3ChjjcutYSaNv+wsN5C6CwRPVFDF UnjE7r2+m4c8Q== Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Sat, 27 Dec 2025 23:25:27 +0100 Message-Id: Subject: Re: [PATCH v4 1/4] rust: macros: add derive macro for `Into` From: "Benno Lossin" To: "Jesung Yang" X-Mailer: aerc 0.21.0 References: <20251225-try-from-into-macro-v4-0-4a563d597836@gmail.com> <20251225-try-from-into-macro-v4-1-4a563d597836@gmail.com> In-Reply-To: Message-ID-Hash: 7D5HQD7P5PVGBG3CDQPFZ6CUMV3HLNB3 X-Message-ID-Hash: 7D5HQD7P5PVGBG3CDQPFZ6CUMV3HLNB3 X-MailFrom: lossin@kernel.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Miguel Ojeda , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Alexandre Courbot , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, nouveau@lists.freedesktop.org X-Mailman-Version: 3.3.8 Precedence: list List-Id: Nouveau development list Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Sat Dec 27, 2025 at 11:45 AM CET, Jesung Yang wrote: > On Sat, Dec 27, 2025 at 1:57=E2=80=AFPM Benno Lossin = wrote: >> On Fri Dec 26, 2025 at 10:36 AM CET, Jesung Yang wrote: >> > On Fri, Dec 26, 2025 at 2:40=E2=80=AFAM Benno Lossin wrote: >> >> On Thu Dec 25, 2025 at 9:37 AM CET, Jesung Yang via B4 Relay wrote: >> >> > + fn emit_overflow_assert( >> >> > + enum_ident: &Ident, >> >> > + variants: &[Ident], >> >> > + repr_ty: &syn::Path, >> >> > + input_ty: &ValidTy, >> >> > + ) -> TokenStream { >> >> >> >> I feel like we should track this via traits rather than using a const >> >> assert. That approach will require & generate much less code. >> > >> > Sorry, but could you elaborate? A small example of what you have in >> > mind would help a lot. >> >> Oh yeah sorry, I had something different in mind compared to what I'll >> describe now, but it achieves the same thing without introducing new >> traits: >> >> We have two options: >> 1) We use `>::try_from` instead of writing >> the `fits` function ourself. >> 2) We require `input_ty: From`. >> >> The first option would still check every variant and should behave the >> same as your current code. >> >> Option 2 allows us to avoid the const altogether, but requires us to >> choose the smallest integer as the representation (and if we want to be >> able to use both `i8` and `u8`, we can't). I missed this before, so >> using option 1 might be the only way to allow conversions of this kind. > > AFAIK, `>::try_from` cannot be called in > const contexts without `#![feature(const_trait_impl, const_convert)]`. > I assume we want to keep this validation at compile-time? If so, we > might need to stick with the custom `fits` check for now. Please let me > know if I misunderstood you. Oh yeah that doesn't work (yet) :( I'll take another look at the function itself then. Cheers, Benno