@@ -112,7 +112,7 @@ impl ProcMacroLibraryLibloading {
112112type ProcMacroLibraryImpl = ProcMacroLibraryLibloading ;
113113
114114pub struct Expander {
115- libs : Vec < ProcMacroLibraryImpl > ,
115+ inner : ProcMacroLibraryImpl ,
116116}
117117
118118impl Expander {
@@ -125,7 +125,7 @@ impl Expander {
125125
126126 let library = ProcMacroLibraryImpl :: open ( & lib) . map_err ( |e| e. to_string ( ) ) ?;
127127
128- Ok ( Expander { libs : vec ! [ library] } )
128+ Ok ( Expander { inner : library } )
129129 }
130130
131131 pub fn expand (
@@ -141,48 +141,46 @@ impl Expander {
141141 TokenStream :: with_subtree ( attr. clone ( ) )
142142 } ) ;
143143
144- for lib in & self . libs {
145- for proc_macro in & lib. exported_macros {
146- match proc_macro {
147- bridge:: client:: ProcMacro :: CustomDerive { trait_name, client, .. }
148- if * trait_name == macro_name =>
149- {
150- let res = client. run (
151- & crate :: proc_macro:: bridge:: server:: SameThread ,
152- crate :: rustc_server:: Rustc :: default ( ) ,
153- parsed_body,
154- ) ;
155- return res. map ( |it| it. subtree ) ;
156- }
157- bridge:: client:: ProcMacro :: Bang { name, client } if * name == macro_name => {
158- let res = client. run (
159- & crate :: proc_macro:: bridge:: server:: SameThread ,
160- crate :: rustc_server:: Rustc :: default ( ) ,
161- parsed_body,
162- ) ;
163- return res. map ( |it| it. subtree ) ;
164- }
165- bridge:: client:: ProcMacro :: Attr { name, client } if * name == macro_name => {
166- let res = client. run (
167- & crate :: proc_macro:: bridge:: server:: SameThread ,
168- crate :: rustc_server:: Rustc :: default ( ) ,
169- parsed_attributes,
170- parsed_body,
171- ) ;
172- return res. map ( |it| it. subtree ) ;
173- }
174- _ => continue ,
144+ for proc_macro in & self . inner . exported_macros {
145+ match proc_macro {
146+ bridge:: client:: ProcMacro :: CustomDerive { trait_name, client, .. }
147+ if * trait_name == macro_name =>
148+ {
149+ let res = client. run (
150+ & crate :: proc_macro:: bridge:: server:: SameThread ,
151+ crate :: rustc_server:: Rustc :: default ( ) ,
152+ parsed_body,
153+ ) ;
154+ return res. map ( |it| it. subtree ) ;
155+ }
156+ bridge:: client:: ProcMacro :: Bang { name, client } if * name == macro_name => {
157+ let res = client. run (
158+ & crate :: proc_macro:: bridge:: server:: SameThread ,
159+ crate :: rustc_server:: Rustc :: default ( ) ,
160+ parsed_body,
161+ ) ;
162+ return res. map ( |it| it. subtree ) ;
163+ }
164+ bridge:: client:: ProcMacro :: Attr { name, client } if * name == macro_name => {
165+ let res = client. run (
166+ & crate :: proc_macro:: bridge:: server:: SameThread ,
167+ crate :: rustc_server:: Rustc :: default ( ) ,
168+ parsed_attributes,
169+ parsed_body,
170+ ) ;
171+ return res. map ( |it| it. subtree ) ;
175172 }
173+ _ => continue ,
176174 }
177175 }
178176
179177 Err ( bridge:: PanicMessage :: String ( "Nothing to expand" . to_string ( ) ) )
180178 }
181179
182180 pub fn list_macros ( & self ) -> Vec < ( String , ProcMacroKind ) > {
183- self . libs
181+ self . inner
182+ . exported_macros
184183 . iter ( )
185- . flat_map ( |it| & it. exported_macros )
186184 . map ( |proc_macro| match proc_macro {
187185 bridge:: client:: ProcMacro :: CustomDerive { trait_name, .. } => {
188186 ( trait_name. to_string ( ) , ProcMacroKind :: CustomDerive )
0 commit comments