Re: [RFC PATCH 0/7] Introduce HasField infrastructure

From: Joel Fernandes

Date: Mon Feb 16 2026 - 20:21:31 EST


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.

--
Joel Fernandes