[][src]Enum syntax::ext::base::SyntaxExtension

pub enum SyntaxExtension {
    NonMacroAttr {
        mark_used: bool,
    },
    MultiDecorator(Box<dyn MultiItemDecorator + Sync + Send>),
    MultiModifier(Box<dyn MultiItemModifier + Sync + Send>),
    ProcMacro {
        expander: Box<dyn ProcMacro + Sync + Send>,
        allow_internal_unstable: bool,
        edition: Edition,
    },
    AttrProcMacro(Box<dyn AttrProcMacro + Sync + Send>, Edition),
    NormalTT {
        expander: Box<dyn TTMacroExpander + Sync + Send>,
        def_info: Option<(NodeId, Span)>,
        allow_internal_unstable: bool,
        allow_internal_unsafe: bool,
        local_inner_macros: bool,
        unstable_feature: Option<(Symbol, u32)>,
        edition: Edition,
    },
    IdentTT(Box<dyn IdentMacroExpander + Sync + Send>, Option<Span>, bool),
    ProcMacroDerive(Box<dyn MultiItemModifier + Sync + Send>, Vec<Symbol>, Edition),
    BuiltinDerive(BuiltinDeriveFn),
    DeclMacro {
        expander: Box<dyn TTMacroExpander + Sync + Send>,
        def_info: Option<(NodeId, Span)>,
        is_transparent: bool,
        edition: Edition,
    },
}

An enum representing the different kinds of syntax extensions.

Variants

NonMacroAttr

A trivial "extension" that does nothing, only keeps the attribute and marks it as known.

Fields of NonMacroAttr

mark_used: bool
MultiDecorator(Box<dyn MultiItemDecorator + Sync + Send>)

A syntax extension that is attached to an item and creates new items based upon it.

#[derive(...)] is a MultiItemDecorator.

Prefer ProcMacro or MultiModifier since they are more flexible.

MultiModifier(Box<dyn MultiItemModifier + Sync + Send>)

A syntax extension that is attached to an item and modifies it in-place. Also allows decoration, i.e., creating new items.

ProcMacro

A function-like procedural macro. TokenStream -> TokenStream.

Fields of ProcMacro

expander: Box<dyn ProcMacro + Sync + Send>allow_internal_unstable: booledition: Edition
AttrProcMacro(Box<dyn AttrProcMacro + Sync + Send>, Edition)

An attribute-like procedural macro. TokenStream, TokenStream -> TokenStream. The first TokenSteam is the attribute, the second is the annotated item. Allows modification of the input items and adding new items, similar to MultiModifier, but uses TokenStreams, rather than AST nodes.

NormalTT

A normal, function-like syntax extension.

bytes! is a NormalTT.

Fields of NormalTT

expander: Box<dyn TTMacroExpander + Sync + Send>def_info: Option<(NodeId, Span)>allow_internal_unstable: bool

Whether the contents of the macro can directly use #[unstable] things (true == yes).

allow_internal_unsafe: bool

Whether the contents of the macro can use unsafe without triggering the unsafe_code lint.

local_inner_macros: bool

Enables the macro helper hack (ident!(...) -> $crate::ident!(...)) for a given macro.

unstable_feature: Option<(Symbol, u32)>

The macro's feature name if it is unstable, and the stability feature

edition: Edition

Edition of the crate in which the macro is defined

IdentTT(Box<dyn IdentMacroExpander + Sync + Send>, Option<Span>, bool)

A function-like syntax extension that has an extra ident before the block.

ProcMacroDerive(Box<dyn MultiItemModifier + Sync + Send>, Vec<Symbol>, Edition)

An attribute-like procedural macro. TokenStream -> TokenStream. The input is the annotated item. Allows generating code to implement a Trait for a given struct or enum item.

BuiltinDerive(BuiltinDeriveFn)

An attribute-like procedural macro that derives a builtin trait.

DeclMacro

A declarative macro, e.g., macro m() {}.

Fields of DeclMacro

expander: Box<dyn TTMacroExpander + Sync + Send>def_info: Option<(NodeId, Span)>is_transparent: booledition: Edition

Methods

impl SyntaxExtension[src]

pub fn kind(&self) -> MacroKind[src]

Return which kind of macro calls this syntax extension.

pub fn default_transparency(&self) -> Transparency[src]

pub fn edition(&self) -> Edition[src]

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<E> SpecializationError for E[src]

impl<T> Send for T where
    T: ?Sized
[src]

impl<T> Sync for T where
    T: ?Sized
[src]

impl<T> Erased for T[src]

impl<T> Erased for T