@@ -252,7 +252,7 @@ pub fn expand_speculative(
252
252
// Otherwise the expand query will fetch the non speculative attribute args and pass those instead.
253
253
let mut speculative_expansion =
254
254
match loc. def . kind {
255
- MacroDefKind :: ProcMacro ( expander , _ , ast ) => {
255
+ MacroDefKind :: ProcMacro ( ast , expander , _ ) => {
256
256
let span = db. proc_macro_span ( ast) ;
257
257
tt. delimiter = tt:: Delimiter :: invisible_spanned ( span) ;
258
258
expander. expand (
@@ -266,22 +266,22 @@ pub fn expand_speculative(
266
266
span_with_mixed_site_ctxt ( db, span, actual_macro_call) ,
267
267
)
268
268
}
269
- MacroDefKind :: BuiltInAttr ( BuiltinAttrExpander :: Derive , _ ) => {
269
+ MacroDefKind :: BuiltInAttr ( _ , it ) if it . is_derive ( ) => {
270
270
pseudo_derive_attr_expansion ( & tt, attr_arg. as_ref ( ) ?, span)
271
271
}
272
272
MacroDefKind :: Declarative ( it) => db
273
273
. decl_macro_expander ( loc. krate , it)
274
274
. expand_unhygienic ( db, tt, loc. def . krate , span, loc. def . edition ) ,
275
- MacroDefKind :: BuiltIn ( it , _ ) => {
275
+ MacroDefKind :: BuiltIn ( _ , it ) => {
276
276
it. expand ( db, actual_macro_call, & tt, span) . map_err ( Into :: into)
277
277
}
278
- MacroDefKind :: BuiltInDerive ( it , .. ) => {
278
+ MacroDefKind :: BuiltInDerive ( _ , it ) => {
279
279
it. expand ( db, actual_macro_call, & tt, span) . map_err ( Into :: into)
280
280
}
281
- MacroDefKind :: BuiltInEager ( it , _ ) => {
281
+ MacroDefKind :: BuiltInEager ( _ , it ) => {
282
282
it. expand ( db, actual_macro_call, & tt, span) . map_err ( Into :: into)
283
283
}
284
- MacroDefKind :: BuiltInAttr ( it , _ ) => it. expand ( db, actual_macro_call, & tt, span) ,
284
+ MacroDefKind :: BuiltInAttr ( _ , it ) => it. expand ( db, actual_macro_call, & tt, span) ,
285
285
} ;
286
286
287
287
let expand_to = loc. expand_to ( ) ;
@@ -493,7 +493,7 @@ fn macro_arg(db: &dyn ExpandDatabase, id: MacroCallId) -> MacroArgResult {
493
493
. map_or_else ( || node. syntax ( ) . text_range ( ) , |it| it. syntax ( ) . text_range ( ) ) ,
494
494
) ;
495
495
// If derive attribute we need to censor the derive input
496
- if matches ! ( loc. def. kind, MacroDefKind :: BuiltInAttr ( expander , .. ) if expander. is_derive( ) )
496
+ if matches ! ( loc. def. kind, MacroDefKind :: BuiltInAttr ( _ , expander ) if expander. is_derive( ) )
497
497
&& ast:: Adt :: can_cast ( node. syntax ( ) . kind ( ) )
498
498
{
499
499
let adt = ast:: Adt :: cast ( node. syntax ( ) . clone ( ) ) . unwrap ( ) ;
@@ -569,11 +569,11 @@ impl TokenExpander {
569
569
MacroDefKind :: Declarative ( ast_id) => {
570
570
TokenExpander :: DeclarativeMacro ( db. decl_macro_expander ( id. krate , ast_id) )
571
571
}
572
- MacroDefKind :: BuiltIn ( expander , _ ) => TokenExpander :: BuiltIn ( expander) ,
573
- MacroDefKind :: BuiltInAttr ( expander , _ ) => TokenExpander :: BuiltInAttr ( expander) ,
574
- MacroDefKind :: BuiltInDerive ( expander , _ ) => TokenExpander :: BuiltInDerive ( expander) ,
575
- MacroDefKind :: BuiltInEager ( expander , .. ) => TokenExpander :: BuiltInEager ( expander) ,
576
- MacroDefKind :: ProcMacro ( expander, .. ) => TokenExpander :: ProcMacro ( expander) ,
572
+ MacroDefKind :: BuiltIn ( _ , expander ) => TokenExpander :: BuiltIn ( expander) ,
573
+ MacroDefKind :: BuiltInAttr ( _ , expander ) => TokenExpander :: BuiltInAttr ( expander) ,
574
+ MacroDefKind :: BuiltInDerive ( _ , expander ) => TokenExpander :: BuiltInDerive ( expander) ,
575
+ MacroDefKind :: BuiltInEager ( _ , expander ) => TokenExpander :: BuiltInEager ( expander) ,
576
+ MacroDefKind :: ProcMacro ( _ , expander, _ ) => TokenExpander :: ProcMacro ( expander) ,
577
577
}
578
578
}
579
579
}
@@ -604,13 +604,13 @@ fn macro_expand(
604
604
MacroDefKind :: Declarative ( id) => db
605
605
. decl_macro_expander ( loc. def . krate , id)
606
606
. expand ( db, arg. clone ( ) , macro_call_id, span) ,
607
- MacroDefKind :: BuiltIn ( it , _ ) => {
607
+ MacroDefKind :: BuiltIn ( _ , it ) => {
608
608
it. expand ( db, macro_call_id, arg, span) . map_err ( Into :: into) . zip_val ( None )
609
609
}
610
- MacroDefKind :: BuiltInDerive ( it , _ ) => {
610
+ MacroDefKind :: BuiltInDerive ( _ , it ) => {
611
611
it. expand ( db, macro_call_id, arg, span) . map_err ( Into :: into) . zip_val ( None )
612
612
}
613
- MacroDefKind :: BuiltInEager ( it , _ ) => {
613
+ MacroDefKind :: BuiltInEager ( _ , it ) => {
614
614
// This might look a bit odd, but we do not expand the inputs to eager macros here.
615
615
// Eager macros inputs are expanded, well, eagerly when we collect the macro calls.
616
616
// That kind of expansion uses the ast id map of an eager macros input though which goes through
@@ -634,12 +634,12 @@ fn macro_expand(
634
634
}
635
635
res. zip_val ( None )
636
636
}
637
- MacroDefKind :: BuiltInAttr ( it , _ ) => {
637
+ MacroDefKind :: BuiltInAttr ( _ , it ) => {
638
638
let mut res = it. expand ( db, macro_call_id, arg, span) ;
639
639
fixup:: reverse_fixups ( & mut res. value , & undo_info) ;
640
640
res. zip_val ( None )
641
641
}
642
- _ => unreachable ! ( ) ,
642
+ MacroDefKind :: ProcMacro ( _ , _ , _ ) => unreachable ! ( ) ,
643
643
} ;
644
644
( ExpandResult { value : res. value , err : res. err } , span)
645
645
}
@@ -678,8 +678,8 @@ fn expand_proc_macro(db: &dyn ExpandDatabase, id: MacroCallId) -> ExpandResult<A
678
678
let loc = db. lookup_intern_macro_call ( id) ;
679
679
let ( macro_arg, undo_info, span) = db. macro_arg_considering_derives ( id, & loc. kind ) ;
680
680
681
- let ( expander , ast ) = match loc. def . kind {
682
- MacroDefKind :: ProcMacro ( expander , _ , ast ) => ( expander , ast ) ,
681
+ let ( ast , expander ) = match loc. def . kind {
682
+ MacroDefKind :: ProcMacro ( ast , expander , _ ) => ( ast , expander ) ,
683
683
_ => unreachable ! ( ) ,
684
684
} ;
685
685
0 commit comments