Open
Description
Salsa currently supports the #[return_ref]
declaration to tag fields whose values are expensive to clone:
#[salsa::tracked]
pub struct SymFunctionSignature<'db> {
source: SymFunction<'db>,
#[return_ref]
pub generics: Vec<SymGeneric<'db>>,
#[return_ref]
pub inputs: Vec<SymLocalVariable<'db>>,
pub output: SymTy<'db>,
}
This is fine but kinda annoying in its own way. I was wondering if we should write instead:
pub inputs: &'db Vec<SymLocalVariable<'db>>
but have that be treated specially such that when you create the struct, we "peel off" the &'db
and replace it with Vec<SymLocalVariable<'db>>
. The idea is that you are declaring the field type as it will be returned to you via an accessor, instead of the field type as it will be created -- and since we never support &'db
field types, we can instead make it require an owned value.