[][src]Struct rustc_ap_rustc_expand::base::ExtCtxt

pub struct ExtCtxt<'a> {
    pub parse_sess: &'a ParseSess,
    pub ecfg: ExpansionConfig<'a>,
    pub reduced_recursion_limit: Option<usize>,
    pub root_path: PathBuf,
    pub resolver: &'a mut dyn Resolver,
    pub current_expansion: ExpansionData,
    pub expansions: FxHashMap<Span, Vec<String>>,
    // some fields omitted
}

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

parse_sess: &'a ParseSessecfg: ExpansionConfig<'a>reduced_recursion_limit: Option<usize>root_path: PathBufresolver: &'a mut dyn Resolvercurrent_expansion: ExpansionDataexpansions: FxHashMap<Span, Vec<String>>

Methods

impl<'a> ExtCtxt<'a>[src]

pub fn new(
    parse_sess: &'a ParseSess,
    ecfg: ExpansionConfig<'a>,
    resolver: &'a mut dyn Resolver,
    extern_mod_loaded: Option<&'a dyn Fn(&Crate)>
) -> ExtCtxt<'a>
[src]

pub fn expander<'b>(&'b mut self) -> MacroExpander<'b, 'a>[src]

Returns a Folder for deeply expanding all macros in an AST node.

pub fn monotonic_expander<'b>(&'b mut self) -> MacroExpander<'b, 'a>[src]

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.

pub fn new_parser_from_tts(&self, stream: TokenStream) -> Parser<'a>[src]

pub fn source_map(&self) -> &'a SourceMap[src]

pub fn parse_sess(&self) -> &'a ParseSess[src]

pub fn call_site(&self) -> Span[src]

pub fn with_def_site_ctxt(&self, span: Span) -> Span[src]

Equivalent of Span::def_site from the proc macro API, except that the location is taken from the span passed as an argument.

pub fn with_call_site_ctxt(&self, span: Span) -> Span[src]

Equivalent of Span::call_site from the proc macro API, except that the location is taken from the span passed as an argument.

pub fn with_mixed_site_ctxt(&self, span: Span) -> Span[src]

Equivalent of Span::mixed_site from the proc macro API, except that the location is taken from the span passed as an argument.

pub fn expansion_cause(&self) -> Option<Span>[src]

Returns span for the macro which originally caused the current expansion to happen.

Stops backtracing at include! boundary.

pub fn struct_span_err<S: Into<MultiSpan>>(
    &self,
    sp: S,
    msg: &str
) -> DiagnosticBuilder<'a>
[src]

pub fn span_err<S: Into<MultiSpan>>(&self, sp: S, msg: &str)[src]

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 span_warn<S: Into<MultiSpan>>(&self, sp: S, msg: &str)[src]

pub fn span_bug<S: Into<MultiSpan>>(&self, sp: S, msg: &str) -> ![src]

pub fn trace_macros_diag(&mut self)[src]

pub fn bug(&self, msg: &str) -> ![src]

pub fn trace_macros(&self) -> bool[src]

pub fn set_trace_macros(&mut self, x: bool)[src]

pub fn ident_of(&self, st: &str, sp: Span) -> Ident[src]

pub fn std_path(&self, components: &[Symbol]) -> Vec<Ident>[src]

pub fn name_of(&self, st: &str) -> Name[src]

pub fn check_unused_macros(&mut self)[src]

pub fn resolve_path(
    &self,
    path: impl Into<PathBuf>,
    span: Span
) -> Result<PathBuf, DiagnosticBuilder<'a>>
[src]

Resolves a path mentioned inside Rust code.

This unifies the logic used for resolving include_X!, and #[doc(include)] file paths.

Returns an absolute path to the file that path refers to.

impl<'a> ExtCtxt<'a>[src]

pub fn path(&self, span: Span, strs: Vec<Ident>) -> Path[src]

pub fn path_ident(&self, span: Span, id: Ident) -> Path[src]

pub fn path_global(&self, span: Span, strs: Vec<Ident>) -> Path[src]

pub fn path_all(
    &self,
    span: Span,
    global: bool,
    idents: Vec<Ident>,
    args: Vec<GenericArg>
) -> Path
[src]

pub fn ty_mt(&self, ty: P<Ty>, mutbl: Mutability) -> MutTy[src]

pub fn ty(&self, span: Span, kind: TyKind) -> P<Ty>[src]

pub fn ty_path(&self, path: Path) -> P<Ty>[src]

pub fn ty_ident(&self, span: Span, ident: Ident) -> P<Ty>[src]

pub fn anon_const(&self, span: Span, kind: ExprKind) -> AnonConst[src]

