From: "Gary Guo" <gary@garyguo.net>
To: "Joel Fernandes" <joelagnelf@nvidia.com>,
"Boqun Feng" <boqun.feng@gmail.com>
Cc: <linux-kernel@vger.kernel.org>, <rust-for-linux@vger.kernel.org>,
<rcu@vger.kernel.org>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Miguel Ojeda" <ojeda@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Paul E. McKenney" <paulmck@kernel.org>,
"Frederic Weisbecker" <frederic@kernel.org>,
"Neeraj Upadhyay" <neeraj.upadhyay@kernel.org>,
"Josh Triplett" <josh@joshtriplett.org>,
"Uladzislau Rezki" <urezki@gmail.com>,
"Steven Rostedt" <rostedt@goodmis.org>,
"Mathieu Desnoyers" <mathieu.desnoyers@efficios.com>,
"Lai Jiangshan" <jiangshanlai@gmail.com>,
"Tamir Duberstein" <tamird@kernel.org>
Subject: Re: [RFC PATCH 0/7] Introduce HasField infrastructure
Date: Fri, 27 Feb 2026 15:00:48 +0000 [thread overview]
Message-ID: <DGPU1OF7TWG0.3EW2BO61C27C6@garyguo.net> (raw)
In-Reply-To: <7400643A-02A9-4FF4-92D4-3F94F868B789@nvidia.com>
On Tue Feb 17, 2026 at 1:21 AM GMT, Joel Fernandes wrote:
> On Wed, 28 Jan 2026 13:53:23 -0800, Boqun Feng wrote:
>> Therefore here is the effort to unify them into a proc-macro based
>> solution. Field and HasField traits are introduced to generify the
>> "Has A" relationship, and a derive macro #[derive(HasField)] is also
>> added to support automatically implementing HasField trait.
>
> Hi Boqun,
>
> One naming concern: the #[field] attribute feels ambiguous since in
> Rust every struct member is already called a "field." When reading:
>
> #[derive(HasField)]
> struct MyStruct {
> value: i32,
> #[field]
> work: Work<MyStruct>,
> }
>
> it's not immediately obvious why "work" gets #[field] but "value"
> does not, as both are struct fields.
>
> Would something like #[project] be clearer?
>
> Similarly, HasField could become HasProjection or ProjectField to
> better distinguish the trait's purpose from the general concept of fields.
This is not just for projection, but to establish has-a relation. A struct can
project into any of its fields, but for work/hrtimer use cases, it needs to be
able to find a specific field.
If we want a different name then I'd suggest `#[has]`.
Best,
Gary
prev parent reply other threads:[~2026-02-27 15:00 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-28 21:53 [RFC PATCH 0/7] Introduce HasField infrastructure Boqun Feng
2026-01-28 21:53 ` [RFC PATCH 1/7] rust: types: Introduce HasField trait and derive macro Boqun Feng
2026-01-28 21:53 ` [RFC PATCH 2/7] rust: time: hrtimer: Make `HasField` a super-trait of `HasHrTimer` Boqun Feng
2026-01-28 21:53 ` [RFC PATCH 3/7] rust: workqueue: Add HasField support for Work Boqun Feng
2026-01-28 21:53 ` [RFC PATCH 4/7] drivers: android: binder: Replace `impl_has_work!` with `#[derive(HasField)]` Boqun Feng
2026-01-28 21:53 ` [RFC PATCH 5/7] rust: sync: Completion: " Boqun Feng
2026-01-28 21:53 ` [RFC PATCH 6/7] rust: work: Remove `impl_has_work!` Boqun Feng
2026-01-28 21:53 ` [RFC PATCH 7/7] rust: sync: rcu: Introduce RcuHead Boqun Feng
2026-02-04 14:20 ` [RFC PATCH 0/7] Introduce HasField infrastructure Gary Guo
2026-02-05 20:47 ` Boqun Feng
2026-02-17 1:21 ` Joel Fernandes
2026-02-27 15:00 ` Gary Guo [this message]
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=DGPU1OF7TWG0.3EW2BO61C27C6@garyguo.net \
--to=gary@garyguo.net \
--cc=a.hindborg@kernel.org \
--cc=aliceryhl@google.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@kernel.org \
--cc=frederic@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=jiangshanlai@gmail.com \
--cc=joelagnelf@nvidia.com \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=neeraj.upadhyay@kernel.org \
--cc=ojeda@kernel.org \
--cc=paulmck@kernel.org \
--cc=rcu@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=urezki@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.