Re: [PATCH v1 1/2] rust: Add support for calling a function exactly once

Boqun Feng
2025-11-10T16:55:08Z

On Mon, Nov 10, 2025 at 05:37:17PM +0100, Miguel Ojeda wrote:
> On Mon, Nov 10, 2025 at 5:15 PM Boqun Feng <boqun.feng@gmail.com> wrote:
> >
> > // ORDERING: Relaxed is fine because we don't expect
> > // synchronization here.
> > let old = self.init.xchg(1, Relaxed);
>
> Meta-comment: I like these `// ORDERING: ...` comments -- I will add
> them to the other ones we are getting implemented in Clippy (`//
> PANIC: ...`, `// CAST: ...`), i.e. we can request them when calling
> certain methods.
>

That's very good.

We do have a soft(?) rule about commenting the usage of memory barriers
in kernel. So enforcing "ORDERING" comments seems good to me.

Regards,
Boqun

> Well, unless you think it is a bad idea for some reason -- I guess in
> some cases they may be obvious, but just like `unsafe`, even "obvious"
> ones may not be as obvious as one may initially think... :)
>
> Cheers,
> Miguel