pub fn const_ident(&self, span: Span, ident: Ident) -> AnonConst[src]

pub fn ty_rptr(
    &self,
    span: Span,
    ty: P<Ty>,
    lifetime: Option<Lifetime>,
    mutbl: Mutability
) -> P<Ty>
[src]

pub fn ty_ptr(&self, span: Span, ty: P<Ty>, mutbl: Mutability) -> P<Ty>[src]

pub fn typaram(
    &self,
    span: Span,
    ident: Ident,
    attrs: Vec<Attribute>,
    bounds: GenericBounds,
    default: Option<P<Ty>>
) -> GenericParam
[src]

pub fn trait_ref(&self, path: Path) -> TraitRef[src]

pub fn poly_trait_ref(&self, span: Span, path: Path) -> PolyTraitRef[src]

pub fn trait_bound(&self, path: Path) -> GenericBound[src]

pub fn lifetime(&self, span: Span, ident: Ident) -> Lifetime[src]

pub fn lifetime_def(
    &self,
    span: Span,
    ident: Ident,
    attrs: Vec<Attribute>,
    bounds: GenericBounds
) -> GenericParam
[src]

pub fn stmt_expr(&self, expr: P<Expr>) -> Stmt[src]

pub fn stmt_let(&self, sp: Span, mutbl: bool, ident: Ident, ex: P<Expr>) -> Stmt[src]

pub fn stmt_let_type_only(&self, span: Span, ty: P<Ty>) -> Stmt[src]

pub fn stmt_item(&self, sp: Span, item: P<Item>) -> Stmt[src]

pub fn block_expr(&self, expr: P<Expr>) -> P<Block>[src]

pub fn block(&self, span: Span, stmts: Vec<Stmt>) -> P<Block>[src]

pub fn expr(&self, span: Span, kind: ExprKind) -> P<Expr>[src]

pub fn expr_path(&self, path: Path) -> P<Expr>[src]

pub fn expr_ident(&self, span: Span, id: Ident) -> P<Expr>[src]

pub fn expr_self(&self, span: Span) -> P<Expr>[src]

pub fn expr_binary(
    &self,
    sp: Span,
    op: BinOpKind,
    lhs: P<Expr>,
    rhs: P<Expr>
) -> P<Expr>
[src]

pub fn expr_deref(&self, sp: Span, e: P<Expr>) -> P<Expr>[src]

pub fn expr_addr_of(&self, sp: Span, e: P<Expr>) -> P<Expr>[src]

pub fn expr_call(
    &self,
    span: Span,
    expr: P<Expr>,
    args: Vec<P<Expr>>
) -> P<Expr>
[src]

pub fn expr_call_ident(
    &self,
    span: Span,
    id: Ident,
    args: Vec<P<Expr>>
) -> P<Expr>
[src]

pub fn expr_call_global(
    &self,
    sp: Span,
    fn_path: Vec<Ident>,
    args: Vec<P<Expr>>
) -> P<Expr>
[src]

pub fn expr_method_call(
    &self,
    span: Span,
    expr: P<Expr>,
    ident: Ident,
    args: Vec<P<Expr>>
) -> P<Expr>
[src]

pub fn expr_block(&self, b: P<Block>) -> P<Expr>[src]

pub fn field_imm(&self, span: Span, ident: Ident, e: P<Expr>) -> Field[src]

pub fn expr_struct(&self, span: Span, path: Path, fields: Vec<Field>) -> P<Expr>[src]

pub fn expr_struct_ident(
    &self,
    span: Span,
    id: Ident,
    fields: Vec<Field>
) -> P<Expr>
[src]

pub fn expr_lit(&self, span: Span, lit_kind: LitKind) -> P<Expr>[src]

pub fn expr_usize(&self, span: Span, i: usize) -> P<Expr>[src]

pub fn expr_u32(&self, sp: Span, u: u32) -> P<Expr>[src]

pub fn expr_bool(&self, sp: Span, value: bool) -> P<Expr>[src]

pub fn expr_vec(&self, sp: Span, exprs: Vec<P<Expr>>) -> P<Expr>[src]

pub fn expr_vec_slice(&self, sp: Span, exprs: Vec<P<Expr>>) -> P<Expr>[src]

pub fn expr_str(&self, sp: Span, s: Symbol) -> P<Expr>[src]

pub fn expr_cast(&self, sp: Span, expr: P<Expr>, ty: P<Ty>) -> P<Expr>[src]

pub fn expr_some(&self, sp: Span, expr: P<Expr>) -> P<Expr>[src]

pub fn expr_tuple(&self, sp: Span, exprs: Vec<P<Expr>>) -> P<Expr>[src]

