Skip to main content

fold_attr_name

Function fold_attr_name 

Source
pub fn fold_attr_name(attr: &Attr) -> Option<String>
Expand description

Constant-fold an attribute-path component, per the rule on AttrKey. The TEXT-level half of fold_attr: the static name an attribute folds to, or None if it is genuinely dynamic.

Split out because [needs_plan] runs on every attribute of every attrset in every parsed file just to decide whether a plan is needed, and interning there costs a String allocation plus a hash into the intern table per attribute — measured as the dominant parse-time cost of this pass. This borrows the token’s text instead.

fold_attr is defined in terms of this, so the fold rule still has exactly ONE implementation.