mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] rust: num: document why Integer is sealed
@ 2026-09-06  7:40 Younes Akhouayri via B4 Relay
  2026-09-06 12:46 ` Gary Guo
  2026-09-06 15:25 ` Alexandre Courbot
  0 siblings, 2 replies; 4+ messages in thread
From: Younes Akhouayri via B4 Relay @ 2026-09-06  7:40 UTC (permalink / raw)
  To: Alexandre Courbot, Yury Norov, Miguel Ojeda, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Alice Ryhl, Trevor Gross, Danilo Krummrich, Daniel Almeida,
	Tamir Duberstein, Onur Özkan
  Cc: rust-for-linux, linux-kernel, Younes Akhouayri

From: Younes Akhouayri <git@younes.io>

Bounded relies on Integer::BITS and Integer::Signedness accurately
describing the implementing type to justify unchecked operations.
The reason external implementations are prohibited is currently recorded
only in the commit history.

Document this safety requirement on Integer itself.

Suggested-by: Miguel Ojeda <ojeda@kernel.org>
Link: https://lore.kernel.org/all/CANiq72m8kycbfQ1teyne-OtB5d5TsUcX_WW0FCkWB3Ayyg-qWw@mail.gmail.com/
Signed-off-by: Younes Akhouayri <git@younes.io>
---
 rust/kernel/num.rs | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/rust/kernel/num.rs b/rust/kernel/num.rs
index de589792a77a..1d06395d3a63 100644
--- a/rust/kernel/num.rs
+++ b/rust/kernel/num.rs
@@ -20,6 +20,11 @@ pub trait Sealed {}
 }
 
 /// Describes core properties of integer types.
+///
+/// This trait is sealed because [`Bounded`] relies on [`Integer::BITS`] and
+/// [`Integer::Signedness`] accurately describing the implementing type to
+/// justify unchecked operations. An incorrect implementation could therefore
+/// make safe [`Bounded`] operations cause undefined behavior.
 pub trait Integer:
     private::Sealed
     + Sized

---
base-commit: c6709d5e14072d0e3d02f291daee46a199e5dad3
change-id: 20260906-docs-rust-num-integer-sealing-safety-3a0e2967a948

Best regards,
--  
Younes Akhouayri <git@younes.io>



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

end of thread, other threads:[~2026-09-06 15:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-06  7:40 [PATCH] rust: num: document why Integer is sealed Younes Akhouayri via B4 Relay
2026-09-06 12:46 ` Gary Guo
2026-09-06 13:00   ` Miguel Ojeda
2026-09-06 15:25 ` Alexandre Courbot

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

all inboxes | Powered by JetHome®