@@ -552,60 +552,78 @@ impl MacroKind {
552552
553553/// An enum representing the different kinds of syntax extensions.
554554pub enum SyntaxExtension {
555- /// A trivial "extension" that does nothing, only keeps the attribute and marks it as known.
556- NonMacroAttr { mark_used : bool } ,
557-
558- /// A syntax extension that is attached to an item and modifies it
559- /// in-place. Also allows decoration, i.e., creating new items.
560- MultiModifier ( Box < dyn MultiItemModifier + sync:: Sync + sync:: Send > ) ,
561-
562- /// A function-like procedural macro. TokenStream -> TokenStream.
555+ /// A token-based function-like macro.
563556 ProcMacro {
557+ /// An expander with signature TokenStream -> TokenStream.
564558 expander : Box < dyn ProcMacro + sync:: Sync + sync:: Send > ,
565- /// Whitelist of unstable features that are treated as stable inside this macro
559+ /// Whitelist of unstable features that are treated as stable inside this macro.
566560 allow_internal_unstable : Option < Lrc < [ Symbol ] > > ,
561+ /// Edition of the crate in which this macro is defined.
567562 edition : Edition ,
568563 } ,
569564
570- /// An attribute-like procedural macro. TokenStream, TokenStream -> TokenStream.
571- /// The first TokenSteam is the attribute, the second is the annotated item.
572- /// Allows modification of the input items and adding new items, similar to
573- /// MultiModifier, but uses TokenStreams, rather than AST nodes.
574- AttrProcMacro ( Box < dyn AttrProcMacro + sync:: Sync + sync:: Send > , Edition ) ,
575-
576- /// A normal, function-like syntax extension.
577- ///
578- /// `bytes!` is a `NormalTT`.
565+ /// An AST-based function-like macro.
579566 NormalTT {
567+ /// An expander with signature TokenStream -> AST.
580568 expander : Box < dyn TTMacroExpander + sync:: Sync + sync:: Send > ,
569+ /// Some info about the macro's definition point.
581570 def_info : Option < ( ast:: NodeId , Span ) > ,
571+ /// Hygienic properties of identifiers produced by this macro.
582572 transparency : Transparency ,
583- /// Whether the contents of the macro can
584- /// directly use `#[unstable]` things.
585- ///
586- /// Only allows things that require a feature gate in the given whitelist
573+ /// Whitelist of unstable features that are treated as stable inside this macro.
587574 allow_internal_unstable : Option < Lrc < [ Symbol ] > > ,
588- /// Whether the contents of the macro can use `unsafe`
589- /// without triggering the `unsafe_code` lint.
575+ /// Suppresses the `unsafe_code` lint for code produced by this macro.
590576 allow_internal_unsafe : bool ,
591- /// Enables the macro helper hack (`ident!(...)` -> `$crate::ident!(...)`)
592- /// for a given macro.
577+ /// Enables the macro helper hack (`ident!(...)` -> `$crate::ident!(...)`) for this macro.
593578 local_inner_macros : bool ,
594- /// The macro's feature name if it is unstable, and the stability feature
579+ /// The macro's feature name and tracking issue number if it is unstable.
595580 unstable_feature : Option < ( Symbol , u32 ) > ,
596- /// Edition of the crate in which the macro is defined
581+ /// Edition of the crate in which this macro is defined.
597582 edition : Edition ,
598583 } ,
599584
600- /// An attribute-like procedural macro. TokenStream -> TokenStream.
601- /// The input is the annotated item.
602- /// Allows generating code to implement a Trait for a given struct
603- /// or enum item.
604- ProcMacroDerive ( Box < dyn MultiItemModifier + sync:: Sync + sync:: Send > ,
605- Vec < Symbol > /* inert attribute names */ , Edition ) ,
585+ /// A token-based attribute macro.
586+ AttrProcMacro (
587+ /// An expander with signature (TokenStream, TokenStream) -> TokenStream.
588+ /// The first TokenSteam is the attribute itself, the second is the annotated item.
589+ /// The produced TokenSteam replaces the input TokenSteam.
590+ Box < dyn AttrProcMacro + sync:: Sync + sync:: Send > ,
591+ /// Edition of the crate in which this macro is defined.
592+ Edition ,
593+ ) ,
594+
595+ /// An AST-based attribute macro.
596+ MultiModifier (
597+ /// An expander with signature (AST, AST) -> AST.
598+ /// The first AST fragment is the attribute itself, the second is the annotated item.
599+ /// The produced AST fragment replaces the input AST fragment.
600+ Box < dyn MultiItemModifier + sync:: Sync + sync:: Send > ,
601+ ) ,
602+
603+ /// A trivial attribute "macro" that does nothing,
604+ /// only keeps the attribute and marks it as known.
605+ NonMacroAttr {
606+ /// Suppresses the `unused_attributes` lint for this attribute.
607+ mark_used : bool ,
608+ } ,
606609
607- /// An attribute-like procedural macro that derives a builtin trait.
608- BuiltinDerive ( Box < dyn MultiItemModifier + sync:: Sync + sync:: Send > ) ,
610+ /// A token-based derive macro.
611+ ProcMacroDerive (
612+ /// An expander with signature TokenStream -> TokenStream (not yet).
613+ /// The produced TokenSteam is appended to the input TokenSteam.
614+ Box < dyn MultiItemModifier + sync:: Sync + sync:: Send > ,
615+ /// Names of helper attributes registered by this macro.
616+ Vec < Symbol > ,
617+ /// Edition of the crate in which this macro is defined.
618+ Edition ,
619+ ) ,
620+
621+ /// An AST-based derive macro.
622+ BuiltinDerive (
623+ /// An expander with signature AST -> AST.
624+ /// The produced AST fragment is appended to the input AST fragment.
625+ Box < dyn MultiItemModifier + sync:: Sync + sync:: Send > ,
626+ ) ,
609627}
610628
611629impl SyntaxExtension {
0 commit comments