Struct syntax::ext::base::ExtCtxt
[−]
[src]
pub struct ExtCtxt<'a> { pub parse_sess: &'a ParseSess, pub ecfg: ExpansionConfig<'a>, pub crate_root: Option<&'static str>, pub resolver: &'a mut Resolver, pub resolve_err_count: usize, pub current_expansion: ExpansionData, }
rustc_private
)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_info of their expansion context stored into their span.
Fields
parse_sess: &'a ParseSess
rustc_private
)ecfg: ExpansionConfig<'a>
rustc_private
)crate_root: Option<&'static str>
rustc_private
)resolver: &'a mut Resolver
rustc_private
)resolve_err_count: usize
rustc_private
)current_expansion: ExpansionData
rustc_private
)Methods
impl<'a> ExtCtxt<'a>
[src]
fn new(parse_sess: &'a ParseSess,
ecfg: ExpansionConfig<'a>,
resolver: &'a mut Resolver)
-> ExtCtxt<'a>
ecfg: ExpansionConfig<'a>,
resolver: &'a mut Resolver)
-> ExtCtxt<'a>
rustc_private
)fn expander<'b>(&'b mut self) -> MacroExpander<'b, 'a>
rustc_private
)Returns a Folder
for deeply expanding all macros in an AST node.
fn monotonic_expander<'b>(&'b mut self) -> MacroExpander<'b, 'a>
rustc_private
)Returns a Folder
that deeply expands all macros and assigns all node ids in an AST node.
Once node ids are assigned, the node may not be expanded, removed, or otherwise modified.
fn new_parser_from_tts(&self, tts: &[TokenTree]) -> Parser<'a>
rustc_private
)fn codemap(&self) -> &'a CodeMap
rustc_private
)fn parse_sess(&self) -> &'a ParseSess
rustc_private
)fn cfg(&self) -> &CrateConfig
rustc_private
)fn call_site(&self) -> Span
rustc_private
)fn backtrace(&self) -> ExpnId
rustc_private
)fn expansion_cause(&self) -> Span
rustc_private
)Returns span for the macro which originally caused the current expansion to happen.
Stops backtracing at include! boundary.
fn bt_push(&mut self, ei: ExpnInfo)
rustc_private
)fn bt_pop(&mut self)
rustc_private
)fn struct_span_warn(&self, sp: Span, msg: &str) -> DiagnosticBuilder<'a>
rustc_private
)fn struct_span_err(&self, sp: Span, msg: &str) -> DiagnosticBuilder<'a>
rustc_private
)fn struct_span_fatal(&self, sp: Span, msg: &str) -> DiagnosticBuilder<'a>
rustc_private
)fn span_fatal(&self, sp: Span, msg: &str) -> !
rustc_private
)Emit msg
attached to sp
, and stop compilation immediately.
span_err
should be strongly preferred where-ever possible:
this should only be used when
- continuing has a high risk of flow-on errors (e.g. errors in
declaring a macro would cause all uses of that macro to
complain about "undefined macro"), or
- there is literally nothing else that can be done (however,
in most cases one can construct a dummy expression/item to
substitute; we never hit resolve/type-checking so the dummy
value doesn't have to match anything)
fn span_err(&self, sp: Span, msg: &str)
rustc_private
)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).
fn span_warn(&self, sp: Span, msg: &str)
rustc_private
)fn span_unimpl(&self, sp: Span, msg: &str) -> !
rustc_private
)fn span_bug(&self, sp: Span, msg: &str) -> !
rustc_private
)fn bug(&self, msg: &str) -> !
rustc_private
)fn trace_macros(&self) -> bool
rustc_private
)fn set_trace_macros(&mut self, x: bool)
rustc_private
)fn ident_of(&self, st: &str) -> Ident
rustc_private
)fn std_path(&self, components: &[&str]) -> Vec<Ident>
rustc_private
)fn name_of(&self, st: &str) -> Name
rustc_private
)Trait Implementations
impl<'a> AstBuilder for ExtCtxt<'a>
[src]
fn path(&self, span: Span, strs: Vec<Ident>) -> Path
rustc_private
)fn path_ident(&self, span: Span, id: Ident) -> Path
rustc_private
)fn path_global(&self, span: Span, strs: Vec<Ident>) -> Path
rustc_private
)fn path_all(&self,
sp: Span,
global: bool,
idents: Vec<Ident>,
lifetimes: Vec<Lifetime>,
types: Vec<P<Ty>>,
bindings: Vec<TypeBinding>)
-> Path
sp: Span,
global: bool,
idents: Vec<Ident>,
lifetimes: Vec<Lifetime>,
types: Vec<P<Ty>>,
bindings: Vec<TypeBinding>)
-> Path
rustc_private
)fn qpath(&self,
self_type: P<Ty>,
trait_path: Path,
ident: SpannedIdent)
-> (QSelf, Path)
self_type: P<Ty>,
trait_path: Path,
ident: SpannedIdent)
-> (QSelf, Path)
rustc_private
)Constructs a qualified path.
Constructs a path like <self_type as trait_path>::ident
.
fn qpath_all(&self,
self_type: P<Ty>,
trait_path: Path,
ident: SpannedIdent,
lifetimes: Vec<Lifetime>,
types: Vec<P<Ty>>,
bindings: Vec<TypeBinding>)
-> (QSelf, Path)
self_type: P<Ty>,
trait_path: Path,
ident: SpannedIdent,
lifetimes: Vec<Lifetime>,
types: Vec<P<Ty>>,
bindings: Vec<TypeBinding>)
-> (QSelf, Path)
rustc_private
)Constructs a qualified path.
Constructs a path like <self_type as trait_path>::ident<'a, T, A=Bar>
.
fn ty_mt(&self, ty: P<Ty>, mutbl: Mutability) -> MutTy
rustc_private
)fn ty(&self, span: Span, ty: TyKind) -> P<Ty>
rustc_private
)fn ty_path(&self, path: Path) -> P<Ty>
rustc_private
)fn ty_ident(&self, span: Span, ident: Ident) -> P<Ty>
rustc_private
)fn ty_rptr(&self,
span: Span,
ty: P<Ty>,
lifetime: Option<Lifetime>,
mutbl: Mutability)
-> P<Ty>
span: Span,
ty: P<Ty>,
lifetime: Option<Lifetime>,
mutbl: Mutability)
-> P<Ty>
rustc_private
)fn ty_ptr(&self, span: Span, ty: P<Ty>, mutbl: Mutability) -> P<Ty>
rustc_private
)fn ty_option(&self, ty: P<Ty>) -> P<Ty>
rustc_private
)fn ty_infer(&self, span: Span) -> P<Ty>
rustc_private
)fn typaram(&self,
span: Span,
id: Ident,
attrs: Vec<Attribute>,
bounds: TyParamBounds,
default: Option<P<Ty>>)
-> TyParam
span: Span,
id: Ident,
attrs: Vec<Attribute>,
bounds: TyParamBounds,
default: Option<P<Ty>>)
-> TyParam
rustc_private
)fn trait_ref(&self, path: Path) -> TraitRef
rustc_private
)fn poly_trait_ref(&self, span: Span, path: Path) -> PolyTraitRef
rustc_private
)fn typarambound(&self, path: Path) -> TyParamBound
rustc_private
)fn lifetime(&self, span: Span, name: Name) -> Lifetime
rustc_private
)fn lifetime_def(&self,
span: Span,
name: Name,
attrs: Vec<Attribute>,
bounds: Vec<Lifetime>)
-> LifetimeDef
span: Span,
name: Name,
attrs: Vec<Attribute>,
bounds: Vec<Lifetime>)
-> LifetimeDef
rustc_private
)fn stmt_expr(&self, expr: P<Expr>) -> Stmt
rustc_private
)fn stmt_semi(&self, expr: P<Expr>) -> Stmt
rustc_private
)fn stmt_let(&self, sp: Span, mutbl: bool, ident: Ident, ex: P<Expr>) -> Stmt
rustc_private
)fn stmt_let_typed(&self,
sp: Span,
mutbl: bool,
ident: Ident,
typ: P<Ty>,
ex: P<Expr>)
-> Stmt
sp: Span,
mutbl: bool,
ident: Ident,
typ: P<Ty>,
ex: P<Expr>)
-> Stmt
rustc_private
)fn stmt_let_type_only(&self, span: Span, ty: P<Ty>) -> Stmt
rustc_private
)fn stmt_item(&self, sp: Span, item: P<Item>) -> Stmt
rustc_private
)fn block_expr(&self, expr: P<Expr>) -> P<Block>
rustc_private
)fn block(&self, span: Span, stmts: Vec<Stmt>) -> P<Block>
rustc_private
)fn expr(&self, span: Span, node: ExprKind) -> P<Expr>
rustc_private
)fn expr_path(&self, path: Path) -> P<Expr>
rustc_private
)fn expr_qpath(&self, span: Span, qself: QSelf, path: Path) -> P<Expr>
rustc_private
)Constructs a QPath expression.
fn expr_ident(&self, span: Span, id: Ident) -> P<Expr>
rustc_private
)fn expr_self(&self, span: Span) -> P<Expr>
rustc_private
)fn expr_binary(&self,
sp: Span,
op: BinOpKind,
lhs: P<Expr>,
rhs: P<Expr>)
-> P<Expr>
sp: Span,
op: BinOpKind,
lhs: P<Expr>,
rhs: P<Expr>)
-> P<Expr>
rustc_private
)fn expr_deref(&self, sp: Span, e: P<Expr>) -> P<Expr>
rustc_private
)fn expr_unary(&self, sp: Span, op: UnOp, e: P<Expr>) -> P<Expr>
rustc_private
)fn expr_field_access(&self, sp: Span, expr: P<Expr>, ident: Ident) -> P<Expr>
rustc_private
)fn expr_tup_field_access(&self, sp: Span, expr: P<Expr>, idx: usize) -> P<Expr>
rustc_private
)fn expr_addr_of(&self, sp: Span, e: P<Expr>) -> P<Expr>
rustc_private
)fn expr_mut_addr_of(&self, sp: Span, e: P<Expr>) -> P<Expr>
rustc_private
)fn expr_call(&self, span: Span, expr: P<Expr>, args: Vec<P<Expr>>) -> P<Expr>
rustc_private
)fn expr_call_ident(&self, span: Span, id: Ident, args: Vec<P<Expr>>) -> P<Expr>
rustc_private
)fn expr_call_global(&self,
sp: Span,
fn_path: Vec<Ident>,
args: Vec<P<Expr>>)
-> P<Expr>
sp: Span,
fn_path: Vec<Ident>,
args: Vec<P<Expr>>)
-> P<Expr>
rustc_private
)fn expr_method_call(&self,
span: Span,
expr: P<Expr>,
ident: Ident,
args: Vec<P<Expr>>)
-> P<Expr>
span: Span,
expr: P<Expr>,
ident: Ident,
args: Vec<P<Expr>>)
-> P<Expr>
rustc_private
)fn expr_block(&self, b: P<Block>) -> P<Expr>
rustc_private
)fn field_imm(&self, span: Span, name: Ident, e: P<Expr>) -> Field
rustc_private
)fn expr_struct(&self, span: Span, path: Path, fields: Vec<Field>) -> P<Expr>
rustc_private
)fn expr_struct_ident(&self,
span: Span,
id: Ident,
fields: Vec<Field>)
-> P<Expr>
span: Span,
id: Ident,
fields: Vec<Field>)
-> P<Expr>
rustc_private
)fn expr_lit(&self, sp: Span, lit: LitKind) -> P<Expr>
rustc_private
)fn expr_usize(&self, span: Span, i: usize) -> P<Expr>
rustc_private
)fn expr_isize(&self, sp: Span, i: isize) -> P<Expr>
rustc_private
)fn expr_u32(&self, sp: Span, u: u32) -> P<Expr>
rustc_private
)fn expr_u8(&self, sp: Span, u: u8) -> P<Expr>
rustc_private
)fn expr_bool(&self, sp: Span, value: bool) -> P<Expr>
rustc_private
)fn expr_vec(&self, sp: Span, exprs: Vec<P<Expr>>) -> P<Expr>
rustc_private
)fn expr_vec_ng(&self, sp: Span) -> P<Expr>
rustc_private
)fn expr_vec_slice(&self, sp: Span, exprs: Vec<P<Expr>>) -> P<Expr>
rustc_private
)fn expr_str(&self, sp: Span, s: Symbol) -> P<Expr>
rustc_private
)fn expr_cast(&self, sp: Span, expr: P<Expr>, ty: P<Ty>) -> P<Expr>
rustc_private
)fn expr_some(&self, sp: Span, expr: P<Expr>) -> P<Expr>
rustc_private
)fn expr_none(&self, sp: Span) -> P<Expr>
rustc_private
)fn expr_break(&self, sp: Span) -> P<Expr>
rustc_private
)fn expr_tuple(&self, sp: Span, exprs: Vec<P<Expr>>) -> P<Expr>
rustc_private
)fn expr_fail(&self, span: Span, msg: Symbol) -> P<Expr>
rustc_private
)fn expr_unreachable(&self, span: Span) -> P<Expr>
rustc_private
)fn expr_ok(&self, sp: Span, expr: P<Expr>) -> P<Expr>
rustc_private
)fn expr_err(&self, sp: Span, expr: P<Expr>) -> P<Expr>
rustc_private
)fn expr_try(&self, sp: Span, head: P<Expr>) -> P<Expr>
rustc_private
)fn pat(&self, span: Span, pat: PatKind) -> P<Pat>
rustc_private
)fn pat_wild(&self, span: Span) -> P<Pat>
rustc_private
)fn pat_lit(&self, span: Span, expr: P<Expr>) -> P<Pat>
rustc_private
)fn pat_ident(&self, span: Span, ident: Ident) -> P<Pat>
rustc_private
)fn pat_ident_binding_mode(&self,
span: Span,
ident: Ident,
bm: BindingMode)
-> P<Pat>
span: Span,
ident: Ident,
bm: BindingMode)
-> P<Pat>
rustc_private
)fn pat_path(&self, span: Span, path: Path) -> P<Pat>
rustc_private
)fn pat_tuple_struct(&self,
span: Span,
path: Path,
subpats: Vec<P<Pat>>)
-> P<Pat>
span: Span,
path: Path,
subpats: Vec<P<Pat>>)
-> P<Pat>
rustc_private
)fn pat_struct(&self,
span: Span,
path: Path,
field_pats: Vec<Spanned<FieldPat>>)
-> P<Pat>
span: Span,
path: Path,
field_pats: Vec<Spanned<FieldPat>>)
-> P<Pat>
rustc_private
)fn pat_tuple(&self, span: Span, pats: Vec<P<Pat>>) -> P<Pat>
rustc_private
)fn pat_some(&self, span: Span, pat: P<Pat>) -> P<Pat>
rustc_private
)fn pat_none(&self, span: Span) -> P<Pat>
rustc_private
)fn pat_ok(&self, span: Span, pat: P<Pat>) -> P<Pat>
rustc_private
)fn pat_err(&self, span: Span, pat: P<Pat>) -> P<Pat>
rustc_private
)fn arm(&self, _span: Span, pats: Vec<P<Pat>>, expr: P<Expr>) -> Arm
rustc_private
)fn arm_unreachable(&self, span: Span) -> Arm
rustc_private
)fn expr_match(&self, span: Span, arg: P<Expr>, arms: Vec<Arm>) -> P<Expr>
rustc_private
)fn expr_if(&self,
span: Span,
cond: P<Expr>,
then: P<Expr>,
els: Option<P<Expr>>)
-> P<Expr>
span: Span,
cond: P<Expr>,
then: P<Expr>,
els: Option<P<Expr>>)
-> P<Expr>
rustc_private
)fn expr_loop(&self, span: Span, block: P<Block>) -> P<Expr>
rustc_private
)fn lambda_fn_decl(&self,
span: Span,
fn_decl: P<FnDecl>,
body: P<Expr>,
fn_decl_span: Span)
-> P<Expr>
span: Span,
fn_decl: P<FnDecl>,
body: P<Expr>,
fn_decl_span: Span)
-> P<Expr>
rustc_private
)fn lambda(&self, span: Span, ids: Vec<Ident>, body: P<Expr>) -> P<Expr>
rustc_private
)fn lambda0(&self, span: Span, body: P<Expr>) -> P<Expr>
rustc_private
)fn lambda1(&self, span: Span, body: P<Expr>, ident: Ident) -> P<Expr>
rustc_private
)fn lambda_stmts(&self, span: Span, ids: Vec<Ident>, stmts: Vec<Stmt>) -> P<Expr>
rustc_private
)fn lambda_stmts_0(&self, span: Span, stmts: Vec<Stmt>) -> P<Expr>
rustc_private
)fn lambda_stmts_1(&self, span: Span, stmts: Vec<Stmt>, ident: Ident) -> P<Expr>
rustc_private
)fn arg(&self, span: Span, ident: Ident, ty: P<Ty>) -> Arg
rustc_private
)fn fn_decl(&self, inputs: Vec<Arg>, output: P<Ty>) -> P<FnDecl>
rustc_private
)fn item(&self,
span: Span,
name: Ident,
attrs: Vec<Attribute>,
node: ItemKind)
-> P<Item>
span: Span,
name: Ident,
attrs: Vec<Attribute>,
node: ItemKind)
-> P<Item>
rustc_private
)fn item_fn_poly(&self,
span: Span,
name: Ident,
inputs: Vec<Arg>,
output: P<Ty>,
generics: Generics,
body: P<Block>)
-> P<Item>
span: Span,
name: Ident,
inputs: Vec<Arg>,
output: P<Ty>,
generics: Generics,
body: P<Block>)
-> P<Item>
rustc_private
)fn item_fn(&self,
span: Span,
name: Ident,
inputs: Vec<Arg>,
output: P<Ty>,
body: P<Block>)
-> P<Item>
span: Span,
name: Ident,
inputs: Vec<Arg>,
output: P<Ty>,
body: P<Block>)
-> P<Item>
rustc_private
)fn variant(&self, span: Span, name: Ident, tys: Vec<P<Ty>>) -> Variant
rustc_private
)fn item_enum_poly(&self,
span: Span,
name: Ident,
enum_definition: EnumDef,
generics: Generics)
-> P<Item>
span: Span,
name: Ident,
enum_definition: EnumDef,
generics: Generics)
-> P<Item>
rustc_private
)fn item_enum(&self,
span: Span,
name: Ident,
enum_definition: EnumDef)
-> P<Item>
span: Span,
name: Ident,
enum_definition: EnumDef)
-> P<Item>
rustc_private
)fn item_struct(&self,
span: Span,
name: Ident,
struct_def: VariantData)
-> P<Item>
span: Span,
name: Ident,
struct_def: VariantData)
-> P<Item>
rustc_private
)fn item_struct_poly(&self,
span: Span,
name: Ident,
struct_def: VariantData,
generics: Generics)
-> P<Item>
span: Span,
name: Ident,
struct_def: VariantData,
generics: Generics)
-> P<Item>
rustc_private
)fn item_mod(&self,
span: Span,
inner_span: Span,
name: Ident,
attrs: Vec<Attribute>,
items: Vec<P<Item>>)
-> P<Item>
span: Span,
inner_span: Span,
name: Ident,
attrs: Vec<Attribute>,
items: Vec<P<Item>>)
-> P<Item>
rustc_private
)fn item_static(&self,
span: Span,
name: Ident,
ty: P<Ty>,
mutbl: Mutability,
expr: P<Expr>)
-> P<Item>
span: Span,
name: Ident,
ty: P<Ty>,
mutbl: Mutability,
expr: P<Expr>)
-> P<Item>
rustc_private
)fn item_const(&self,
span: Span,
name: Ident,
ty: P<Ty>,
expr: P<Expr>)
-> P<Item>
span: Span,
name: Ident,
ty: P<Ty>,
expr: P<Expr>)
-> P<Item>
rustc_private
)fn item_ty_poly(&self,
span: Span,
name: Ident,
ty: P<Ty>,
generics: Generics)
-> P<Item>
span: Span,
name: Ident,
ty: P<Ty>,
generics: Generics)
-> P<Item>
rustc_private
)fn item_ty(&self, span: Span, name: Ident, ty: P<Ty>) -> P<Item>
rustc_private
)fn attribute(&self, sp: Span, mi: MetaItem) -> Attribute
rustc_private
)fn meta_word(&self, sp: Span, w: Name) -> MetaItem
rustc_private
)fn meta_list_item_word(&self, sp: Span, w: Name) -> NestedMetaItem
rustc_private
)fn meta_list(&self, sp: Span, name: Name, mis: Vec<NestedMetaItem>) -> MetaItem
rustc_private
)fn meta_name_value(&self, sp: Span, name: Name, value: LitKind) -> MetaItem
rustc_private
)fn item_use(&self, sp: Span, vis: Visibility, vp: P<ViewPath>) -> P<Item>
rustc_private
)fn item_use_simple(&self, sp: Span, vis: Visibility, path: Path) -> P<Item>
rustc_private
)fn item_use_simple_(&self,
sp: Span,
vis: Visibility,
ident: Ident,
path: Path)
-> P<Item>
sp: Span,
vis: Visibility,
ident: Ident,
path: Path)
-> P<Item>
rustc_private
)fn item_use_list(&self,
sp: Span,
vis: Visibility,
path: Vec<Ident>,
imports: &[Ident])
-> P<Item>
sp: Span,
vis: Visibility,
path: Vec<Ident>,
imports: &[Ident])
-> P<Item>
rustc_private
)fn item_use_glob(&self, sp: Span, vis: Visibility, path: Vec<Ident>) -> P<Item>
rustc_private
)impl<'a> ExtParseUtils for ExtCtxt<'a>
[src]
fn parse_item(&self, s: String) -> P<Item>
rustc_private
)fn parse_stmt(&self, s: String) -> Stmt
rustc_private
)fn parse_expr(&self, s: String) -> P<Expr>
rustc_private
)fn parse_tts(&self, s: String) -> Vec<TokenTree>
rustc_private
)