diff options
| author | Gary Guo <gary@garyguo.net> | 2026-07-23 19:19:44 +0100 |
|---|---|---|
| committer | Gary Guo <gary@garyguo.net> | 2026-07-27 11:52:08 +0100 |
| commit | 5bbf2b2deb94d0ef8324866d39cb5e0947ca5068 (patch) | |
| tree | c008d10f66f5d9d67098bd85cd5a0fefbb10416c /rust/kernel | |
| parent | 0c20f77a26b89bc911d31cd79f1abe1a7ae57f60 (diff) | |
rust: pin-init: internal: rework how `#[pin_data]` handles cfg
Attribute macros are invoked without cfg being resolved. This adds quite a
bit complexity to the macro because all of the macro needs to be careful to
attach necessary cfgs. This becomes especially tricky for tuple structs.
Thus, it is convenient if cfgs are all resolved like derive macros.
The most optimal way to handle this is via `TokenStream::expand_expr`, but
that is still unstable. We can also create an internal derive macro and
transform the attribute macro invocation to be derive macro, but doing
requires us to serialize all extracted information in a form of helper
attributes; it would also make it more difficult if we want to make changes
to the struct (which the self-reference feature would need).
Implement an approach where we generate two cfg-gated macro invocations
with cfg resolved within the invocation. This would mean when the loop
falls through, all field cfgs are resolved, so remove all handling of
cfg_attrs for the rest of the macro.
Signed-off-by: Gary Guo <gary@garyguo.net>
Diffstat (limited to 'rust/kernel')
0 files changed, 0 insertions, 0 deletions
