[<prev] [next>] [day] [month] [year] [list]
Message-ID: <Zdubehd0Qsr96dgq@boqun-archlinux>
Date: Sun, 25 Feb 2024 11:56:42 -0800
From: Boqun Feng <boqun.feng@...il.com>
To: Mathys Gasnier <mathys35.gasnier@...il.com>
Cc: Alice Ryhl <aliceryhl@...gle.com>, Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>,
Wedson Almeida Filho <wedsonaf@...il.com>,
Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>,
Andreas Hindborg <a.hindborg@...sung.com>,
rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3] rust: locks: Add `get_mut` method to `Lock`
On Sun, Feb 25, 2024 at 10:21:23AM +0100, Mathys Gasnier wrote:
> Should i include this comment in this patch ?
>
My suggestion is 1) in the comment of the `get_mut()` function, mention
that "`data` is not structurally pinned, so return a `&mut T` here" and
2) in the function body of `get_mut()`, at the safety comments, you only
need to put the reasoning explaining that `self` wouldn't get moved via
the return value of `self.get_unchecked_mut()`.
With these (along with the period and newline added), it'll be good to
me.
Regards,
Boqun
> Le ven. 23 févr. 2024 à 11:49, Alice Ryhl <aliceryhl@...gle.com> a écrit :
>
> > On Fri, Feb 23, 2024 at 3:52 AM Boqun Feng <boqun.feng@...il.com> wrote:
> > > BTW, while we are at it, I think we should document the
> > > "structural/non-structural pinning" design decisions somewhere, for
> > > example in the struct definition:
> > >
> > > #[pin_data]
> > > pub struct Lock<T: ?Sized, B: Backend> {
> > > ...
> > > /// The data protected by the lock.
> > > /// This field is non-structural pinned.
> > > pub(crate) data: UnsafeCell<T>,
> > > }
> > >
> > > Thoughts? Or do we think "non-structural pinned" should be the default
> > > case so no need to document it? I want to have a clear document for each
> > > field to avoid the accidental "everyone forgets what's the decision
> > > here" ;-)
> >
> > I would normally assume that "field is not marked #[pin]" implies that
> > it's not structurally pinned. But it could still be worth to call out
> > here.
> >
> > I prefer the wording "not structurally pinnned" over "non-structural
> > pinned".
> >
> > Alice
> >
Powered by blists - more mailing lists