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

Emit struct in #[tracked] fn last for better IDE support #612

Merged
merged 2 commits into from
Nov 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions components/salsa-macro-rules/src/setup_tracked_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@ macro_rules! setup_tracked_fn {
$inner:ident,
]
) => {
#[allow(non_camel_case_types)]
$vis struct $fn_name {
_priv: std::convert::Infallible,
}

// Suppress this clippy lint because we sometimes require `'db` where the ordinary Rust rules would not.
#[allow(clippy::needless_lifetimes)]
$(#[$attr])*
Expand Down Expand Up @@ -288,5 +283,12 @@ macro_rules! setup_tracked_fn {
}
})
}
// The struct needs be last in the macro expansion in order to make the tracked
// function's ident be identified as a function, not a struct, during semantic highlighting.
// for more details, see https://github.com/salsa-rs/salsa/pull/612.
#[allow(non_camel_case_types)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would consider adding a comment explaining the importance of why this has to come last to avoid accidentally breaking this in the future.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a description; I'll land this change as Lukas is on vacation for the next 3 weeks.

$vis struct $fn_name {
_priv: std::convert::Infallible,
}
};
}
Loading