Struct syntax::ext::base::ExtCtxtExperimental
[-]
[+]
[src]
pub struct ExtCtxt<'a> { pub parse_sess: &'a ParseSess, pub cfg: CrateConfig, pub backtrace: ExpnId, pub ecfg: ExpansionConfig, pub mod_path: Vec<Ident>, pub trace_mac: bool, pub exported_macros: Vec<P<Item>>, pub syntax_env: SyntaxEnv, pub recursion_count: uint, }
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 | |
cfg | |
backtrace | |
ecfg | |
mod_path | |
trace_mac | |
exported_macros | |
syntax_env | |
recursion_count |
Methods
impl<'a> ExtCtxt<'a>
fn new(parse_sess: &'a ParseSess, cfg: CrateConfig, ecfg: ExpansionConfig) -> ExtCtxt<'a>
fn expand_expr(&mut self, e: P<Expr>) -> P<Expr>
fn expander<'b>(&'b mut self) -> MacroExpander<'b, 'a>
Returns a Folder
for deeply expanding all macros in a AST node.
fn new_parser_from_tts(&self, tts: &[TokenTree]) -> Parser<'a>
fn codemap(&self) -> &'a CodeMap
fn parse_sess(&self) -> &'a ParseSess
fn cfg(&self) -> CrateConfig
fn call_site(&self) -> Span
fn print_backtrace(&self)
fn backtrace(&self) -> ExpnId
fn original_span(&self) -> Span
fn original_span_in_file(&self) -> Span
fn mod_push(&mut self, i: Ident)
fn mod_pop(&mut self)
fn mod_path(&self) -> Vec<Ident>
fn bt_push(&mut self, ei: ExpnInfo)
fn bt_pop(&mut self)
fn span_fatal(&self, sp: Span, msg: &str) -> !
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)
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).