@@ -13,8 +13,7 @@ use crate::parse::{DirectoryOwnership, PResult, ParseSess};
13
13
use crate :: parse:: token;
14
14
use crate :: parse:: parser:: Parser ;
15
15
use crate :: ptr:: P ;
16
- use crate :: symbol:: Symbol ;
17
- use crate :: symbol:: { kw, sym} ;
16
+ use crate :: symbol:: { sym, Symbol } ;
18
17
use crate :: tokenstream:: { TokenStream , TokenTree } ;
19
18
use crate :: visit:: { self , Visitor } ;
20
19
use crate :: util:: map_in_place:: MapInPlace ;
@@ -197,7 +196,6 @@ pub struct Invocation {
197
196
pub enum InvocationKind {
198
197
Bang {
199
198
mac : ast:: Mac ,
200
- ident : Option < Ident > ,
201
199
span : Span ,
202
200
} ,
203
201
Attr {
@@ -664,13 +662,12 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
664
662
ext : & SyntaxExtension )
665
663
-> Option < AstFragment > {
666
664
let kind = invoc. fragment_kind ;
667
- let ( mac, ident , span) = match invoc. kind {
668
- InvocationKind :: Bang { mac, ident , span } => ( mac, ident , span) ,
665
+ let ( mac, span) = match invoc. kind {
666
+ InvocationKind :: Bang { mac, span } => ( mac, span) ,
669
667
_ => unreachable ! ( ) ,
670
668
} ;
671
669
let path = & mac. node . path ;
672
670
673
- let ident = ident. unwrap_or_else ( || Ident :: invalid ( ) ) ;
674
671
let validate = |this : & mut Self | {
675
672
// feature-gate the macro invocation
676
673
if let Some ( ( feature, issue) ) = ext. unstable_feature {
@@ -690,12 +687,6 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
690
687
}
691
688
}
692
689
693
- if ident. name != kw:: Invalid {
694
- let msg = format ! ( "macro {}! expects no ident argument, given '{}'" , path, ident) ;
695
- this. cx . span_err ( path. span , & msg) ;
696
- this. cx . trace_macros_diag ( ) ;
697
- return Err ( kind. dummy ( span) ) ;
698
- }
699
690
Ok ( ( ) )
700
691
} ;
701
692
@@ -729,19 +720,11 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
729
720
}
730
721
731
722
SyntaxExtensionKind :: Bang ( expander) => {
732
- if ident. name != kw:: Invalid {
733
- let msg =
734
- format ! ( "macro {}! expects no ident argument, given '{}'" , path, ident) ;
735
- self . cx . span_err ( path. span , & msg) ;
736
- self . cx . trace_macros_diag ( ) ;
737
- kind. dummy ( span)
738
- } else {
739
- self . gate_proc_macro_expansion_kind ( span, kind) ;
740
- let tok_result = expander. expand ( self . cx , span, mac. node . stream ( ) ) ;
741
- let result = self . parse_ast_fragment ( tok_result, kind, path, span) ;
742
- self . gate_proc_macro_expansion ( span, & result) ;
743
- result
744
- }
723
+ self . gate_proc_macro_expansion_kind ( span, kind) ;
724
+ let tok_result = expander. expand ( self . cx , span, mac. node . stream ( ) ) ;
725
+ let result = self . parse_ast_fragment ( tok_result, kind, path, span) ;
726
+ self . gate_proc_macro_expansion ( span, & result) ;
727
+ result
745
728
}
746
729
} ;
747
730
@@ -944,7 +927,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
944
927
}
945
928
946
929
fn collect_bang ( & mut self , mac : ast:: Mac , span : Span , kind : AstFragmentKind ) -> AstFragment {
947
- self . collect ( kind, InvocationKind :: Bang { mac, ident : None , span } )
930
+ self . collect ( kind, InvocationKind :: Bang { mac, span } )
948
931
}
949
932
950
933
fn collect_attr ( & mut self ,
@@ -1179,13 +1162,9 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
1179
1162
ast:: ItemKind :: Mac ( ..) => {
1180
1163
self . check_attributes ( & item. attrs ) ;
1181
1164
item. and_then ( |item| match item. node {
1182
- ItemKind :: Mac ( mac) => {
1183
- self . collect ( AstFragmentKind :: Items , InvocationKind :: Bang {
1184
- mac,
1185
- ident : Some ( item. ident ) ,
1186
- span : item. span ,
1187
- } ) . make_items ( )
1188
- }
1165
+ ItemKind :: Mac ( mac) => self . collect (
1166
+ AstFragmentKind :: Items , InvocationKind :: Bang { mac, span : item. span }
1167
+ ) . make_items ( ) ,
1189
1168
_ => unreachable ! ( ) ,
1190
1169
} )
1191
1170
}
0 commit comments