public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: rust: sync: lock: Add Lock::get_mut_pinned()
Date: Thu, 04 Jun 2026 16:11:03 +1000	[thread overview]
Message-ID: <review-patch1-20260529173137.303717-2-lyude@redhat.com> (raw)
In-Reply-To: <20260529173137.303717-2-lyude@redhat.com>

Patch Review

**Correctness: Good.** The implementation is sound.

The method provides `Pin<&mut T>` from `Pin<&mut Lock<T, B>>` without acquiring the lock, which is safe because `&mut` guarantees exclusive access. This mirrors `std::sync::Mutex::get_mut()` from the Rust stdlib.

```rust
pub fn get_mut_pinned(self: Pin<&mut Self>) -> Pin<&mut T> {
    // SAFETY: We return a pinned T, ensuring we don't move T.
    unsafe { self.map_unchecked_mut(|data| data.data.get_mut()) }
}
```

The safety of `map_unchecked_mut` relies on the returned reference pointing to structurally pinned data. Since `data: UnsafeCell<T>` is `#[pin]` in the `Lock` struct definition (line 119 of `lock.rs`), this is correct.

**Minor issues:**

1. **Commit message says "These two functions"** but only one function (`get_mut_pinned`) is added. Likely a leftover from an earlier revision:

   > These two functions are inspired by the Rust stdlib equivalent

2. **`#[inline(always)]` is arguably too strong.** The method is trivial and the compiler will almost certainly inline it without the hint. `#[inline]` would suffice and avoids forcing inlining in debug builds. Very minor nit.

3. The method is placed in the `impl<T: ?Sized, B: Backend> Lock<T, B>` block, which is correct — it works for unsized types and any backend.

---

---
Generated by Claude Code Patch Reviewer

  parent reply	other threads:[~2026-06-04  6:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-29 17:30 [PATCH v2 0/2] rust: sync: Introduce LazyInit Lyude Paul
2026-05-29 17:30 ` [PATCH v2 1/2] rust: sync: lock: Add Lock::get_mut_pinned() Lyude Paul
2026-06-01  8:28   ` Alice Ryhl
2026-06-04  6:11   ` Claude Code Review Bot [this message]
2026-05-29 17:30 ` [PATCH v2 2/2] rust: sync: Introduce LazyInit Lyude Paul
2026-06-01  8:27   ` Alice Ryhl
2026-06-01 22:26     ` lyude
2026-06-04  6:11   ` Claude review: " Claude Code Review Bot
2026-06-04  6:11 ` Claude Code Review Bot
  -- strict thread matches above, loose matches on Subject: below --
2026-05-26 20:41 [PATCH 0/2] " Lyude Paul
2026-05-26 20:41 ` [PATCH 1/2] rust: sync: lock: Add Lock::get_mut_pinned() Lyude Paul
2026-05-27  4:07   ` Claude review: " Claude Code Review Bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=review-patch1-20260529173137.303717-2-lyude@redhat.com \
    --to=claude-review@example.com \
    --cc=dri-devel-reviews@example.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox