@@ -158,7 +158,6 @@ pub struct Invocation {
158
158
159
159
pub enum InvocationKind {
160
160
Bang {
161
- attrs : Vec < ast:: Attribute > ,
162
161
mac : ast:: Mac ,
163
162
ident : Option < Ident > ,
164
163
span : Span ,
@@ -386,8 +385,8 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
386
385
/// Expand a macro invocation. Returns the result of expansion.
387
386
fn expand_bang_invoc ( & mut self , invoc : Invocation , ext : Rc < SyntaxExtension > ) -> Expansion {
388
387
let ( mark, kind) = ( invoc. expansion_data . mark , invoc. expansion_kind ) ;
389
- let ( attrs , mac, ident, span) = match invoc. kind {
390
- InvocationKind :: Bang { attrs , mac, ident, span } => ( attrs , mac, ident, span) ,
388
+ let ( mac, ident, span) = match invoc. kind {
389
+ InvocationKind :: Bang { mac, ident, span } => ( mac, ident, span) ,
391
390
_ => unreachable ! ( ) ,
392
391
} ;
393
392
let Mac_ { path, tts, .. } = mac. node ;
@@ -432,7 +431,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
432
431
}
433
432
} ) ;
434
433
435
- kind. make_from ( expander. expand ( self . cx , span, ident, marked_tts, attrs ) )
434
+ kind. make_from ( expander. expand ( self . cx , span, ident, marked_tts) )
436
435
}
437
436
438
437
MultiDecorator ( ..) | MultiModifier ( ..) | SyntaxExtension :: AttrProcMacro ( ..) => {
@@ -590,11 +589,8 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
590
589
placeholder ( expansion_kind, ast:: NodeId :: from_u32 ( mark. as_u32 ( ) ) )
591
590
}
592
591
593
- fn collect_bang (
594
- & mut self , mac : ast:: Mac , attrs : Vec < ast:: Attribute > , span : Span , kind : ExpansionKind ,
595
- ) -> Expansion {
596
- self . check_attributes ( & attrs) ;
597
- self . collect ( kind, InvocationKind :: Bang { attrs : attrs, mac : mac, ident : None , span : span } )
592
+ fn collect_bang ( & mut self , mac : ast:: Mac , span : Span , kind : ExpansionKind ) -> Expansion {
593
+ self . collect ( kind, InvocationKind :: Bang { mac : mac, ident : None , span : span } )
598
594
}
599
595
600
596
fn collect_attr ( & mut self , attr : ast:: Attribute , item : Annotatable , kind : ExpansionKind )
@@ -663,7 +659,8 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> {
663
659
expr. node = self . cfg . configure_expr_kind ( expr. node ) ;
664
660
665
661
if let ast:: ExprKind :: Mac ( mac) = expr. node {
666
- self . collect_bang ( mac, expr. attrs . into ( ) , expr. span , ExpansionKind :: Expr ) . make_expr ( )
662
+ self . check_attributes ( & expr. attrs ) ;
663
+ self . collect_bang ( mac, expr. span , ExpansionKind :: Expr ) . make_expr ( )
667
664
} else {
668
665
P ( noop_fold_expr ( expr, self ) )
669
666
}
@@ -674,8 +671,8 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> {
674
671
expr. node = self . cfg . configure_expr_kind ( expr. node ) ;
675
672
676
673
if let ast:: ExprKind :: Mac ( mac) = expr. node {
677
- self . collect_bang ( mac , expr. attrs . into ( ) , expr . span , ExpansionKind :: OptExpr )
678
- . make_opt_expr ( )
674
+ self . check_attributes ( & expr. attrs ) ;
675
+ self . collect_bang ( mac , expr . span , ExpansionKind :: OptExpr ) . make_opt_expr ( )
679
676
} else {
680
677
Some ( P ( noop_fold_expr ( expr, self ) ) )
681
678
}
@@ -688,8 +685,7 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> {
688
685
}
689
686
690
687
pat. and_then ( |pat| match pat. node {
691
- PatKind :: Mac ( mac) =>
692
- self . collect_bang ( mac, Vec :: new ( ) , pat. span , ExpansionKind :: Pat ) . make_pat ( ) ,
688
+ PatKind :: Mac ( mac) => self . collect_bang ( mac, pat. span , ExpansionKind :: Pat ) . make_pat ( ) ,
693
689
_ => unreachable ! ( ) ,
694
690
} )
695
691
}
@@ -710,8 +706,8 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> {
710
706
} ) . collect ( )
711
707
} ;
712
708
713
- let mut placeholder =
714
- self . collect_bang ( mac, attrs . into ( ) , stmt. span , ExpansionKind :: Stmts ) . make_stmts ( ) ;
709
+ self . check_attributes ( & attrs ) ;
710
+ let mut placeholder = self . collect_bang ( mac, stmt. span , ExpansionKind :: Stmts ) . make_stmts ( ) ;
715
711
716
712
// If this is a macro invocation with a semicolon, then apply that
717
713
// semicolon to the final statement produced by expansion.
@@ -758,7 +754,6 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> {
758
754
ItemKind :: Mac ( mac) => {
759
755
self . collect ( ExpansionKind :: Items , InvocationKind :: Bang {
760
756
mac : mac,
761
- attrs : item. attrs ,
762
757
ident : Some ( item. ident ) ,
763
758
span : item. span ,
764
759
} ) . make_items ( )
@@ -830,7 +825,8 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> {
830
825
match item. node {
831
826
ast:: TraitItemKind :: Macro ( mac) => {
832
827
let ast:: TraitItem { attrs, span, .. } = item;
833
- self . collect_bang ( mac, attrs, span, ExpansionKind :: TraitItems ) . make_trait_items ( )
828
+ self . check_attributes ( & attrs) ;
829
+ self . collect_bang ( mac, span, ExpansionKind :: TraitItems ) . make_trait_items ( )
834
830
}
835
831
_ => fold:: noop_fold_trait_item ( item, self ) ,
836
832
}
@@ -848,7 +844,8 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> {
848
844
match item. node {
849
845
ast:: ImplItemKind :: Macro ( mac) => {
850
846
let ast:: ImplItem { attrs, span, .. } = item;
851
- self . collect_bang ( mac, attrs, span, ExpansionKind :: ImplItems ) . make_impl_items ( )
847
+ self . check_attributes ( & attrs) ;
848
+ self . collect_bang ( mac, span, ExpansionKind :: ImplItems ) . make_impl_items ( )
852
849
}
853
850
_ => fold:: noop_fold_impl_item ( item, self ) ,
854
851
}
@@ -861,8 +858,7 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> {
861
858
} ;
862
859
863
860
match ty. node {
864
- ast:: TyKind :: Mac ( mac) =>
865
- self . collect_bang ( mac, Vec :: new ( ) , ty. span , ExpansionKind :: Ty ) . make_ty ( ) ,
861
+ ast:: TyKind :: Mac ( mac) => self . collect_bang ( mac, ty. span , ExpansionKind :: Ty ) . make_ty ( ) ,
866
862
_ => unreachable ! ( ) ,
867
863
}
868
864
}
0 commit comments