rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andreas Hindborg <a.hindborg@kernel.org>
To: "Alice Ryhl" <aliceryhl@google.com>
Cc: "Boqun Feng" <boqun.feng@gmail.com>,
	 "Dirk Behme" <dirk.behme@de.bosch.com>,
	 <rust-for-linux@vger.kernel.org>, <ojeda@kernel.org>,
	 <daniel.almeida@collabora.com>,  "Gary Guo" <gary@garyguo.net>,
	 "Trevor Gross" <tmgross@umich.edu>
Subject: Re: [PATCH v3 2/2] rust: types: `Opaque` doc: Add some destructor description
Date: Fri, 07 Mar 2025 09:22:46 +0100	[thread overview]
Message-ID: <87ldth5jxl.fsf@kernel.org> (raw)
In-Reply-To: <Z8lviMzPiMzjQIE3@google.com> (Alice Ryhl's message of "Thu, 06 Mar 2025 09:48:56 +0000")

"Alice Ryhl" <aliceryhl@google.com> writes:

> On Wed, Mar 05, 2025 at 10:07:33PM +0100, Andreas Hindborg wrote:
>> Without `Opaque` it is illegal to have aliased `&mut T`. With `Opaque`,
>> it is legal to have aliased `&mut Opaque<T>`. Or at least that is my
>> understanding.
>
> There's a really important wrinckle here. Having multiple aliasing &mut
> Opaque<T> does not trigger immediate UB, but that doesn't mean that such
> mutable references are safe to hand out to end-users of the API. The end
> user could call `swap` on the mutable references, and which would be
> really bad if it uses intrusive linked lists.
>
> I.e., you could only safely hand out Pin<&mut Opaque<T>> to the end-user
> of the API.
>
> But of course you still need the guarantee. Pin is just a library type,
> and if having a &mut T is immediate UB, then so is having a Pin<&mut T>.

Right, this is a really important caveat. Thanks.



Best regards,
Andreas Hindborg




  reply	other threads:[~2025-03-07  8:22 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <Qag_hE1Uvj0nZB8Bf_MPl4UUT5v6CzPHCzseIqIvESgDKvayvNPlhVBSSS-HVW_ubhQh1GJrGH3eU-8Fy84YOQ==@protonmail.internalid>
2025-03-05  5:34 ` [PATCH v3 1/2] rust: types: `Opaque` doc: Add some intra doc linkage Dirk Behme
2025-03-05  5:34   ` [PATCH v3 2/2] rust: types: `Opaque` doc: Add some destructor description Dirk Behme
2025-03-05  7:47     ` Andreas Hindborg
2025-03-05 15:39       ` Boqun Feng
2025-03-05 17:32         ` Andreas Hindborg
2025-03-05 18:49           ` Boqun Feng
2025-03-05 21:07             ` Andreas Hindborg
2025-03-06  6:01               ` Boqun Feng
2025-03-06  9:42                 ` Andreas Hindborg
2025-03-06 10:45                   ` Benno Lossin
2025-03-07  0:00                     ` Boqun Feng
2025-03-06  9:48               ` Alice Ryhl
2025-03-07  8:22                 ` Andreas Hindborg [this message]
2025-03-10 16:20                   ` Miguel Ojeda
2025-03-05 15:25     ` Boqun Feng
2025-03-05  7:41   ` [PATCH v3 1/2] rust: types: `Opaque` doc: Add some intra doc linkage Andreas Hindborg
2025-03-05  8:12   ` Alice Ryhl
2025-03-05  8:40   ` Fiona Behrens
2025-03-10 14:25   ` Miguel Ojeda

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=87ldth5jxl.fsf@kernel.org \
    --to=a.hindborg@kernel.org \
    --cc=aliceryhl@google.com \
    --cc=boqun.feng@gmail.com \
    --cc=daniel.almeida@collabora.com \
    --cc=dirk.behme@de.bosch.com \
    --cc=gary@garyguo.net \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    /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;
as well as URLs for NNTP newsgroup(s).