pub fn expr_fail(&self, span: Span, msg: Symbol) -> P<Expr>[src]

pub fn expr_unreachable(&self, span: Span) -> P<Expr>[src]

pub fn expr_ok(&self, sp: Span, expr: P<Expr>) -> P<Expr>[src]

pub fn expr_try(&self, sp: Span, head: P<Expr>) -> P<Expr>[src]

pub fn pat(&self, span: Span, kind: PatKind) -> P<Pat>[src]

pub fn pat_wild(&self, span: Span) -> P<Pat>[src]

pub fn pat_lit(&self, span: Span, expr: P<Expr>) -> P<Pat>[src]

pub fn pat_ident(&self, span: Span, ident: Ident) -> P<Pat>[src]

pub fn pat_ident_binding_mode(
    &self,
    span: Span,
    ident: Ident,
    bm: BindingMode
) -> P<Pat>
[src]

pub fn pat_path(&self, span: Span, path: Path) -> P<Pat>[src]

pub fn pat_tuple_struct(
    &self,
    span: Span,
    path: Path,
    subpats: Vec<P<Pat>>
) -> P<Pat>
[src]

pub fn pat_struct(
    &self,
    span: Span,
    path: Path,
    field_pats: Vec<FieldPat>
) -> P<Pat>
[src]

pub fn pat_tuple(&self, span: Span, pats: Vec<P<Pat>>) -> P<Pat>[src]

pub fn pat_some(&self, span: Span, pat: P<Pat>) -> P<Pat>[src]

pub fn pat_none(&self, span: Span) -> P<Pat>[src]

pub fn pat_ok(&self, span: Span, pat: P<Pat>) -> P<Pat>[src]

pub fn pat_err(&self, span: Span, pat: P<Pat>) -> P<Pat>[src]

pub fn arm(&self, span: Span, pat: P<Pat>, expr: P<Expr>) -> Arm[src]

pub fn arm_unreachable(&self, span: Span) -> Arm[src]

pub fn expr_match(&self, span: Span, arg: P<Expr>, arms: Vec<Arm>) -> P<Expr>[src]

pub fn expr_if(
    &self,
    span: Span,
    cond: P<Expr>,
    then: P<Expr>,
    els: Option<P<Expr>>
) -> P<Expr>
[src]

pub fn lambda_fn_decl(
    &self,
    span: Span,
    fn_decl: P<FnDecl>,
    body: P<Expr>,
    fn_decl_span: Span
) -> P<Expr>
[src]

pub fn lambda(&self, span: Span, ids: Vec<Ident>, body: P<Expr>) -> P<Expr>[src]

pub fn lambda0(&self, span: Span, body: P<Expr>) -> P<Expr>[src]

pub fn lambda1(&self, span: Span, body: P<Expr>, ident: Ident) -> P<Expr>[src]

pub fn lambda_stmts_1(
    &self,
    span: Span,
    stmts: Vec<Stmt>,
    ident: Ident
) -> P<Expr>
[src]

pub fn param(&self, span: Span, ident: Ident, ty: P<Ty>) -> Param[src]

pub fn fn_decl(&self, inputs: Vec<Param>, output: FnRetTy) -> P<FnDecl>[src]

pub fn item(
    &self,
    span: Span,
    name: Ident,
    attrs: Vec<Attribute>,
    kind: ItemKind
) -> P<Item>
[src]

pub fn variant(&self, span: Span, ident: Ident, tys: Vec<P<Ty>>) -> Variant[src]

pub fn item_static(
    &self,
    span: Span,
    name: Ident,
    ty: P<Ty>,
    mutbl: Mutability,
    expr: P<Expr>
) -> P<Item>
[src]

pub fn item_const(
    &self,
    span: Span,
    name: Ident,
    ty: P<Ty>,
    expr: P<Expr>
) -> P<Item>
[src]

pub fn attribute(&self, mi: MetaItem) -> Attribute[src]

pub fn meta_word(&self, sp: Span, w: Name) -> MetaItem[src]

Auto Trait Implementations

impl<'a> !RefUnwindSafe for ExtCtxt<'a>

impl<'a> !Send for ExtCtxt<'a>

impl<'a> !Sync for ExtCtxt<'a>

impl<'a> Unpin for ExtCtxt<'a>

impl<'a> !UnwindSafe for ExtCtxt<'a>

Blanket Implementations

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

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

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

impl<'a, T> Captures<'a> for T where
    T: ?Sized
[src]

impl<T> Erased for T[src]

impl<T> From<T> for T[src]

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

impl<T> MaybeResult<T> for T[src]

type Error = !

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<E> SpecializationError for E[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.