public inbox for rust-for-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Boqun Feng <boqun.feng@gmail.com>
To: jos <dev.json2@gmail.com>
Cc: "Miguel Ojeda" <miguel.ojeda.sandonis@gmail.com>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Alex Gaynor" <alex.gaynor@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <benno.lossin@proton.me>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	rust-for-linux@vger.kernel.org, boris.chen.czy@gmail.com
Subject: Re: [PATCH v4] rust: sync: add #[must_use] to Lock::try_lock
Date: Wed, 11 Dec 2024 10:57:51 -0800	[thread overview]
Message-ID: <Z1ngrwGgJdg_mSFL@tardis.local> (raw)
In-Reply-To: <CAOJvc-aJJoUh-YSNwWX21vT4O8tuLSOVb10w=WUV7cFcPJvf9g@mail.gmail.com>

On Wed, Dec 11, 2024 at 09:05:32AM -0800, jos wrote:
> > Can't we use the same warning message as Guard?
> 
> > #[must_use = "the lock unlocks immediately when the guard is unused"]
> 
> That is what I originally had in my first patch and how I understood
> the annotation should be phrased, but @Boqun Feng maybe you can chime
> in with your input?
> 

Hmm... I think it was a mis-communication. In the v1, you said "..but it
currently does not issue a warning if the return value is unused. This
could result in the lock being unlocked immediately.." I thought "This"
means "not having `#[must_use]`", but you probably meant "not using the
value"? My comment is more to that commit log instead of the warning
message in the `#[must_use = ...]` block.

Anyway, I think the warning message in your v1 works for me. Again, to
be clear, my concern was on the commit log then. Hope it clarifies
things.

Regards,
Boqun

> >> +    /// Note that `T` is `#[must_use]` but `Option<T>` is not.
> >
> > Should this be a comment, i.e. `//`, rather than part of the documentation?
> 
> Agreed, after reading more documentation conventions
> (https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md),
> this should not be part of the rustdocs.
> 
> > I would also reword to explain the "what", not just "why", e.g. something like:
> >
> >    // `Option<T>` is not `#[must_use]` even if `T` is, thus the
> > attribute is needed here.
> 
> Thank you for the insight, I can see how there is missing clarity in
> the current comment, will update in the next patch.
> 
> Thanks,
> Jason
> 
> 
> On Wed, Dec 11, 2024 at 1:45 AM Miguel Ojeda
> <miguel.ojeda.sandonis@gmail.com> wrote:
> >
> > On Wed, Dec 11, 2024 at 3:05 AM Jason Devers <dev.json2@gmail.com> wrote:
> > >
> > > +    /// Note that `T` is `#[must_use]` but `Option<T>` is not.
> >
> > Should this be a comment, i.e. `//`, rather than part of the documentation?
> >
> > I would also reword to explain the "what", not just "why", e.g. something like:
> >
> >     // `Option<T>` is not `#[must_use]` even if `T` is, thus the
> > attribute is needed here.
> >
> > Cheers,
> > Miguel

  reply	other threads:[~2024-12-11 18:57 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-08 18:48 [PATCH] rust: sync: add #[must_use] to Lock::try_lock Jason Devers
2024-12-08 19:11 ` Boqun Feng
     [not found]   ` <CAOJvc-bi6ym6ZMAbDSh4H_L6LQXoTs8oNY07SZ1crzXxY9BodQ@mail.gmail.com>
2024-12-08 19:43     ` jos
2024-12-08 20:02     ` Boqun Feng
2024-12-08 20:50       ` Jason Devers
2024-12-08 21:57         ` Tamir Duberstein
2024-12-08 22:09           ` jos
2024-12-08 22:26             ` Jason Devers
2024-12-09 11:57               ` Miguel Ojeda
2024-12-09 17:09                 ` jos
2024-12-11  2:05             ` [PATCH v4] " Jason Devers
2024-12-11  9:17               ` Alice Ryhl
2024-12-11  9:45               ` Miguel Ojeda
2024-12-11 17:05                 ` jos
2024-12-11 18:57                   ` Boqun Feng [this message]
2024-12-12  3:11             ` [PATCH v5] " Jason Devers
2024-12-12 11:25               ` Miguel Ojeda
2024-12-12 15:47             ` [PATCH v6] " Jason Devers
2024-12-15 20:05               ` Boqun Feng
2025-01-09 13:05               ` Alice Ryhl
2025-01-15 18:12                 ` Boqun Feng
2024-12-08 21:28     ` [PATCH] " Miguel Ojeda
2024-12-09  7:11 ` Alice Ryhl

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=Z1ngrwGgJdg_mSFL@tardis.local \
    --to=boqun.feng@gmail.com \
    --cc=a.hindborg@kernel.org \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=benno.lossin@proton.me \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boris.chen.czy@gmail.com \
    --cc=dev.json2@gmail.com \
    --cc=gary@garyguo.net \
    --cc=miguel.ojeda.sandonis@gmail.com \
    --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