pub(crate) struct Rustc<'a, 'b> {
    ecx: &'a mut ExtCtxt<'b>,
    def_site: Span,
    call_site: Span,
    mixed_site: Span,
    krate: CrateNum,
    rebased_spans: FxHashMap<usize, Span>,
}

Fields§

§ecx: &'a mut ExtCtxt<'b>§def_site: Span§call_site: Span§mixed_site: Span§krate: CrateNum§rebased_spans: FxHashMap<usize, Span>

Implementations§

source§

impl<'a, 'b> Rustc<'a, 'b>

source

pub fn new(ecx: &'a mut ExtCtxt<'b>) -> Self

source

fn sess(&self) -> &ParseSess

Trait Implementations§

source§

impl FreeFunctions for Rustc<'_, '_>

source§

fn track_env_var(&mut self, var: &str, value: Option<&str>)

🔬This is a nightly-only experimental API. (proc_macro_internals)
source§

fn track_path(&mut self, path: &str)

🔬This is a nightly-only experimental API. (proc_macro_internals)
source§

fn literal_from_str( &mut self, s: &str ) -> Result<Literal<Self::Span, Self::Symbol>, ()>

🔬This is a nightly-only experimental API. (proc_macro_internals)
source§

fn emit_diagnostic(&mut self, diagnostic: Diagnostic<Self::Span>)

🔬This is a nightly-only experimental API. (proc_macro_internals)
source§

fn drop(&mut self, self_: Self::FreeFunctions)

🔬This is a nightly-only experimental API. (proc_macro_internals)
source§

impl Server for Rustc<'_, '_>

source§

fn globals(&mut self) -> ExpnGlobals<Self::Span>

🔬This is a nightly-only experimental API. (proc_macro_internals)
source§

fn intern_symbol(string: &str) -> Self::Symbol

🔬This is a nightly-only experimental API. (proc_macro_internals)
Intern a symbol received from RPC
source§

fn with_symbol_string(symbol: &Self::Symbol, f: impl FnOnce(&str))

🔬This is a nightly-only experimental API. (proc_macro_internals)
Recover the string value of a symbol, and invoke a callback with it.
source§

impl SourceFile for Rustc<'_, '_>

source§

fn eq(&mut self, file1: &Self::SourceFile, file2: &Self::SourceFile) -> bool

🔬This is a nightly-only experimental API. (proc_macro_internals)
source§

fn path(&mut self, file: &Self::SourceFile) -> String

🔬This is a nightly-only experimental API. (proc_macro_internals)
source§

fn is_real(&mut self, file: &Self::SourceFile) -> bool

🔬This is a nightly-only experimental API. (proc_macro_internals)
source§

fn drop(&mut self, self_: Self::SourceFile)

🔬This is a nightly-only experimental API. (proc_macro_internals)
source§

fn clone(&mut self, self_: &Self::SourceFile) -> Self::SourceFile

🔬This is a nightly-only experimental API. (proc_macro_internals)
source§

impl Span for Rustc<'_, '_>

source§

fn save_span(&mut self, span: Self::Span) -> usize

🔬This is a nightly-only experimental API. (proc_macro_internals)

Saves the provided span into the metadata of the crate we are currently compiling, which must be a proc-macro crate. This id can be passed to recover_proc_macro_span when our current crate is run as a proc-macro.

Let’s suppose that we have two crates - my_client and my_proc_macro. The my_proc_macro crate contains a procedural macro my_macro, which is implemented as: quote! { "hello" }

When we compile my_proc_macro, we will execute the quote proc-macro. This will save the span of “hello” into the metadata of my_proc_macro. As a result, the body of my_proc_macro (after expansion) will end up containing a call that looks like this: proc_macro::Ident::new("hello", proc_macro::Span::recover_proc_macro_span(0))

where 0 is the id returned by this function. When my_proc_macro executes (during the compilation of my_client), the call to recover_proc_macro_span will load the corresponding span from the metadata of my_proc_macro (which we have access to, since we’ve loaded my_proc_macro from disk in order to execute it). In this way, we have obtained a span pointing into my_proc_macro

source§

fn debug(&mut self, span: Self::Span) -> String

🔬This is a nightly-only experimental API. (proc_macro_internals)
source§

fn source_file(&mut self, span: Self::Span) -> Self::SourceFile

🔬This is a nightly-only experimental API. (proc_macro_internals)
source§

fn parent(&mut self, span: Self::Span) -> Option<Self::Span>

🔬This is a nightly-only experimental API. (proc_macro_internals)
source§

fn source(&mut self, span: Self::Span) -> Self::Span

🔬This is a nightly-only experimental API. (proc_macro_internals)
source§

fn byte_range(&mut self, span: Self::Span) -> Range<usize>

