Struct syntex_syntax::ext::base::ExtCtxt
[−]
[src]
pub struct ExtCtxt<'a> { pub parse_sess: &'a ParseSess, pub cfg: CrateConfig, pub backtrace: ExpnId, pub ecfg: ExpansionConfig<'a>, pub crate_root: Option<&'static str>, pub feature_gated_cfgs: &'a mut Vec<GatedCfgAttr>, pub mod_path: Vec<Ident>, pub exported_macros: Vec<MacroDef>, pub syntax_env: SyntaxEnv, pub recursion_count: usize, }
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 | |
crate_root | |
feature_gated_cfgs | |
mod_path | |
exported_macros | |
syntax_env | |
recursion_count |
Methods
impl<'a> ExtCtxt<'a>
fn new(parse_sess: &'a ParseSess, cfg: CrateConfig, ecfg: ExpansionConfig<'a>, feature_gated_cfgs: &'a mut Vec<GatedCfgAttr>) -> ExtCtxt<'a>
fn expander<'b>(&'b mut self) -> MacroExpander<'b, 'a>
Returns a Folder
for deeply expanding all macros in an 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 backtrace(&self) -> ExpnId
fn original_span(&self) -> Span
Original span that caused the current exapnsion to happen.
fn expansion_cause(&self) -> Span
Returns span for the macro which originally caused the current expansion to happen.
Stops backtracing at include! boundary.
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 insert_macro(&mut self, def: MacroDef)
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).