Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: use &'db in tracked struct declaration for return_ref #582

Open
nikomatsakis opened this issue Sep 28, 2024 · 0 comments
Open
Labels
bikeshed 🚴‍♀️ Debating API details and the like rfc Active discussion about a possible future feature
Milestone

Comments

@nikomatsakis
Copy link
Member

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.

@nikomatsakis nikomatsakis added rfc Active discussion about a possible future feature bikeshed 🚴‍♀️ Debating API details and the like labels Sep 28, 2024
@nikomatsakis nikomatsakis added this to the Salsa 3.0 milestone Sep 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bikeshed 🚴‍♀️ Debating API details and the like rfc Active discussion about a possible future feature
Projects
None yet
Development

No branches or pull requests

1 participant