🔬This is a nightly-only experimental API. (proc_macro_internals)
source§

fn start(&mut self, span: Self::Span) -> Self::Span

🔬This is a nightly-only experimental API. (proc_macro_internals)
source§

fn end(&mut self, span: Self::Span) -> Self::Span

🔬This is a nightly-only experimental API. (proc_macro_internals)
source§

fn line(&mut self, span: Self::Span) -> usize

🔬This is a nightly-only experimental API. (proc_macro_internals)
source§

fn column(&mut self, span: Self::Span) -> usize

🔬This is a nightly-only experimental API. (proc_macro_internals)
source§

fn join(&mut self, first: Self::Span, second: Self::Span) -> Option<Self::Span>

🔬This is a nightly-only experimental API. (proc_macro_internals)
source§

fn subspan( &mut self, span: Self::Span, start: Bound<usize>, end: Bound<usize> ) -> Option<Self::Span>

🔬This is a nightly-only experimental API. (proc_macro_internals)
source§

fn resolved_at(&mut self, span: Self::Span, at: Self::Span) -> Self::Span

🔬This is a nightly-only experimental API. (proc_macro_internals)
source§

fn source_text(&mut self, span: Self::Span) -> Option<String>

🔬This is a nightly-only experimental API. (proc_macro_internals)
source§

fn recover_proc_macro_span(&mut self, id: usize) -> Self::Span

🔬This is a nightly-only experimental API. (proc_macro_internals)
source§

impl Symbol for Rustc<'_, '_>

source§

fn normalize_and_validate_ident( &mut self, string: &str ) -> Result<Self::Symbol, ()>

🔬This is a nightly-only experimental API. (proc_macro_internals)
source§

impl TokenStream for Rustc<'_, '_>

source§

fn is_empty(&mut self, stream: &Self::TokenStream) -> bool

🔬This is a nightly-only experimental API. (proc_macro_internals)
source§

fn from_str(&mut self, src: &str) -> Self::TokenStream

🔬This is a nightly-only experimental API. (proc_macro_internals)
source§

fn to_string(&mut self, stream: &Self::TokenStream) -> String

🔬This is a nightly-only experimental API. (proc_macro_internals)
source§

fn expand_expr( &mut self, stream: &Self::TokenStream ) -> Result<Self::TokenStream, ()>

🔬This is a nightly-only experimental API. (proc_macro_internals)
source§

fn from_token_tree( &mut self, tree: TokenTree<Self::TokenStream, Self::Span, Self::Symbol> ) -> Self::TokenStream

🔬This is a nightly-only experimental API. (proc_macro_internals)
source§

fn concat_trees( &mut self, base: Option<Self::TokenStream>, trees: Vec<TokenTree<Self::TokenStream, Self::Span, Self::Symbol>> ) -> Self::TokenStream

🔬This is a nightly-only experimental API. (proc_macro_internals)
source§

fn concat_streams( &mut self, base: Option<Self::TokenStream>, streams: Vec<Self::TokenStream> ) -> Self::TokenStream

🔬This is a nightly-only experimental API. (proc_macro_internals)
source§

fn into_trees( &mut self, stream: Self::TokenStream ) -> Vec<TokenTree<Self::TokenStream, Self::Span, Self::Symbol>>

🔬This is a nightly-only experimental API. (proc_macro_internals)
source§

fn drop(&mut self, self_: Self::TokenStream)

🔬This is a nightly-only experimental API. (proc_macro_internals)
source§

fn clone(&mut self, self_: &Self::TokenStream) -> Self::TokenStream

🔬This is a nightly-only experimental API. (proc_macro_internals)
source§

impl Types for Rustc<'_, '_>

§

type FreeFunctions = FreeFunctions

🔬This is a nightly-only experimental API. (proc_macro_internals)
§

type TokenStream = TokenStream

🔬This is a nightly-only experimental API. (proc_macro_internals)
§

type SourceFile = Rc<SourceFile, Global>

🔬This is a nightly-only experimental API. (proc_macro_internals)
§

type Span = Span

🔬This is a nightly-only experimental API. (proc_macro_internals)
§

type Symbol = Symbol

🔬This is a nightly-only experimental API. (proc_macro_internals)

Auto Trait Implementations§

§

impl<'a, 'b> !RefUnwindSafe for Rustc<'a, 'b>

§

impl<'a, 'b> !Send for Rustc<'a, 'b>

§

impl<'a, 'b> !Sync for Rustc<'a, 'b>

§

impl<'a, 'b> Unpin for Rustc<'a, 'b>

§

impl<'a, 'b> !UnwindSafe for Rustc<'a, 'b>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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, U> TryFrom<U> for Twhere 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 Twhere 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.

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