Struct rustc_expand::base::ExtCtxt  [−][src]
pub struct ExtCtxt<'a> {
    pub sess: &'a Session,
    pub ecfg: ExpansionConfig<'a>,
    pub reduced_recursion_limit: Option<Limit>,
    pub root_path: PathBuf,
    pub resolver: &'a mut dyn ResolverExpand,
    pub current_expansion: ExpansionData,
    pub force_mode: bool,
    pub expansions: FxHashMap<Span, Vec<String>>,
    pub(crate) extern_mod_loaded: Option<&'a dyn Fn(Ident, Vec<Attribute>, Vec<P<Item>>, Span) -> (Vec<Attribute>, Vec<P<Item>>)>,
    pub(crate) expanded_inert_attrs: MarkedAttrs,
}Expand description
One of these is made during expansion and incrementally updated as we go;
when a macro expansion occurs, the resulting nodes have the backtrace() -> expn_data of their expansion context stored into their span.
Fields
sess: &'a Sessionecfg: ExpansionConfig<'a>reduced_recursion_limit: Option<Limit>root_path: PathBufresolver: &'a mut dyn ResolverExpandcurrent_expansion: ExpansionDataforce_mode: boolError recovery mode entered when expansion is stuck (or during eager expansion, but that’s a hack).
expansions: FxHashMap<Span, Vec<String>>extern_mod_loaded: Option<&'a dyn Fn(Ident, Vec<Attribute>, Vec<P<Item>>, Span) -> (Vec<Attribute>, Vec<P<Item>>)>Called directly after having parsed an external mod foo; in expansion.
Ident is the module name.
expanded_inert_attrs: MarkedAttrsWhen we ‘expand’ an inert attribute, we leave it in the AST, but insert it here so that we know not to expand it again.
Implementations
pub fn new(
    sess: &'a Session, 
    ecfg: ExpansionConfig<'a>, 
    resolver: &'a mut dyn ResolverExpand, 
    extern_mod_loaded: Option<&'a dyn Fn(Ident, Vec<Attribute>, Vec<P<Item>>, Span) -> (Vec<Attribute>, Vec<P<Item>>)>
) -> ExtCtxt<'a>
Returns a Folder for deeply expanding all macros in an AST node.
Returns a Folder that deeply expands all macros and assigns all NodeIds in an AST node.
Once NodeIds are assigned, the node may not be expanded, removed, or otherwise modified.
Equivalent of Span::def_site from the proc macro API,
except that the location is taken from the span passed as an argument.
Equivalent of Span::call_site from the proc macro API,
except that the location is taken from the span passed as an argument.
Equivalent of Span::mixed_site from the proc macro API,
except that the location is taken from the span passed as an argument.
Returns span for the macro which originally caused the current expansion to happen.
Stops backtracing at include! boundary.
Emit msg attached to sp, without immediately stopping
compilation.
Compilation will be stopped in the near future (at the end of the macro expansion phase).
pub fn resolve_path(
    &self, 
    path: impl Into<PathBuf>, 
    span: Span
) -> Result<PathBuf, DiagnosticBuilder<'a>>
pub fn resolve_path(
    &self, 
    path: impl Into<PathBuf>, 
    span: Span
) -> Result<PathBuf, DiagnosticBuilder<'a>>
Resolves a path mentioned inside Rust code, returning an absolute path.
This unifies the logic used for resolving include_X!.
FIXME: move this to rustc_builtin_macros and make it private.
pub fn path_all(
    &self, 
    span: Span, 
    global: bool, 
    idents: Vec<Ident>, 
    args: Vec<GenericArg>
) -> Path
pub fn ty_rptr(
    &self, 
    span: Span, 
    ty: P<Ty>, 
    lifetime: Option<Lifetime>, 
    mutbl: Mutability
) -> P<Ty>
pub fn typaram(
    &self, 
    span: Span, 
    ident: Ident, 
    attrs: Vec<Attribute>, 
    bounds: GenericBounds, 
    default: Option<P<Ty>>
) -> GenericParam
pub fn item_static(
    &self, 
    span: Span, 
    name: Ident, 
    ty: P<Ty>, 
    mutbl: Mutability, 
    expr: P<Expr>
) -> P<Item>
Auto Trait Implementations
impl<'a> !RefUnwindSafe for ExtCtxt<'a>
impl<'a> !UnwindSafe for ExtCtxt<'a>
Blanket Implementations
Layout
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.
Size: 256 bytes