pub enum AttrKey {
Static(Symbol),
Dynamic(Expr),
}Expand description
One component of an attribute path, after constant-folding.
The static/dynamic split is a constant-fold on node kind, not “quoted vs unquoted” — which is the trap that makes intuition wrong here:
a Ident -> STATIC
"a" Str, no interpolation
-> STATIC (`{ "a" = 1; a = 2; }` is a duplicate)
${"a"} Dynamic wrapping a pure Str
-> STATIC (`{ ${"a"} = 1; a = 2; }` is a duplicate)
"${"a"}" Str WITH interpolation
-> DYNAMIC (parses fine; errors only when FORCED)
${"a"+""} Dynamic wrapping a non-Str
-> DYNAMICGetting this wrong in the permissive direction turns a currently-correct
answer into a throw: { a = {p=1;}; ${"a"} = {q=2;}; } merges in nix, and
sui already agrees with it today.
Variants§
Static(Symbol)
Folded to a compile-time-known name.
Dynamic(Expr)
Genuinely dynamic — resolved, and checked for collisions, only when the enclosing attrset is FORCED. Never participates in a parse-time merge.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for AttrKey
impl !Send for AttrKey
impl !Sync for AttrKey
impl !UnwindSafe for AttrKey
impl Freeze for AttrKey
impl Unpin for AttrKey
impl UnsafeUnpin for AttrKey
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more