[][src]Struct syntax::ext::base::ExtCtxt

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

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 ParseSessecfg: ExpansionConfig<'a>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
) -> 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, tts: &[TokenTree]) -> Parser<'a>[src]

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

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

pub fn cfg(&self) -> &CrateConfig[src]

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

pub fn backtrace(&self) -> SyntaxContext[src]

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

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

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

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

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)

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

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

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

pub fn span_unimpl<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) -> 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(&self)[src]

Trait Implementations

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

fn qpath(
    &self,
    self_type: P<Ty>,
    trait_path: Path,
    ident: Ident
) -> (QSelf, Path)
[src]

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: Ident,
    args: Vec<GenericArg>,
    bindings: Vec<TypeBinding>
) -> (QSelf, Path)
[src]

Constructs a qualified path.

Constructs a path like <self_type as trait_path>::ident<'a, T, A = Bar>.

fn expr_qpath(&self, span: Span, qself: QSelf, path: Path) -> P<Expr>[src]

Constructs a QPath expression.

Auto Trait Implementations

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

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

Blanket Implementations

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

impl<T> From<T> for T[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.

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

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

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

impl<E> SpecializationError for E[src]

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

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

impl<T> Erased for T[src]