Re: [PATCH RFC 0/2] rust: sync: create lock class using `#[track_caller]`

From: lyude

Date: Tue Jul 07 2026 - 17:06:09 EST


On Sat, 2026-07-04 at 18:46 +0100, Gary Guo wrote:
>
> It's certainly possible to give explicit names (this is what patch
> 1/2's
> "new_with_name" function is for). To mandate names being provided we
> just need
> to remove the constructor function without the name. That said, I am
> not sure
> that we want everyone to explicitly give names. Especially for types
> like
> delayed_work where it needs two lock classes and names, it's somewhat
> leaky abstraction if the constructor asks to user to provide a name
> for its
> work completion and a name for its timer (as it's not possible to
> concat strings
> without allocation without using macros).
>

I think it's also worth mentioning too: this doesn't really make that
much of a difference compared to how lockdep names are currently
generated in the upstream kernel with Rust. If anything, this sort of
change would make it a lot easier to actually improve the auto-
generated names we come up with in the future.

> Best,
> Gary