Struct rustc_expand::base::ExtCtxt

source ·
pub struct ExtCtxt<'a> {
    pub sess: &'a Session,
    pub ecfg: ExpansionConfig<'a>,
    pub num_standard_library_imports: usize,
    pub reduced_recursion_limit: Option<(Limit, ErrorGuaranteed)>,
    pub root_path: PathBuf,
    pub resolver: &'a mut dyn ResolverExpand,
    pub current_expansion: ExpansionData,
    pub force_mode: bool,
    pub expansions: FxIndexMap<Span, Vec<String>>,
    pub(crate) lint_store: Option<&'a (dyn LintStoreExpand + 'a)>,
    pub buffered_early_lint: Vec<BufferedEarlyLint>,
    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 Session§ecfg: ExpansionConfig<'a>§num_standard_library_imports: usize§reduced_recursion_limit: Option<(Limit, ErrorGuaranteed)>§root_path: PathBuf§resolver: &'a mut dyn ResolverExpand§current_expansion: ExpansionData§force_mode: bool

Error recovery mode entered when expansion is stuck (or during eager expansion, but that’s a hack).

§expansions: FxIndexMap<Span, Vec<String>>§lint_store: Option<&'a (dyn LintStoreExpand + 'a)>

Used for running pre-expansion lints on freshly loaded modules.

§buffered_early_lint: Vec<BufferedEarlyLint>

Used for storing lints generated during expansion, like NAMED_ARGUMENTS_USED_POSITIONALLY

§expanded_inert_attrs: MarkedAttrs

When 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§

source§

impl<'a> ExtCtxt<'a>

source

