Skip to main content

Module cfg_gates

Module cfg_gates 

Source
Expand description

Resolve cfg / cfg_attr on the members of a #[miniextendr] item before anything is generated from it.

An attribute macro receives its item unconfigured: rustc has not evaluated the gates on the itemโ€™s methods, trait items, parameters, variants or fields. Forwarding a memberโ€™s gate to some generated items is not enough, because item-wide analysis (constructor inference, S7 properties, name collisions, factor levels, R formals) and the generated R text must see the same members the compiled item has. So the macro re-enters itself on two gated copies of the item, one per value of the first member gate it finds. rustc strips the inactive copy before expanding it, so each pass resolves one gate and configurations are never enumerated. The item stays whole: splitting an impl into separately registered blocks would change constructor inference and the ownership of S7 properties.

Gates on the item itself need no re-entry: rustc evaluates them when they precede #[miniextendr], and the expansion forwards them otherwise.

Functionsยง

member_attrs ๐Ÿ”’
member_attrs_mut ๐Ÿ”’
Only called for a member member_attrs returned.
member_count ๐Ÿ”’
Number of gateable members: function parameters, impl and trait items, enum variants, struct fields.
remove_at ๐Ÿ”’
remove_member ๐Ÿ”’
select ๐Ÿ”’
Re-enter #[miniextendr(attr)] on both resolutions of the itemโ€™s first member gate, or return None when no member carries one.