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
sourceimpl Diagnostic for Rustc<'_, '_>
impl Diagnostic for Rustc<'_, '_>
sourcefn new(
&mut self,
level: Level,
msg: &str,
spans: Self::MultiSpan
) -> Self::Diagnostic
fn new(
&mut self,
level: Level,
msg: &str,
spans: Self::MultiSpan
) -> Self::Diagnostic
proc_macro_internals
)sourcefn sub(
&mut self,
diag: &mut Self::Diagnostic,
level: Level,
msg: &str,
spans: Self::MultiSpan
)
fn sub(
&mut self,
diag: &mut Self::Diagnostic,
level: Level,
msg: &str,
spans: Self::MultiSpan
)
proc_macro_internals
)sourcefn emit(&mut self, diag: Self::Diagnostic)
fn emit(&mut self, diag: Self::Diagnostic)
proc_macro_internals
)sourcefn drop(&mut self, self_: Self::Diagnostic)
fn drop(&mut self, self_: Self::Diagnostic)
proc_macro_internals
)sourceimpl FreeFunctions for Rustc<'_, '_>
impl FreeFunctions for Rustc<'_, '_>
sourcefn track_env_var(&mut self, var: &str, value: Option<&str>)
fn track_env_var(&mut self, var: &str, value: Option<&str>)
proc_macro_internals
)sourcefn track_path(&mut self, path: &str)
fn track_path(&mut self, path: &str)
proc_macro_internals
)sourcefn drop(&mut self, self_: Self::FreeFunctions)
fn drop(&mut self, self_: Self::FreeFunctions)
proc_macro_internals
)sourceimpl Group for Rustc<'_, '_>
impl Group for Rustc<'_, '_>
sourcefn new(
&mut self,
delimiter: Delimiter,
stream: Option<Self::TokenStream>
) -> Self::Group
fn new(
&mut self,
delimiter: Delimiter,
stream: Option<Self::TokenStream>
) -> Self::Group
proc_macro_internals
)sourcefn delimiter(&mut self, group: &Self::Group) -> Delimiter
fn delimiter(&mut self, group: &Self::Group) -> Delimiter
proc_macro_internals
)sourcefn stream(&mut self, group: &Self::Group) -> Self::TokenStream
fn stream(&mut self, group: &Self::Group) -> Self::TokenStream
proc_macro_internals
)sourcefn span(&mut self, group: &Self::Group) -> Self::Span
fn span(&mut self, group: &Self::Group) -> Self::Span
proc_macro_internals
)sourcefn span_open(&mut self, group: &Self::Group) -> Self::Span
fn span_open(&mut self, group: &Self::Group) -> Self::Span
proc_macro_internals
)sourcefn span_close(&mut self, group: &Self::Group) -> Self::Span
fn span_close(&mut self, group: &Self::Group) -> Self::Span
proc_macro_internals
)sourcefn set_span(&mut self, group: &mut Self::Group, span: Self::Span)
fn set_span(&mut self, group: &mut Self::Group, span: Self::Span)
proc_macro_internals
)sourceimpl Ident for Rustc<'_, '_>
impl Ident for Rustc<'_, '_>
sourceimpl Literal for Rustc<'_, '_>
impl Literal for Rustc<'_, '_>
sourcefn from_str(&mut self, s: &str) -> Result<Self::Literal, ()>
fn from_str(&mut self, s: &str) -> Result<Self::Literal, ()>
proc_macro_internals
)sourcefn to_string(&mut self, literal: &Self::Literal) -> String
fn to_string(&mut self, literal: &Self::Literal) -> String
proc_macro_internals
)sourcefn debug_kind(&mut self, literal: &Self::Literal) -> String
fn debug_kind(&mut self, literal: &Self::Literal) -> String
proc_macro_internals
)sourcefn symbol(&mut self, literal: &Self::Literal) -> String
fn symbol(&mut self, literal: &Self::Literal) -> String
proc_macro_internals
)sourcefn suffix(&mut self, literal: &Self::Literal) -> Option<String>
fn suffix(&mut self, literal: &Self::Literal) -> Option<String>
proc_macro_internals
)sourcefn integer(&mut self, n: &str) -> Self::Literal
fn integer(&mut self, n: &str) -> Self::Literal
proc_macro_internals
)sourcefn typed_integer(&mut self, n: &str, kind: &str) -> Self::Literal
fn typed_integer(&mut self, n: &str, kind: &str) -> Self::Literal
proc_macro_internals
)sourcefn float(&mut self, n: &str) -> Self::Literal
fn float(&mut self, n: &str) -> Self::Literal
proc_macro_internals
)sourcefn f32(&mut self, n: &str) -> Self::Literal
fn f32(&mut self, n: &str) -> Self::Literal
proc_macro_internals
)sourcefn f64(&mut self, n: &str) -> Self::Literal
fn f64(&mut self, n: &str) -> Self::Literal
proc_macro_internals
)sourcefn string(&mut self, string: &str) -> Self::Literal
fn string(&mut self, string: &str) -> Self::Literal
proc_macro_internals
)sourcefn character(&mut self, ch: char) -> Self::Literal
fn character(&mut self, ch: char) -> Self::Literal
proc_macro_internals
)sourcefn byte_string(&mut self, bytes: &[u8]) -> Self::Literal
fn byte_string(&mut self, bytes: &[u8]) -> Self::Literal
proc_macro_internals
)sourcefn span(&mut self, literal: &Self::Literal) -> Self::Span
fn span(&mut self, literal: &Self::Literal) -> Self::Span
proc_macro_internals
)sourcefn set_span(&mut self, literal: &mut Self::Literal, span: Self::Span)
fn set_span(&mut self, literal: &mut Self::Literal, span: Self::Span)
proc_macro_internals
)sourcefn subspan(
&mut self,
literal: &Self::Literal,
start: Bound<usize>,
end: Bound<usize>
) -> Option<Self::Span>
fn subspan(
&mut self,
literal: &Self::Literal,
start: Bound<usize>,
end: Bound<usize>
) -> Option<Self::Span>
proc_macro_internals
)sourceimpl MultiSpan for Rustc<'_, '_>
impl MultiSpan for Rustc<'_, '_>
sourceimpl Punct for Rustc<'_, '_>
impl Punct for Rustc<'_, '_>
sourcefn new(&mut self, ch: char, spacing: Spacing) -> Self::Punct
fn new(&mut self, ch: char, spacing: Spacing) -> Self::Punct
proc_macro_internals
)sourcefn as_char(&mut self, punct: Self::Punct) -> char
fn as_char(&mut self, punct: Self::Punct) -> char
proc_macro_internals
)sourcefn spacing(&mut self, punct: Self::Punct) -> Spacing
fn spacing(&mut self, punct: Self::Punct) -> Spacing
proc_macro_internals
)sourceimpl SourceFile for Rustc<'_, '_>
impl SourceFile for Rustc<'_, '_>
sourcefn eq(&mut self, file1: &Self::SourceFile, file2: &Self::SourceFile) -> bool
fn eq(&mut self, file1: &Self::SourceFile, file2: &Self::SourceFile) -> bool
proc_macro_internals
)sourcefn path(&mut self, file: &Self::SourceFile) -> String
fn path(&mut self, file: &Self::SourceFile) -> String
proc_macro_internals
)sourcefn is_real(&mut self, file: &Self::SourceFile) -> bool
fn is_real(&mut self, file: &Self::SourceFile) -> bool
proc_macro_internals
)sourcefn drop(&mut self, self_: Self::SourceFile)
fn drop(&mut self, self_: Self::SourceFile)
proc_macro_internals
)sourcefn clone(&mut self, self_: &Self::SourceFile) -> Self::SourceFile
fn clone(&mut self, self_: &Self::SourceFile) -> Self::SourceFile
proc_macro_internals
)sourceimpl Span for Rustc<'_, '_>
impl Span for Rustc<'_, '_>
sourcefn 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
sourcefn debug(&mut self, span: Self::Span) -> String
fn debug(&mut self, span: Self::Span) -> String
proc_macro_internals
)sourcefn def_site(&mut self) -> Self::Span
fn def_site(&mut self) -> Self::Span
proc_macro_internals
)sourcefn call_site(&mut self) -> Self::Span
fn call_site(&mut self) -> Self::Span
proc_macro_internals
)sourcefn mixed_site(&mut self) -> Self::Span
fn mixed_site(&mut self) -> Self::Span
proc_macro_internals
)sourcefn source_file(&mut self, span: Self::Span) -> Self::SourceFile
fn source_file(&mut self, span: Self::Span) -> Self::SourceFile
proc_macro_internals
)sourcefn parent(&mut self, span: Self::Span) -> Option<Self::Span>
fn parent(&mut self, span: Self::Span) -> Option<Self::Span>
proc_macro_internals
)sourcefn source(&mut self, span: Self::Span) -> Self::Span
fn source(&mut self, span: Self::Span) -> Self::Span
proc_macro_internals
)sourcefn start(&mut self, span: Self::Span) -> LineColumn
fn start(&mut self, span: Self::Span) -> LineColumn
proc_macro_internals
)sourcefn end(&mut self, span: Self::Span) -> LineColumn
fn end(&mut self, span: Self::Span) -> LineColumn
proc_macro_internals
)sourcefn before(&mut self, span: Self::Span) -> Self::Span
fn before(&mut self, span: Self::Span) -> Self::Span
proc_macro_internals
)sourcefn after(&mut self, span: Self::Span) -> Self::Span
fn after(&mut self, span: Self::Span) -> Self::Span
proc_macro_internals
)sourcefn 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
)sourcefn 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
)sourcefn source_text(&mut self, span: Self::Span) -> Option<String>
fn source_text(&mut self, span: Self::Span) -> Option<String>
proc_macro_internals
)sourcefn recover_proc_macro_span(&mut self, id: usize) -> Self::Span
fn recover_proc_macro_span(&mut self, id: usize) -> Self::Span
proc_macro_internals
)sourceimpl TokenStream for Rustc<'_, '_>
impl TokenStream for Rustc<'_, '_>
sourcefn is_empty(&mut self, stream: &Self::TokenStream) -> bool
fn is_empty(&mut self, stream: &Self::TokenStream) -> bool
proc_macro_internals
)sourcefn from_str(&mut self, src: &str) -> Self::TokenStream
fn from_str(&mut self, src: &str) -> Self::TokenStream
proc_macro_internals
)sourcefn to_string(&mut self, stream: &Self::TokenStream) -> String
fn to_string(&mut self, stream: &Self::TokenStream) -> String
proc_macro_internals
)sourcefn expand_expr(
&mut self,
stream: &Self::TokenStream
) -> Result<Self::TokenStream, ()>
fn expand_expr(
&mut self,
stream: &Self::TokenStream
) -> Result<Self::TokenStream, ()>
proc_macro_internals
)sourcefn from_token_tree(
&mut self,
tree: TokenTree<Self::Group, Self::Punct, Self::Ident, Self::Literal>
) -> Self::TokenStream
fn from_token_tree(
&mut self,
tree: TokenTree<Self::Group, Self::Punct, Self::Ident, Self::Literal>
) -> Self::TokenStream
proc_macro_internals
)sourcefn concat_trees(
&mut self,
base: Option<Self::TokenStream>,
trees: Vec<TokenTree<Self::Group, Self::Punct, Self::Ident, Self::Literal>>
) -> Self::TokenStream
fn concat_trees(
&mut self,
base: Option<Self::TokenStream>,
trees: Vec<TokenTree<Self::Group, Self::Punct, Self::Ident, Self::Literal>>
) -> Self::TokenStream
proc_macro_internals
)sourcefn 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
)sourcefn into_trees(
&mut self,
stream: Self::TokenStream
) -> Vec<TokenTree<Self::Group, Self::Punct, Self::Ident, Self::Literal>>
fn into_trees(
&mut self,
stream: Self::TokenStream
) -> Vec<TokenTree<Self::Group, Self::Punct, Self::Ident, Self::Literal>>
proc_macro_internals
)sourcefn drop(&mut self, self_: Self::TokenStream)
fn drop(&mut self, self_: Self::TokenStream)
proc_macro_internals
)sourcefn clone(&mut self, self_: &Self::TokenStream) -> Self::TokenStream
fn clone(&mut self, self_: &Self::TokenStream) -> Self::TokenStream
proc_macro_internals
)sourceimpl Types for Rustc<'_, '_>
impl Types for Rustc<'_, '_>
type FreeFunctions = FreeFunctions
type FreeFunctions = FreeFunctions
proc_macro_internals
)type TokenStream = TokenStream
type TokenStream = TokenStream
proc_macro_internals
)type SourceFile = Rc<SourceFile>
type SourceFile = Rc<SourceFile>
proc_macro_internals
)type Diagnostic = Diagnostic
type Diagnostic = Diagnostic
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> where
'b: 'a,
impl<'a, 'b> !UnwindSafe for Rustc<'a, 'b>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
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