-
Notifications
You must be signed in to change notification settings - Fork 181
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
Conversation
✅ Deploy Preview for salsa-rs canceled.
|
@@ -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)) })", |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
b6e7444
to
0e616ee
Compare
CodSpeed Performance ReportMerging #927 will not alter performanceComparing Summary
|
@@ -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) { |
There was a problem hiding this comment.
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?)
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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)) })", |
There was a problem hiding this comment.
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.
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) |
I believe this broke #925 |
No description provided.