Struct rustc_expand::proc_macro_server::Rustc
source · 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§
Trait Implementations§
source§impl FreeFunctions for Rustc<'_, '_>
impl FreeFunctions for Rustc<'_, '_>
source§fn injected_env_var(&mut self, var: &str) -> Option<String>
fn injected_env_var(&mut self, var: &str) -> Option<String>
proc_macro_internals
)source§fn track_env_var(&mut self, var: &str, value: Option<&str>)
fn track_env_var(&mut self, var: &str, value: Option<&str>)
proc_macro_internals
)source§fn track_path(&mut self, path: &str)
fn track_path(&mut self, path: &str)
proc_macro_internals
)source§fn literal_from_str(
&mut self,
s: &str,
) -> Result<Literal<Self::Span, Self::Symbol>, ()>
fn literal_from_str( &mut self, s: &str, ) -> Result<Literal<Self::Span, Self::Symbol>, ()>
proc_macro_internals
)source§fn emit_diagnostic(&mut self, diagnostic: Diagnostic<Self::Span>)
fn emit_diagnostic(&mut self, diagnostic: Diagnostic<Self::Span>)
proc_macro_internals
)source§fn drop(&mut self, self_: Self::FreeFunctions)
fn drop(&mut self, self_: Self::FreeFunctions)
proc_macro_internals
)source§impl Server for Rustc<'_, '_>
impl Server for Rustc<'_, '_>
source§fn globals(&mut self) -> ExpnGlobals<Self::Span>
fn globals(&mut self) -> ExpnGlobals<Self::Span>
proc_macro_internals
)source§fn intern_symbol(string: &str) -> Self::Symbol
fn intern_symbol(string: &str) -> Self::Symbol
proc_macro_internals
)source§impl SourceFile for Rustc<'_, '_>
impl SourceFile for Rustc<'_, '_>
source§fn eq(&mut self, file1: &Self::SourceFile, file2: &Self::SourceFile) -> bool
fn eq(&mut self, file1: &Self::SourceFile, file2: &Self::SourceFile) -> bool
proc_macro_internals
)source§fn path(&mut self, file: &Self::SourceFile) -> String
fn path(&mut self, file: &Self::SourceFile) -> String
proc_macro_internals
)source§fn is_real(&mut self, file: &Self::SourceFile) -> bool
fn is_real(&mut self, file: &Self::SourceFile) -> bool
proc_macro_internals
)source§fn drop(&mut self, self_: Self::SourceFile)
fn drop(&mut self, self_: Self::SourceFile)
proc_macro_internals
)source§fn clone(&mut self, self_: &Self::SourceFile) -> Self::SourceFile
fn clone(&mut self, self_: &Self::SourceFile) -> Self::SourceFile
proc_macro_internals
)source§impl Span for Rustc<'_, '_>
impl Span for Rustc<'_, '_>
source§fn save_span(&mut self, span: Self::Span) -> usize
🔬This is a nightly-only experimental API. (proc_macro_internals
)
fn save_span(&mut self, span: Self::Span) -> usize
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
fn debug(&mut self, span: Self::Span) -> String
proc_macro_internals
)source§fn source_file(&mut self, span: Self::Span) -> Self::SourceFile
fn source_file(&mut self, span: Self::Span) -> Self::SourceFile
proc_macro_internals
)source§fn parent(&mut self, span: Self::Span) -> Option<Self::Span>
fn parent(&mut self, span: Self::Span) -> Option<Self::Span>
proc_macro_internals
)source§fn source(&mut self, span: Self::Span) -> Self::Span
fn source(&mut self, span: Self::Span) -> Self::Span
proc_macro_internals
)source§fn byte_range(&mut self, span: Self::Span) -> Range<usize>
fn byte_range(&mut self, span: Self::Span) -> Range<usize>
proc_macro_internals
)source§fn start(&mut self, span: Self::Span) -> Self::Span
fn start(&mut self, span: Self::Span) -> Self::Span
proc_macro_internals
)source§fn end(&mut self, span: Self::Span) -> Self::Span
fn end(&mut self, span: Self::Span) -> Self::Span
proc_macro_internals
)source§fn line(&mut self, span: Self::Span) -> usize
fn line(&mut self, span: Self::Span) -> usize
proc_macro_internals
)source§fn column(&mut self, span: Self::Span) -> usize
fn column(&mut self, span: Self::Span) -> usize
proc_macro_internals
)source§fn join(&mut self, first: Self::Span, second: Self::Span) -> Option<Self::Span>
fn join(&mut self, first: Self::Span, second: Self::Span) -> Option<Self::Span>
proc_macro_internals
)source§fn subspan(
&mut self,
span: Self::Span,
start: Bound<usize>,
end: Bound<usize>,
) -> Option<Self::Span>
fn subspan( &mut self, span: Self::Span, start: Bound<usize>, end: Bound<usize>, ) -> Option<Self::Span>
proc_macro_internals
)source§fn resolved_at(&mut self, span: Self::Span, at: Self::Span) -> Self::Span
fn resolved_at(&mut self, span: Self::Span, at: Self::Span) -> Self::Span
proc_macro_internals
)source§fn source_text(&mut self, span: Self::Span) -> Option<String>
fn source_text(&mut self, span: Self::Span) -> Option<String>
proc_macro_internals
)source§fn recover_proc_macro_span(&mut self, id: usize) -> Self::Span
fn recover_proc_macro_span(&mut self, id: usize) -> Self::Span
proc_macro_internals
)source§impl TokenStream for Rustc<'_, '_>
impl TokenStream for Rustc<'_, '_>
source§fn is_empty(&mut self, stream: &Self::TokenStream) -> bool
fn is_empty(&mut self, stream: &Self::TokenStream) -> bool
proc_macro_internals
)source§fn from_str(&mut self, src: &str) -> Self::TokenStream
fn from_str(&mut self, src: &str) -> Self::TokenStream
proc_macro_internals
)source§fn to_string(&mut self, stream: &Self::TokenStream) -> String
fn to_string(&mut self, stream: &Self::TokenStream) -> String
proc_macro_internals
)source§fn expand_expr(
&mut self,
stream: &Self::TokenStream,
) -> Result<Self::TokenStream, ()>
fn expand_expr( &mut self, stream: &Self::TokenStream, ) -> Result<Self::TokenStream, ()>
proc_macro_internals
)source§fn from_token_tree(
&mut self,
tree: TokenTree<Self::TokenStream, Self::Span, Self::Symbol>,
) -> Self::TokenStream
fn from_token_tree( &mut self, tree: TokenTree<Self::TokenStream, Self::Span, Self::Symbol>, ) -> Self::TokenStream
proc_macro_internals
)source§fn concat_trees(
&mut self,
base: Option<Self::TokenStream>,
trees: Vec<TokenTree<Self::TokenStream, Self::Span, Self::Symbol>>,
) -> Self::TokenStream
fn concat_trees( &mut self, base: Option<Self::TokenStream>, trees: Vec<TokenTree<Self::TokenStream, Self::Span, Self::Symbol>>, ) -> Self::TokenStream
proc_macro_internals
)source§fn concat_streams(
&mut self,
base: Option<Self::TokenStream>,
streams: Vec<Self::TokenStream>,
) -> Self::TokenStream
fn concat_streams( &mut self, base: Option<Self::TokenStream>, streams: Vec<Self::TokenStream>, ) -> Self::TokenStream
proc_macro_internals
)source§fn into_trees(
&mut self,
stream: Self::TokenStream,
) -> Vec<TokenTree<Self::TokenStream, Self::Span, Self::Symbol>>
fn into_trees( &mut self, stream: Self::TokenStream, ) -> Vec<TokenTree<Self::TokenStream, Self::Span, Self::Symbol>>
proc_macro_internals
)source§fn drop(&mut self, self_: Self::TokenStream)
fn drop(&mut self, self_: Self::TokenStream)
proc_macro_internals
)source§fn clone(&mut self, self_: &Self::TokenStream) -> Self::TokenStream
fn clone(&mut self, self_: &Self::TokenStream) -> Self::TokenStream
proc_macro_internals
)source§impl Types for Rustc<'_, '_>
impl Types for Rustc<'_, '_>
source§type FreeFunctions = FreeFunctions
type FreeFunctions = FreeFunctions
proc_macro_internals
)source§type TokenStream = TokenStream
type TokenStream = TokenStream
proc_macro_internals
)source§type SourceFile = Rc<SourceFile>
type SourceFile = Rc<SourceFile>
proc_macro_internals
)Auto Trait Implementations§
impl<'a, 'b> Freeze for Rustc<'a, 'b>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
source§impl<T> Filterable for T
impl<T> Filterable for T
source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
source§impl<I, T> UpcastFrom<I, T> for T
impl<I, T> UpcastFrom<I, T> for T
fn upcast_from(from: T, _tcx: I) -> T
source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> MaybeSendSync for T
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