File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
lang/syn/src/codegen/program Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 11use crate :: Program ;
22use heck:: SnakeCase ;
3- use quote:: quote;
3+ use quote:: { quote, quote_spanned} ;
4+ use syn:: spanned:: Spanned ;
45
56pub fn generate ( program : & Program ) -> proc_macro2:: TokenStream {
67 let mut accounts = std:: collections:: HashMap :: new ( ) ;
8+ let mut ix_spans = std:: collections:: HashMap :: new ( ) ;
79
810 // Go through instruction accounts.
911 for ix in & program. ixs {
@@ -13,6 +15,7 @@ pub fn generate(program: &Program) -> proc_macro2::TokenStream {
1315 "__client_accounts_{}" ,
1416 anchor_ident. to_string( ) . to_snake_case( )
1517 ) ;
18+ ix_spans. insert ( macro_name. clone ( ) , ix. raw_method . span ( ) ) ;
1619 accounts. insert ( macro_name, ix. cfgs . as_slice ( ) ) ;
1720 }
1821
@@ -21,7 +24,11 @@ pub fn generate(program: &Program) -> proc_macro2::TokenStream {
2124 . iter ( )
2225 . map ( |( macro_name_str, cfgs) | {
2326 let macro_name: proc_macro2:: TokenStream = macro_name_str. parse ( ) . unwrap ( ) ;
24- quote ! {
27+ let ix_span = ix_spans
28+ . get ( macro_name_str)
29+ . copied ( )
30+ . unwrap_or_else ( proc_macro2:: Span :: call_site) ;
31+ quote_spanned ! { ix_span =>
2532 #( #cfgs) *
2633 pub use crate :: #macro_name:: * ;
2734 }
You can’t perform that action at this time.
0 commit comments