Re: [PATCH v3 4/4] rust: str: implement `Borrow` and `BorrowMut` for `CString`
From: Miguel Ojeda
Date: Sun Jun 15 2025 - 09:57:54 EST
On Sun, Jun 15, 2025 at 3:48 PM Alexandre Courbot <acourbot@xxxxxxxxxx> wrote:
>
> I thought I could get away with it since it is in a test, and clippy
> does not seem to complain about it, but...
Hmm... It should:
error: unsafe block missing a safety comment
--> rust/doctests_kernel_generated.rs:7973:24
|
7973 | let foo_borrowed = Foo(unsafe {
CStr::from_bytes_with_nul_unchecked_mut(&mut str_data) });
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Do you have the doctests enabled? i.e. CONFIG_RUST_KERNEL_DOCTESTS=y
> ... as penance (and for symmetry with `from_bytes_with_nul`), let me
> implement that so we don't need a safety block at all. :)
:)
Cheers,
Miguel