Skip to content

Allow creation of tracked associated functions (without self) #859

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

regexident
Copy link
Contributor

@regexident regexident commented May 10, 2025

Fixes #858 & #585.

This allows users to annotate impl blocks with #[salsa::tracked] and then create tracked associated type-level functions by marking individual functions with #[salsa::tracked].

Note this requires your code that looks like:

#[salsa::tracked]
impl MyOutput {
    #[salsa::tracked]
    fn tracked_fn(db: &dyn Db, input: MyInput) -> MyOutput {
        MyOutput::new(db, input.field(db) * 2)
    }
}

You get an error if you annotate an associated function with #[salsa::tracked] but forget to mark the impl block.

Copy link

netlify bot commented May 10, 2025

Deploy Preview for salsa-rs canceled.

Name Link
🔨 Latest commit a7b34bd
🔍 Latest deploy log https://app.netlify.com/projects/salsa-rs/deploys/68261f643a8ac700086761f7

Copy link

codspeed-hq bot commented May 10, 2025

CodSpeed Performance Report

Merging #859 will not alter performance

Comparing regexident:tracked-assoc-fns (a7b34bd) with master (247a9df)

Summary

✅ 12 untouched benchmarks

(since every method is an associated function, but not every associated function is a method)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support tracked associated functions
1 participant