pub fn new( sess: &'a Session, ecfg: ExpansionConfig<'a>, resolver: &'a mut dyn ResolverExpand, lint_store: Option<&'a (dyn LintStoreExpand + 'a)> ) -> ExtCtxt<'a>

source

pub fn dcx(&self) -> &'a DiagCtxt

source

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

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

source

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

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.

source

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

source

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

source

pub fn psess(&self) -> &'a ParseSess

source

pub fn call_site(&self) -> Span

source

pub(crate) fn expansion_descr(&self) -> String

Returns the current expansion kind’s description.

source

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

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

source

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

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

source

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

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

source

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

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

Stops backtracing at include! boundary.

source

pub fn trace_macros_diag(&mut self)

source

pub fn trace_macros(&self) -> bool

source

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

source

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

source

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

source

pub fn check_unused_macros(&mut self)

source§

impl<'a> ExtCtxt<'a>

source

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

source

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

source

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

source

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

source

pub fn macro_call( &self, span: Span, path: Path, delim: Delimiter, tokens: TokenStream ) -> P<MacCall>

source

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

source

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

source

pub fn ty_infer(&self, span: Span) -> P<Ty>

source

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

source

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

source

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

source

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

source

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

source

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

source

pub fn typaram( &self, span: Span, ident: Ident, bounds: GenericBounds, default: Option<P<Ty>> ) -> GenericParam

source

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

source

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

source

pub fn trait_bound(&self, path: Path, is_const: bool) -> GenericBound

source

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

source

pub fn lifetime_static(&self, span: Span) -> Lifetime

source

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

source

pub fn stmt_let_pat(&self, sp: Span, pat: P<Pat>, ex: P<Expr>) -> Stmt

source

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

source

pub fn stmt_let_ty( &self, sp: Span, mutbl: bool, ident: Ident, ty: Option<P<Ty>>, ex: P<Expr> ) -> Stmt

source

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

Generates let _: Type;, which is usually used for type assertions.

source

pub fn stmt_local(&self, local: P<Local>, span: Span) -> Stmt

source

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

source

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

source

pub fn block(&self, span: Span, stmts: ThinVec<Stmt>) -> P<Block>

source

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

source

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

source

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

source

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

source

pub fn expr_field(&self, span: Span, expr: P<Expr>, field: Ident) -> P<Expr>

source

pub fn expr_macro_call(&self, span: Span, call: P<MacCall>) -> P<Expr>

source

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

source

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

source

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

source

pub fn expr_paren(&self, sp: Span, e: P<Expr>) -> P<Expr>

source

pub fn expr_call( &self, span: Span, expr: P<Expr>, args: ThinVec<P<Expr>> ) -> P<Expr>

source

pub fn expr_call_ident( &self, span: Span, id: Ident, args: ThinVec<P<Expr>> ) -> P<Expr>

source

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

source

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

source

pub fn field_imm(&self, span: Span, ident: Ident, e: P<Expr>) -> ExprField

source

pub fn expr_struct( &self, span: Span, path: Path, fields: ThinVec<ExprField> ) -> P<Expr>

source

pub fn expr_struct_ident( &self, span: Span, id: Ident, fields: ThinVec<ExprField> ) -> P<Expr>

source

pub fn expr_usize(&self, span: Span, n: usize) -> P<Expr>

source

pub fn expr_u32(&self, span: Span, n: u32) -> P<Expr>

source

pub fn expr_bool(&self, span: Span, value: bool) -> P<Expr>

source

pub fn expr_str(&self, span: Span, s: Symbol) -> P<Expr>

source

pub fn expr_char(&self, span: Span, ch: char) -> P<Expr>

source

pub fn expr_byte_str(&self, span: Span, bytes: Vec<u8>) -> P<Expr>

source

pub fn expr_array(&self, sp: Span, exprs: ThinVec<P<Expr>>) -> P<Expr>

[expr1, expr2, ...]

source

pub fn expr_array_ref(&self, sp: Span, exprs: ThinVec<P<Expr>>) -> P<Expr>

&[expr1, expr2, ...]

source

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

source

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

source

pub fn expr_none(&self, sp: Span) -> P<Expr>

source

pub fn expr_tuple(&self, sp: Span, exprs: ThinVec<P<Expr>>) -> P<Expr>

source

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

source

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

source

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

source

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

source

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

source

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

source

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

source

pub fn pat_ident_binding_mode( &self, span: Span, ident: Ident, ann: BindingMode ) -> P<Pat>

source

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

source

pub fn pat_tuple_struct( &self, span: Span, path: Path, subpats: ThinVec<P<Pat>> ) -> P<Pat>

source

pub fn pat_struct( &self, span: Span, path: Path, field_pats: ThinVec<PatField> ) -> P<Pat>

source

pub fn pat_tuple(&self, span: Span, pats: ThinVec<P<Pat>>) -> P<Pat>

source

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

source

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

source

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

source

pub fn expr_match( &self, span: Span, arg: P<Expr>, arms: ThinVec<Arm> ) -> P<Expr>

source

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

source

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

source

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

source

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

source

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

source

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

source

pub fn fn_decl(&self, inputs: ThinVec<Param>, output: FnRetTy) -> P<FnDecl>

source

pub fn item( &self, span: Span, name: Ident, attrs: AttrVec, kind: ItemKind ) -> P<Item>

source

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

source

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

source

pub fn attr_word(&self, name: Symbol, span: Span) -> Attribute

source

pub fn attr_name_value_str( &self, name: Symbol, val: Symbol, span: Span ) -> Attribute

source

pub fn attr_nested_word( &self, outer: Symbol, inner: Symbol, span: Span ) -> Attribute

Auto Trait Implementations§

§

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

§

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

§

impl<'a> Freeze for ExtCtxt<'a>

§

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§

source§

impl<T> Aligned for T

source§

const ALIGN: Alignment = _

Alignment of Self.
source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, R> CollectAndApply<T, R> for T

source§

fn collect_and_apply<I, F>(iter: I, f: F) -> R
where I: Iterator<Item = T>, F: FnOnce(&[T]) -> R,

Equivalent to f(&iter.collect::<Vec<_>>()).

§

type Output = R

source§

impl<T> Filterable for T

source§

fn filterable( self, filter_name: &'static str ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>

Creates a filterable data provider with the given name for debugging. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

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

source§

impl<T> ErasedDestructor for T
where T: 'static,

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: 296 bytes