* [PATCH 0/2] rust: add unsafe precondition assertions to Vec length helpers
@ 2026-09-08 8:06 JX
0 siblings, 0 replies; only message in thread
From: JX @ 2026-09-08 8:06 UTC (permalink / raw)
To: Miguel Ojeda, Danilo Krummrich
Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Alice Ryhl, Trevor Gross, Daniel Almeida,
Tamir Duberstein, Alexandre Courbot, Onur Özkan,
Lorenzo Stoakes, Vlastimil Babka, Liam R . Howlett,
Uladzislau Rezki, rust-for-linux, linux-kernel
The safety requirements of `Vec::inc_len` and `Vec::dec_len` are
currently checked with `debug_assert!`. Convert them to
`unsafe_precondition_assert!` so violations are reported consistently
with other unsafe precondition failures.
The first patch makes the no-message form of
`unsafe_precondition_assert!` usable from const functions. This is
needed by `Vec::inc_len`, which is const, and avoids runtime formatting
when the diagnostic consists only of the stringified condition.
The second patch converts both Vec length helpers.
The series has been checked with:
make rustfmtcheck
make CLIPPY=1 rust/kernel.o
make rusttest
make rustdoc
JX (2):
rust: make unsafe_precondition_assert! const compatible
rust: alloc: use unsafe_precondition_assert! in Vec length helpers
rust/kernel/alloc/kvec.rs | 7 ++++---
rust/kernel/safety.rs | 10 +++++++++-
2 files changed, 13 insertions(+), 4 deletions(-)
base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
--
2.54.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-09-08 8:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-08 8:06 [PATCH 0/2] rust: add unsafe precondition assertions to Vec length helpers JX
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).