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

Merged
merged 4 commits into from
May 23, 2025

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 51bdd88
🔍 Latest deploy log https://app.netlify.com/projects/salsa-rs/deploys/682f4d311cf4eb00089a0ed6

Copy link

codspeed-hq bot commented May 10, 2025

CodSpeed Performance Report

Merging #859 will improve performances by 4.03%

Comparing regexident:tracked-assoc-fns (51bdd88) with master (678f51a)

Summary

⚡ 1 improvements
✅ 11 untouched benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
amortized[SupertypeInput] 3.8 µs 3.6 µs +4.03%

@Veykril
Copy link
Member

Veykril commented May 22, 2025

Needs a rebase to fix CI I believe

@regexident regexident force-pushed the tracked-assoc-fns branch from a7b34bd to 51bdd88 Compare May 22, 2025 16:13
@Veykril Veykril added this pull request to the merge queue May 23, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 23, 2025
@Veykril Veykril added this pull request to the merge queue May 23, 2025
Merged via the queue into salsa-rs:master with commit e859218 May 23, 2025
11 checks passed
@github-actions github-actions bot mentioned this pull request May 23, 2025
@regexident regexident deleted the tracked-assoc-fns branch May 23, 2025 10:41
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
2 participants