@@ -72,6 +72,16 @@ pub struct PanicMessage(pub String);
72
72
73
73
#[ derive( Debug , Serialize , Deserialize ) ]
74
74
pub 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 {
75
85
/// Argument of macro call.
76
86
///
77
87
/// In custom derive this will be a struct or enum; in attribute-like macro - underlying
@@ -86,13 +96,6 @@ pub struct ExpandMacro {
86
96
87
97
/// Possible attributes for the attribute-like macros.
88
98
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 > ,
96
99
/// marker for serde skip stuff
97
100
#[ serde( skip_serializing_if = "ExpnGlobals::skip_serializing_if" ) ]
98
101
#[ serde( default ) ]
@@ -268,25 +271,30 @@ mod tests {
268
271
let tt = fixture_token_tree ( ) ;
269
272
let mut span_data_table = Default :: default ( ) ;
270
273
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
+ } ,
274
286
lib : Utf8PathBuf :: from_path_buf ( std:: env:: current_dir ( ) . unwrap ( ) ) . unwrap ( ) ,
275
287
env : Default :: default ( ) ,
276
288
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 ( ) ,
284
289
} ;
285
290
286
291
let json = serde_json:: to_string ( & task) . unwrap ( ) ;
287
292
// println!("{}", json);
288
293
let back: ExpandMacro = serde_json:: from_str ( & json) . unwrap ( ) ;
289
294
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
+ ) ;
291
299
}
292
300
}
0 commit comments