public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/4] rust: add `TryFrom` and `Into` derive macros
@ 2025-12-25  8:37 Jesung Yang via B4 Relay
  2025-12-25  8:37 ` [PATCH v4 1/4] rust: macros: add derive macro for `Into` Jesung Yang via B4 Relay
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Jesung Yang via B4 Relay @ 2025-12-25  8:37 UTC (permalink / raw)
  To: Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich, Alexandre Courbot
  Cc: linux-kernel, rust-for-linux, nouveau, Jesung Yang

I am resending the full series (with minor typo fixes) as Gmail
consistently dropped several patches in v3.

This patch series introduces derive macros for the `TryFrom` and `Into`
traits.

Primary updates in v3:
- Adopt `syn` for improved macro parsing.
- Allow `kernel::num::Bounded` to be specified in helper attributes,
  enabling the generation of `TryFrom` and `Into` implementations for
  types with restricted bit ranges as required by the nova-core [1].
- Add compile-time overflow assertion to ensure that enum discriminants
  fit within the types being converted to or from, preventing silent
  overflows.

Note: 1015+ insertions are purely from doctests. Most of them are kept
private to keep the public API documentation clean and simple for
users. This might not be the usual way of doing things, but for now I
don't think I have a better option. Feedback and suggestions are always
appreciated.

[1] https://lore.kernel.org/rust-for-linux/DDHU4LL4GGIY.16OJMIL7ZK58P@nvidia.com/

Signed-off-by: Jesung Yang <y.j3ms.n@gmail.com>
---
Changes in v4:
- Fix typos.
- Link to (broken) v3: https://lore.kernel.org/rust-for-linux/cover.1766544407.git.y.j3ms.n@gmail.com/

Changes in v3:
- Use the vendored `syn` and `quote` crates.
- Support `kernel::num::Bounded`.
- Add compile-time overflow assertion.
- Add a comment about `#[repr(C)]` enums.
- Drop Tested-by and Reviewed-by tags, as the code structure has
  changed substantially. (Thanks for the previous reviews and testing!)
- Link to v2: https://lore.kernel.org/rust-for-linux/cover.1755235180.git.y.j3ms.n@gmail.com/

Changes in v2 (no functional changes):
- Split the patch "rust: macros: extend custom `quote!()` macro"
  into two separate patches.
- Remove unnecessary spaces between tags.
- Use a consistent commit subject prefix: "rust: macros:".
- Add Tested-by tags.
- Link to v1: https://lore.kernel.org/rust-for-linux/cover.1754228164.git.y.j3ms.n@gmail.com/

---
Jesung Yang (4):
      rust: macros: add derive macro for `Into`
      rust: macros: add derive macro for `TryFrom`
      rust: macros: add private doctests for `Into` derive macro
      rust: macros: add private doctests for `TryFrom` derive macro

 rust/macros/convert.rs | 1546 ++++++++++++++++++++++++++++++++++++++++++++++++
 rust/macros/lib.rs     |  319 ++++++++++
 2 files changed, 1865 insertions(+)
---
base-commit: 9448598b22c50c8a5bb77a9103e2d49f134c9578
change-id: 20251225-try-from-into-macro-1665d0afcfc8

Best regards,
-- 
Jesung Yang <y.j3ms.n@gmail.com>



^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2026-01-21  3:20 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-25  8:37 [PATCH v4 0/4] rust: add `TryFrom` and `Into` derive macros Jesung Yang via B4 Relay
2025-12-25  8:37 ` [PATCH v4 1/4] rust: macros: add derive macro for `Into` Jesung Yang via B4 Relay
2025-12-25 17:40   ` Benno Lossin
2025-12-26  9:36     ` Jesung Yang
2025-12-27  4:57       ` Benno Lossin
2025-12-27 10:45         ` Jesung Yang
2025-12-27 22:25           ` Benno Lossin
2025-12-29 12:29         ` Jesung Yang
2025-12-30  9:09           ` Benno Lossin
2026-01-21  3:20             ` Jesung Yang
2025-12-25  8:37 ` [PATCH v4 2/4] rust: macros: add derive macro for `TryFrom` Jesung Yang via B4 Relay
2025-12-25 17:42   ` Benno Lossin
2025-12-25  8:37 ` [PATCH v4 3/4] rust: macros: add private doctests for `Into` derive macro Jesung Yang via B4 Relay
2025-12-25  8:37 ` [PATCH v4 4/4] rust: macros: add private doctests for `TryFrom` " Jesung Yang via B4 Relay

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox