#[input]Expand description
Defines a mutable input to a Salsa database.
Each constructed input has a distinct identity that remains stable when its fields are changed. Reading a field records a dependency on that field; setting it invalidates queries that read it.
The macro replaces a named-field struct with a compact, Copy Salsa ID and generates a
constructor, a builder, and getter and setter methods for every field.
See input structs in the salsa crate documentation for their identity, field-level
dependencies, and lifecycle.
The annotated item must be a struct with named fields and no generic parameters.
§Options
Options are comma-separated inside the attribute:
constructor = IDENTrenames the generated constructor fromnewtoIDENT.debugimplementsDebugusing the field values when a database is attached to the current thread. The generateddefault_debug_fmtmethod can also be called from a manualDebugimplementation.singletonpermits only one instance of this input type in a database and generatestry_get(db)andget(db)methods for retrieving it.heap_size = PATHrecords heap use for Salsa’s unstable memory-usage reporting.PATHmust accept a reference to the tuple of all fields and return its heap allocation size in bytes.persistenables persistent caching when Salsa’spersistencefeature is enabled. Fields are serialized as a tuple withserdeby default.persist(serialize = PATH, deserialize = PATH)enables persistence with custom tuple serialization functions. Either path may be omitted to use the correspondingserdeimplementation.
§Field attributes
Every field generates getter and setter methods with the same name and visibility as the field. These helper attributes configure those methods:
#[returns(MODE)]selects how the getter returns the field.ref(the default) returns&FieldTy;clonereturns an ownedFieldTyusingClone;copyreturns an ownedFieldTyusingCopy; andderefusesDerefto return&<FieldTy as Deref>::Target.as_refandas_derefusesalsa::SalsaAsRefandsalsa::SalsaAsDerefto return borrowed forms such asOption<&T>andOption<&T::Target>. Every borrowed result is tied to the database borrow.#[get(IDENT)]renames the generated getter.#[set(IDENT)]renames the generated setter.#[default]initializes the field withDefault::default, omits it from the constructor’s arguments, and adds a builder method for overriding the default.
Input fields do not support #[salsa_value(...)]. Input field types are stored without database
lifetime rebinding, so neither conditional nor unconditional retention proofs apply.
Other attributes, including documentation and lint attributes, are copied to the generated getter.