@@ -72,6 +72,16 @@ pub struct PanicMessage(pub String);
7272
7373#[ derive( Debug , Serialize , Deserialize ) ]
7474pub struct ExpandMacro {
75+ pub lib : Utf8PathBuf ,
76+ /// Environment variables to set during macro expansion.
77+ pub env : Vec < ( String , String ) > ,
78+ pub current_dir : Option < String > ,
79+ #[ serde( flatten) ]
80+ pub data : ExpandMacroData ,
81+ }
82+
83+ #[ derive( Debug , Serialize , Deserialize ) ]
84+ pub struct ExpandMacroData {
7585 /// Argument of macro call.
7686 ///
7787 /// In custom derive this will be a struct or enum; in attribute-like macro - underlying
@@ -86,13 +96,6 @@ pub struct ExpandMacro {
8696
8797 /// Possible attributes for the attribute-like macros.
8898 pub attributes : Option < FlatTree > ,
89-
90- pub lib : Utf8PathBuf ,
91-
92- /// Environment variables to set during macro expansion.
93- pub env : Vec < ( String , String ) > ,
94-
95- pub current_dir : Option < String > ,
9699 /// marker for serde skip stuff
97100 #[ serde( skip_serializing_if = "ExpnGlobals::skip_serializing_if" ) ]
98101 #[ serde( default ) ]
@@ -268,25 +271,30 @@ mod tests {
268271 let tt = fixture_token_tree ( ) ;
269272 let mut span_data_table = Default :: default ( ) ;
270273 let task = ExpandMacro {
271- macro_body : FlatTree :: new ( & tt, CURRENT_API_VERSION , & mut span_data_table) ,
272- macro_name : Default :: default ( ) ,
273- attributes : None ,
274+ data : ExpandMacroData {
275+ macro_body : FlatTree :: new ( & tt, CURRENT_API_VERSION , & mut span_data_table) ,
276+ macro_name : Default :: default ( ) ,
277+ attributes : None ,
278+ has_global_spans : ExpnGlobals {
279+ serialize : true ,
280+ def_site : 0 ,
281+ call_site : 0 ,
282+ mixed_site : 0 ,
283+ } ,
284+ span_data_table : Vec :: new ( ) ,
285+ } ,
274286 lib : Utf8PathBuf :: from_path_buf ( std:: env:: current_dir ( ) . unwrap ( ) ) . unwrap ( ) ,
275287 env : Default :: default ( ) ,
276288 current_dir : Default :: default ( ) ,
277- has_global_spans : ExpnGlobals {
278- serialize : true ,
279- def_site : 0 ,
280- call_site : 0 ,
281- mixed_site : 0 ,
282- } ,
283- span_data_table : Vec :: new ( ) ,
284289 } ;
285290
286291 let json = serde_json:: to_string ( & task) . unwrap ( ) ;
287292 // println!("{}", json);
288293 let back: ExpandMacro = serde_json:: from_str ( & json) . unwrap ( ) ;
289294
290- assert_eq ! ( tt, back. macro_body. to_subtree_resolved( CURRENT_API_VERSION , & span_data_table) ) ;
295+ assert_eq ! (
296+ tt,
297+ back. data. macro_body. to_subtree_resolved( CURRENT_API_VERSION , & span_data_table)
298+ ) ;
291299 }
292300}
0 commit comments