-
Notifications
You must be signed in to change notification settings - Fork 195
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,7 +69,7 @@ impl Macro { | |
| return Ok(()); | ||
| }; | ||
|
|
||
| let self_ty = &impl_item.self_ty; | ||
| let self_ty = &*impl_item.self_ty; | ||
|
|
||
| let Some(tracked_attr_index) = fn_item.attrs.iter().position(|a| self.is_tracked_attr(a)) | ||
| else { | ||
|
|
@@ -83,11 +83,20 @@ impl Macro { | |
| let mut change = ChangeSelfPath::new(self_ty, trait_); | ||
| change.visit_impl_item_fn_mut(fn_item); | ||
|
|
||
| let salsa_tracked_attr = fn_item.attrs.remove(tracked_attr_index); | ||
| let args: FnArgs = match &salsa_tracked_attr.meta { | ||
| let mut salsa_tracked_attr = fn_item.attrs.remove(tracked_attr_index); | ||
| let mut args: FnArgs = match &salsa_tracked_attr.meta { | ||
| 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()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| } | ||
| salsa_tracked_attr.meta = syn::Meta::List(syn::MetaList { | ||
| path: salsa_tracked_attr.path().clone(), | ||
| delimiter: syn::MacroDelimiter::Paren(syn::token::Paren::default()), | ||
| tokens: quote! {#args}, | ||
| }); | ||
|
|
||
| let InnerTrait = self.hygiene.ident("InnerTrait"); | ||
| let inner_fn_name = self.hygiene.ident(&fn_item.sig.ident.to_string()); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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)) })", | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| ]"#]]); | ||
| } | ||
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-R99There 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 😅