@@ -10,14 +10,14 @@ use crate::ext::mbe::macro_rules::annotate_err_with_kind;
1010use crate :: ext:: placeholders:: { placeholder, PlaceholderExpander } ;
1111use crate :: feature_gate:: { self , Features , GateIssue , is_builtin_attr, emit_feature_err} ;
1212use crate :: mut_visit:: * ;
13- use crate :: parse:: { DirectoryOwnership , PResult , ParseSess } ;
13+ use crate :: parse:: { DirectoryOwnership , PResult } ;
1414use crate :: parse:: token;
1515use crate :: parse:: parser:: Parser ;
1616use crate :: print:: pprust;
1717use crate :: ptr:: P ;
1818use crate :: symbol:: { sym, Symbol } ;
1919use crate :: tokenstream:: { TokenStream , TokenTree } ;
20- use crate :: visit:: { self , Visitor } ;
20+ use crate :: visit:: Visitor ;
2121use crate :: util:: map_in_place:: MapInPlace ;
2222
2323use errors:: { Applicability , FatalError } ;
@@ -577,10 +577,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
577577 SyntaxExtensionKind :: Bang ( expander) => {
578578 self . gate_proc_macro_expansion_kind ( span, fragment_kind) ;
579579 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)
584581 }
585582 SyntaxExtensionKind :: LegacyBang ( expander) => {
586583 let prev = self . cx . current_expansion . prior_type_ascription ;
@@ -624,10 +621,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
624621 } ) ) , DUMMY_SP ) . into ( ) ;
625622 let input = self . extract_proc_macro_attr_input ( attr. item . tokens , span) ;
626623 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)
631625 }
632626 SyntaxExtensionKind :: LegacyAttr ( expander) => {
633627 match attr. parse_meta ( self . cx . parse_sess ) {
@@ -718,41 +712,6 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
718712 ) ;
719713 }
720714
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-
756715 fn gate_proc_macro_expansion_kind ( & self , span : Span , kind : AstFragmentKind ) {
757716 let kind = match kind {
758717 AstFragmentKind :: Expr |
0 commit comments