@@ -10,14 +10,14 @@ use crate::ext::mbe::macro_rules::annotate_err_with_kind;
10
10
use crate :: ext:: placeholders:: { placeholder, PlaceholderExpander } ;
11
11
use crate :: feature_gate:: { self , Features , GateIssue , is_builtin_attr, emit_feature_err} ;
12
12
use crate :: mut_visit:: * ;
13
- use crate :: parse:: { DirectoryOwnership , PResult , ParseSess } ;
13
+ use crate :: parse:: { DirectoryOwnership , PResult } ;
14
14
use crate :: parse:: token;
15
15
use crate :: parse:: parser:: Parser ;
16
16
use crate :: print:: pprust;
17
17
use crate :: ptr:: P ;
18
18
use crate :: symbol:: { sym, Symbol } ;
19
19
use crate :: tokenstream:: { TokenStream , TokenTree } ;
20
- use crate :: visit:: { self , Visitor } ;
20
+ use crate :: visit:: Visitor ;
21
21
use crate :: util:: map_in_place:: MapInPlace ;
22
22
23
23
use errors:: { Applicability , FatalError } ;
@@ -577,10 +577,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
577
577
SyntaxExtensionKind :: Bang ( expander) => {
578
578
self . gate_proc_macro_expansion_kind ( span, fragment_kind) ;
579
579
let tok_result = expander. expand ( self . cx , span, mac. stream ( ) ) ;
580
- let result =
581
- self . parse_ast_fragment ( tok_result, fragment_kind, & mac. path , span) ;
582
- self . gate_proc_macro_expansion ( span, & result) ;
583
- result
580
+ self . parse_ast_fragment ( tok_result, fragment_kind, & mac. path , span)
584
581
}
585
582
SyntaxExtensionKind :: LegacyBang ( expander) => {
586
583
let prev = self . cx . current_expansion . prior_type_ascription ;
@@ -624,10 +621,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
624
621
} ) ) , DUMMY_SP ) . into ( ) ;
625
622
let input = self . extract_proc_macro_attr_input ( attr. item . tokens , span) ;
626
623
let tok_result = expander. expand ( self . cx , span, input, item_tok) ;
627
- let res =
628
- self . parse_ast_fragment ( tok_result, fragment_kind, & attr. item . path , span) ;
629
- self . gate_proc_macro_expansion ( span, & res) ;
630
- res
624
+ self . parse_ast_fragment ( tok_result, fragment_kind, & attr. item . path , span)
631
625
}
632
626
SyntaxExtensionKind :: LegacyAttr ( expander) => {
633
627
match attr. parse_meta ( self . cx . parse_sess ) {
@@ -718,41 +712,6 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
718
712
) ;
719
713
}
720
714
721
- fn gate_proc_macro_expansion ( & self , span : Span , fragment : & AstFragment ) {
722
- if self . cx . ecfg . proc_macro_hygiene ( ) {
723
- return
724
- }
725
-
726
- fragment. visit_with ( & mut DisallowMacros {
727
- span,
728
- parse_sess : self . cx . parse_sess ,
729
- } ) ;
730
-
731
- struct DisallowMacros < ' a > {
732
- span : Span ,
733
- parse_sess : & ' a ParseSess ,
734
- }
735
-
736
- impl < ' ast , ' a > Visitor < ' ast > for DisallowMacros < ' a > {
737
- fn visit_item ( & mut self , i : & ' ast ast:: Item ) {
738
- if let ast:: ItemKind :: MacroDef ( _) = i. kind {
739
- emit_feature_err (
740
- self . parse_sess ,
741
- sym:: proc_macro_hygiene,
742
- self . span ,
743
- GateIssue :: Language ,
744
- "procedural macros cannot expand to macro definitions" ,
745
- ) ;
746
- }
747
- visit:: walk_item ( self , i) ;
748
- }
749
-
750
- fn visit_mac ( & mut self , _mac : & ' ast ast:: Mac ) {
751
- // ...
752
- }
753
- }
754
- }
755
-
756
715
fn gate_proc_macro_expansion_kind ( & self , span : Span , kind : AstFragmentKind ) {
757
716
let kind = match kind {
758
717
AstFragmentKind :: Expr |
0 commit comments