Thread (21 messages) 21 messages, 4 authors, 2026-02-24

Re: [PATCH v15 9/9] rust: page: add `from_raw()`

From: Miguel Ojeda <hidden>
Date: 2026-02-20 17:34:03
Also in: dri-devel, linux-block, linux-fsdevel, linux-mm, linux-pci, linux-pm, lkml, rust-for-linux

On Fri, Feb 20, 2026 at 10:52 AM Andreas Hindborg [off-list ref] wrote:
+    /// Create a `&Page` from a raw `struct page` pointer
Please end sentences with a period.
+        // SAFETY: By function safety requirements, ptr is not null and is
Please use Markdown in comments: `ptr`.
+    /// `ptr` must be valid for use as a reference for the duration of `'a`.
Since we will likely try to starting introducing at least a subset of
the Safety Standard soon, we should try to use standard terms.

So I think this "valid for use as a reference" is not an established
one, no? Isn't "convertible to a shared reference" the official term?

  https://doc.rust-lang.org/std/ptr/index.html#pointer-to-reference-conversion

In fact, I see `as_ref_unchecked()` and `as_mut_unchecked()` just got
stabilized for 1.95.0, so we should probably starting using those were
applicable as we bump the minimum, but we should probably use already
a similar wording as the standard library for the safety section and
the comment:

  "`ptr` must be [convertible to a reference](...)."

where the term is a link to that section. Cc'ing Benno.

I have created a (future) issue for that:

  https://github.com/Rust-for-Linux/linux/issues/1225

Cc'ing Tamir since this is close to the cast work, so it may interest
him as well.

Cheers,
Miguel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help