Skip to content

Emit self ty for query debug name of assoc function queries #927

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 1 commit into from
Jun 27, 2025

Conversation

Veykril
Copy link
Member

@Veykril Veykril commented Jun 26, 2025

No description provided.

Copy link

netlify bot commented Jun 26, 2025

Deploy Preview for salsa-rs canceled.

Name Link
🔨 Latest commit 0e616ee
🔍 Latest deploy log https://app.netlify.com/projects/salsa-rs/deploys/685d1daf89045c00086f64ac

@@ -80,6 +80,6 @@ fn debug_name() {
assert_eq!(output.field(&db), 88);
db.assert_logs(expect![[r#"
[
"salsa_event(WillExecute { database_key: tracked_trait_fn_(Id(0)) })",
"salsa_event(WillExecute { database_key: MyOutput < 'db >::tracked_trait_fn_(Id(0)) })",
Copy link
Member Author

Choose a reason for hiding this comment

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

The formatting here is a bit unfortunate, but we the only other options are to either hand format these (I'd rather not) instead of relying on stringify! behavior or pulling in something like syn pretty (forgot the exact name). I think this is fine (and either way an improvement over the status quo)

Copy link
Contributor

Choose a reason for hiding this comment

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

You mean https://github.com/dtolnay/prettyplease

I don't think it's worth the dependency, given that this is for debugging only.

@Veykril Veykril force-pushed the veykril/push-mkounqurwslo branch from b6e7444 to 0e616ee Compare June 26, 2025 10:15
Copy link

codspeed-hq bot commented Jun 26, 2025

CodSpeed Performance Report

Merging #927 will not alter performance

Comparing Veykril:veykril/push-mkounqurwslo (0e616ee) with master (0666e20)

Summary

✅ 12 untouched benchmarks

@@ -433,3 +455,82 @@ impl<A: AllowedOptions> syn::parse::Parse for Options<A> {
Ok(options)
}
}
impl<A: AllowedOptions> quote::ToTokens for Options<A> {
fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I haven't read the diff to closely but what's this used for (should it replace some existing code?)

Copy link
Member Author

Choose a reason for hiding this comment

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

This is used to inject arguments into the #[tracked] invocation supplied by the user, see https://github.com/salsa-rs/salsa/pull/927/files#diff-7091e579afd9cfe8ee883486f5951094096ebf6419e4e5fc5d1d9be926a858fdR86-R99

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, this goes beyond what I understand about macros 😅

syn::Meta::Path(..) => Default::default(),
_ => salsa_tracked_attr.parse_args()?,
};
if args.self_ty.is_none() {
// If the user did not specify a self_ty, we use the impl's self_ty
args.self_ty = Some(self_ty.clone());
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reason or use case where a user needs to provide a self type? Can you add a test for it (or remove the attribute)

Copy link
Member Author

Choose a reason for hiding this comment

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

The user isn't really supposed to use this, this is solely needed for tracked impls to pass through their self type to the assoc tracked fn so that it can adjust the debug name appropriately

@@ -80,6 +80,6 @@ fn debug_name() {
assert_eq!(output.field(&db), 88);
db.assert_logs(expect![[r#"
[
"salsa_event(WillExecute { database_key: tracked_trait_fn_(Id(0)) })",
"salsa_event(WillExecute { database_key: MyOutput < 'db >::tracked_trait_fn_(Id(0)) })",
Copy link
Contributor

Choose a reason for hiding this comment

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

You mean https://github.com/dtolnay/prettyplease

I don't think it's worth the dependency, given that this is for debugging only.

@Veykril Veykril added this pull request to the merge queue Jun 27, 2025
@Veykril
Copy link
Member Author

Veykril commented Jun 27, 2025

Will cut a new release after this merges so we can update r-a (and see if things break for us given the generation changes)

Merged via the queue into salsa-rs:master with commit f384ab5 Jun 27, 2025
12 checks passed
@Veykril Veykril deleted the veykril/push-mkounqurwslo branch June 27, 2025 09:33
This was referenced Jun 27, 2025
@MichaReiser
Copy link
Contributor

I believe this broke #925

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.

2 participants