Fix review comments
This commit is contained in:
parent
d9ec1aef8d
commit
e8c48c6895
6 changed files with 76 additions and 78 deletions
|
|
@ -566,19 +566,19 @@ impl server::Server for Rustc<'_, '_> {
|
|||
diag.emit();
|
||||
}
|
||||
|
||||
fn tt_drop(&mut self, stream: Self::TokenStream) {
|
||||
fn ts_drop(&mut self, stream: Self::TokenStream) {
|
||||
drop(stream);
|
||||
}
|
||||
|
||||
fn tt_clone(&mut self, stream: &Self::TokenStream) -> Self::TokenStream {
|
||||
fn ts_clone(&mut self, stream: &Self::TokenStream) -> Self::TokenStream {
|
||||
stream.clone()
|
||||
}
|
||||
|
||||
fn tt_is_empty(&mut self, stream: &Self::TokenStream) -> bool {
|
||||
fn ts_is_empty(&mut self, stream: &Self::TokenStream) -> bool {
|
||||
stream.is_empty()
|
||||
}
|
||||
|
||||
fn tt_from_str(&mut self, src: &str) -> Self::TokenStream {
|
||||
fn ts_from_str(&mut self, src: &str) -> Self::TokenStream {
|
||||
unwrap_or_emit_fatal(source_str_to_stream(
|
||||
self.psess(),
|
||||
FileName::proc_macro_source_code(src),
|
||||
|
|
@ -587,11 +587,11 @@ impl server::Server for Rustc<'_, '_> {
|
|||
))
|
||||
}
|
||||
|
||||
fn tt_to_string(&mut self, stream: &Self::TokenStream) -> String {
|
||||
fn ts_to_string(&mut self, stream: &Self::TokenStream) -> String {
|
||||
pprust::tts_to_string(stream)
|
||||
}
|
||||
|
||||
fn tt_expand_expr(&mut self, stream: &Self::TokenStream) -> Result<Self::TokenStream, ()> {
|
||||
fn ts_expand_expr(&mut self, stream: &Self::TokenStream) -> Result<Self::TokenStream, ()> {
|
||||
// Parse the expression from our tokenstream.
|
||||
let expr: PResult<'_, _> = try {
|
||||
let mut p = Parser::new(self.psess(), stream.clone(), Some("proc_macro expand expr"));
|
||||
|
|
@ -652,14 +652,14 @@ impl server::Server for Rustc<'_, '_> {
|
|||
}
|
||||
}
|
||||
|
||||
fn tt_from_token_tree(
|
||||
fn ts_from_token_tree(
|
||||
&mut self,
|
||||
tree: TokenTree<Self::TokenStream, Self::Span, Self::Symbol>,
|
||||
) -> Self::TokenStream {
|
||||
Self::TokenStream::new((tree, &mut *self).to_internal().into_iter().collect::<Vec<_>>())
|
||||
}
|
||||
|
||||
fn tt_concat_trees(
|
||||
fn ts_concat_trees(
|
||||
&mut self,
|
||||
base: Option<Self::TokenStream>,
|
||||
trees: Vec<TokenTree<Self::TokenStream, Self::Span, Self::Symbol>>,
|
||||
|
|
@ -673,7 +673,7 @@ impl server::Server for Rustc<'_, '_> {
|
|||
stream
|
||||
}
|
||||
|
||||
fn tt_concat_streams(
|
||||
fn ts_concat_streams(
|
||||
&mut self,
|
||||
base: Option<Self::TokenStream>,
|
||||
streams: Vec<Self::TokenStream>,
|
||||
|
|
@ -685,7 +685,7 @@ impl server::Server for Rustc<'_, '_> {
|
|||
stream
|
||||
}
|
||||
|
||||
fn tt_into_trees(
|
||||
fn ts_into_trees(
|
||||
&mut self,
|
||||
stream: Self::TokenStream,
|
||||
) -> Vec<TokenTree<Self::TokenStream, Self::Span, Self::Symbol>> {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ impl !Sync for TokenStream {}
|
|||
// Forward `Drop::drop` to the inherent `drop` method.
|
||||
impl Drop for TokenStream {
|
||||
fn drop(&mut self) {
|
||||
Methods::tt_drop(TokenStream { handle: self.handle });
|
||||
Methods::ts_drop(TokenStream { handle: self.handle });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -75,7 +75,7 @@ impl<S> Decode<'_, '_, S> for Span {
|
|||
|
||||
impl Clone for TokenStream {
|
||||
fn clone(&self) -> Self {
|
||||
Methods::tt_clone(self)
|
||||
Methods::ts_clone(self)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,24 +56,24 @@ macro_rules! with_api {
|
|||
fn literal_from_str(s: &str) -> Result<Literal<$S::Span, $S::Symbol>, ()>;
|
||||
fn emit_diagnostic(diagnostic: Diagnostic<$S::Span>);
|
||||
|
||||
fn tt_drop(stream: $S::TokenStream);
|
||||
fn tt_clone(stream: &$S::TokenStream) -> $S::TokenStream;
|
||||
fn tt_is_empty(stream: &$S::TokenStream) -> bool;
|
||||
fn tt_expand_expr(stream: &$S::TokenStream) -> Result<$S::TokenStream, ()>;
|
||||
fn tt_from_str(src: &str) -> $S::TokenStream;
|
||||
fn tt_to_string(stream: &$S::TokenStream) -> String;
|
||||
fn tt_from_token_tree(
|
||||
fn ts_drop(stream: $S::TokenStream);
|
||||
fn ts_clone(stream: &$S::TokenStream) -> $S::TokenStream;
|
||||
fn ts_is_empty(stream: &$S::TokenStream) -> bool;
|
||||
fn ts_expand_expr(stream: &$S::TokenStream) -> Result<$S::TokenStream, ()>;
|
||||
fn ts_from_str(src: &str) -> $S::TokenStream;
|
||||
fn ts_to_string(stream: &$S::TokenStream) -> String;
|
||||
fn ts_from_token_tree(
|
||||
tree: TokenTree<$S::TokenStream, $S::Span, $S::Symbol>,
|
||||
) -> $S::TokenStream;
|
||||
fn tt_concat_trees(
|
||||
fn ts_concat_trees(
|
||||
base: Option<$S::TokenStream>,
|
||||
trees: Vec<TokenTree<$S::TokenStream, $S::Span, $S::Symbol>>,
|
||||
) -> $S::TokenStream;
|
||||
fn tt_concat_streams(
|
||||
fn ts_concat_streams(
|
||||
base: Option<$S::TokenStream>,
|
||||
streams: Vec<$S::TokenStream>,
|
||||
) -> $S::TokenStream;
|
||||
fn tt_into_trees(
|
||||
fn ts_into_trees(
|
||||
stream: $S::TokenStream
|
||||
) -> Vec<TokenTree<$S::TokenStream, $S::Span, $S::Symbol>>;
|
||||
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ use rustc_literal_escaper::{MixedUnit, unescape_byte_str, unescape_c_str, unesca
|
|||
#[unstable(feature = "proc_macro_totokens", issue = "130977")]
|
||||
pub use to_tokens::ToTokens;
|
||||
|
||||
use crate::bridge::client::Methods as BridgeMethods;
|
||||
use crate::escape::{EscapeOptions, escape_bytes};
|
||||
|
||||
/// Errors returned when trying to retrieve a literal unescaped value.
|
||||
|
|
@ -158,7 +159,7 @@ impl TokenStream {
|
|||
/// Checks if this `TokenStream` is empty.
|
||||
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.0.as_ref().map(|h| bridge::client::Methods::tt_is_empty(h)).unwrap_or(true)
|
||||
self.0.as_ref().map(|h| BridgeMethods::ts_is_empty(h)).unwrap_or(true)
|
||||
}
|
||||
|
||||
/// Parses this `TokenStream` as an expression and attempts to expand any
|
||||
|
|
@ -174,7 +175,7 @@ impl TokenStream {
|
|||
#[unstable(feature = "proc_macro_expand", issue = "90765")]
|
||||
pub fn expand_expr(&self) -> Result<TokenStream, ExpandError> {
|
||||
let stream = self.0.as_ref().ok_or(ExpandError)?;
|
||||
match bridge::client::Methods::tt_expand_expr(stream) {
|
||||
match BridgeMethods::ts_expand_expr(stream) {
|
||||
Ok(stream) => Ok(TokenStream(Some(stream))),
|
||||
Err(_) => Err(ExpandError),
|
||||
}
|
||||
|
|
@ -193,7 +194,7 @@ impl FromStr for TokenStream {
|
|||
type Err = LexError;
|
||||
|
||||
fn from_str(src: &str) -> Result<TokenStream, LexError> {
|
||||
Ok(TokenStream(Some(bridge::client::Methods::tt_from_str(src))))
|
||||
Ok(TokenStream(Some(BridgeMethods::ts_from_str(src))))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -212,7 +213,7 @@ impl FromStr for TokenStream {
|
|||
impl fmt::Display for TokenStream {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match &self.0 {
|
||||
Some(ts) => write!(f, "{}", bridge::client::Methods::tt_to_string(ts)),
|
||||
Some(ts) => write!(f, "{}", BridgeMethods::ts_to_string(ts)),
|
||||
None => Ok(()),
|
||||
}
|
||||
}
|
||||
|
|
@ -252,7 +253,7 @@ fn tree_to_bridge_tree(
|
|||
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]
|
||||
impl From<TokenTree> for TokenStream {
|
||||
fn from(tree: TokenTree) -> TokenStream {
|
||||
TokenStream(Some(bridge::client::Methods::tt_from_token_tree(tree_to_bridge_tree(tree))))
|
||||
TokenStream(Some(BridgeMethods::ts_from_token_tree(tree_to_bridge_tree(tree))))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -281,7 +282,7 @@ impl ConcatTreesHelper {
|
|||
if self.trees.is_empty() {
|
||||
TokenStream(None)
|
||||
} else {
|
||||
TokenStream(Some(bridge::client::Methods::tt_concat_trees(None, self.trees)))
|
||||
TokenStream(Some(BridgeMethods::ts_concat_trees(None, self.trees)))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -289,7 +290,7 @@ impl ConcatTreesHelper {
|
|||
if self.trees.is_empty() {
|
||||
return;
|
||||
}
|
||||
stream.0 = Some(bridge::client::Methods::tt_concat_trees(stream.0.take(), self.trees))
|
||||
stream.0 = Some(BridgeMethods::ts_concat_trees(stream.0.take(), self.trees))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -314,7 +315,7 @@ impl ConcatStreamsHelper {
|
|||
if self.streams.len() <= 1 {
|
||||
TokenStream(self.streams.pop())
|
||||
} else {
|
||||
TokenStream(Some(bridge::client::Methods::tt_concat_streams(None, self.streams)))
|
||||
TokenStream(Some(BridgeMethods::ts_concat_streams(None, self.streams)))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -326,7 +327,7 @@ impl ConcatStreamsHelper {
|
|||
if base.is_none() && self.streams.len() == 1 {
|
||||
stream.0 = self.streams.pop();
|
||||
} else {
|
||||
stream.0 = Some(bridge::client::Methods::tt_concat_streams(base, self.streams));
|
||||
stream.0 = Some(BridgeMethods::ts_concat_streams(base, self.streams));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -377,7 +378,7 @@ impl Extend<TokenStream> for TokenStream {
|
|||
macro_rules! extend_items {
|
||||
($($item:ident)*) => {
|
||||
$(
|
||||
#[stable(feature = "token_stream_extend_tt_items", since = "1.92.0")]
|
||||
#[stable(feature = "token_stream_extend_ts_items", since = "1.92.0")]
|
||||
impl Extend<$item> for TokenStream {
|
||||
fn extend<T: IntoIterator<Item = $item>>(&mut self, iter: T) {
|
||||
self.extend(iter.into_iter().map(TokenTree::$item));
|
||||
|
|
@ -392,7 +393,7 @@ extend_items!(Group Literal Punct Ident);
|
|||
/// Public implementation details for the `TokenStream` type, such as iterators.
|
||||
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]
|
||||
pub mod token_stream {
|
||||
use crate::{Group, Ident, Literal, Punct, TokenStream, TokenTree, bridge};
|
||||
use crate::{BridgeMethods, Group, Ident, Literal, Punct, TokenStream, TokenTree, bridge};
|
||||
|
||||
/// An iterator over `TokenStream`'s `TokenTree`s.
|
||||
/// The iteration is "shallow", e.g., the iterator doesn't recurse into delimited groups,
|
||||
|
|
@ -438,10 +439,7 @@ pub mod token_stream {
|
|||
|
||||
fn into_iter(self) -> IntoIter {
|
||||
IntoIter(
|
||||
self.0
|
||||
.map(|v| bridge::client::Methods::tt_into_trees(v))
|
||||
.unwrap_or_default()
|
||||
.into_iter(),
|
||||
self.0.map(|v| BridgeMethods::ts_into_trees(v)).unwrap_or_default().into_iter(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -514,7 +512,7 @@ impl Span {
|
|||
/// `self` was generated from, if any.
|
||||
#[unstable(feature = "proc_macro_span", issue = "54725")]
|
||||
pub fn parent(&self) -> Option<Span> {
|
||||
bridge::client::Methods::span_parent(self.0).map(Span)
|
||||
BridgeMethods::span_parent(self.0).map(Span)
|
||||
}
|
||||
|
||||
/// The span for the origin source code that `self` was generated from. If
|
||||
|
|
@ -522,25 +520,25 @@ impl Span {
|
|||
/// value is the same as `*self`.
|
||||
#[unstable(feature = "proc_macro_span", issue = "54725")]
|
||||
pub fn source(&self) -> Span {
|
||||
Span(bridge::client::Methods::span_source(self.0))
|
||||
Span(BridgeMethods::span_source(self.0))
|
||||
}
|
||||
|
||||
/// Returns the span's byte position range in the source file.
|
||||
#[unstable(feature = "proc_macro_span", issue = "54725")]
|
||||
pub fn byte_range(&self) -> Range<usize> {
|
||||
bridge::client::Methods::span_byte_range(self.0)
|
||||
BridgeMethods::span_byte_range(self.0)
|
||||
}
|
||||
|
||||
/// Creates an empty span pointing to directly before this span.
|
||||
#[stable(feature = "proc_macro_span_location", since = "1.88.0")]
|
||||
pub fn start(&self) -> Span {
|
||||
Span(bridge::client::Methods::span_start(self.0))
|
||||
Span(BridgeMethods::span_start(self.0))
|
||||
}
|
||||
|
||||
/// Creates an empty span pointing to directly after this span.
|
||||
#[stable(feature = "proc_macro_span_location", since = "1.88.0")]
|
||||
pub fn end(&self) -> Span {
|
||||
Span(bridge::client::Methods::span_end(self.0))
|
||||
Span(BridgeMethods::span_end(self.0))
|
||||
}
|
||||
|
||||
/// The one-indexed line of the source file where the span starts.
|
||||
|
|
@ -548,7 +546,7 @@ impl Span {
|
|||
/// To obtain the line of the span's end, use `span.end().line()`.
|
||||
#[stable(feature = "proc_macro_span_location", since = "1.88.0")]
|
||||
pub fn line(&self) -> usize {
|
||||
bridge::client::Methods::span_line(self.0)
|
||||
BridgeMethods::span_line(self.0)
|
||||
}
|
||||
|
||||
/// The one-indexed column of the source file where the span starts.
|
||||
|
|
@ -556,7 +554,7 @@ impl Span {
|
|||
/// To obtain the column of the span's end, use `span.end().column()`.
|
||||
#[stable(feature = "proc_macro_span_location", since = "1.88.0")]
|
||||
pub fn column(&self) -> usize {
|
||||
bridge::client::Methods::span_column(self.0)
|
||||
BridgeMethods::span_column(self.0)
|
||||
}
|
||||
|
||||
/// The path to the source file in which this span occurs, for display purposes.
|
||||
|
|
@ -565,7 +563,7 @@ impl Span {
|
|||
/// It might be remapped (e.g. `"/src/lib.rs"`) or an artificial path (e.g. `"<command line>"`).
|
||||
#[stable(feature = "proc_macro_span_file", since = "1.88.0")]
|
||||
pub fn file(&self) -> String {
|
||||
bridge::client::Methods::span_file(self.0)
|
||||
BridgeMethods::span_file(self.0)
|
||||
}
|
||||
|
||||
/// The path to the source file in which this span occurs on the local file system.
|
||||
|
|
@ -575,7 +573,7 @@ impl Span {
|
|||
/// This path should not be embedded in the output of the macro; prefer `file()` instead.
|
||||
#[stable(feature = "proc_macro_span_file", since = "1.88.0")]
|
||||
pub fn local_file(&self) -> Option<PathBuf> {
|
||||
bridge::client::Methods::span_local_file(self.0).map(PathBuf::from)
|
||||
BridgeMethods::span_local_file(self.0).map(PathBuf::from)
|
||||
}
|
||||
|
||||
/// Creates a new span encompassing `self` and `other`.
|
||||
|
|
@ -583,14 +581,14 @@ impl Span {
|
|||
/// Returns `None` if `self` and `other` are from different files.
|
||||
#[unstable(feature = "proc_macro_span", issue = "54725")]
|
||||
pub fn join(&self, other: Span) -> Option<Span> {
|
||||
bridge::client::Methods::span_join(self.0, other.0).map(Span)
|
||||
BridgeMethods::span_join(self.0, other.0).map(Span)
|
||||
}
|
||||
|
||||
/// Creates a new span with the same line/column information as `self` but
|
||||
/// that resolves symbols as though it were at `other`.
|
||||
#[stable(feature = "proc_macro_span_resolved_at", since = "1.45.0")]
|
||||
pub fn resolved_at(&self, other: Span) -> Span {
|
||||
Span(bridge::client::Methods::span_resolved_at(self.0, other.0))
|
||||
Span(BridgeMethods::span_resolved_at(self.0, other.0))
|
||||
}
|
||||
|
||||
/// Creates a new span with the same name resolution behavior as `self` but
|
||||
|
|
@ -615,21 +613,21 @@ impl Span {
|
|||
/// be used for diagnostics only.
|
||||
#[stable(feature = "proc_macro_source_text", since = "1.66.0")]
|
||||
pub fn source_text(&self) -> Option<String> {
|
||||
bridge::client::Methods::span_source_text(self.0)
|
||||
BridgeMethods::span_source_text(self.0)
|
||||
}
|
||||
|
||||
// Used by the implementation of `Span::quote`
|
||||
#[doc(hidden)]
|
||||
#[unstable(feature = "proc_macro_internals", issue = "27812")]
|
||||
pub fn save_span(&self) -> usize {
|
||||
bridge::client::Methods::span_save_span(self.0)
|
||||
BridgeMethods::span_save_span(self.0)
|
||||
}
|
||||
|
||||
// Used by the implementation of `Span::quote`
|
||||
#[doc(hidden)]
|
||||
#[unstable(feature = "proc_macro_internals", issue = "27812")]
|
||||
pub fn recover_proc_macro_span(id: usize) -> Span {
|
||||
Span(bridge::client::Methods::span_recover_proc_macro_span(id))
|
||||
Span(BridgeMethods::span_recover_proc_macro_span(id))
|
||||
}
|
||||
|
||||
diagnostic_method!(error, Level::Error);
|
||||
|
|
@ -1394,7 +1392,7 @@ impl Literal {
|
|||
// was 'c' or whether it was '\u{63}'.
|
||||
#[unstable(feature = "proc_macro_span", issue = "54725")]
|
||||
pub fn subspan<R: RangeBounds<usize>>(&self, range: R) -> Option<Span> {
|
||||
bridge::client::Methods::span_subspan(
|
||||
BridgeMethods::span_subspan(
|
||||
self.0.span,
|
||||
range.start_bound().cloned(),
|
||||
range.end_bound().cloned(),
|
||||
|
|
@ -1569,7 +1567,7 @@ impl FromStr for Literal {
|
|||
type Err = LexError;
|
||||
|
||||
fn from_str(src: &str) -> Result<Self, LexError> {
|
||||
match bridge::client::Methods::literal_from_str(src) {
|
||||
match BridgeMethods::literal_from_str(src) {
|
||||
Ok(literal) => Ok(Literal(literal)),
|
||||
Err(()) => Err(LexError),
|
||||
}
|
||||
|
|
@ -1611,11 +1609,12 @@ impl fmt::Debug for Literal {
|
|||
)]
|
||||
/// Functionality for adding environment state to the build dependency info.
|
||||
pub mod tracked {
|
||||
|
||||
use std::env::{self, VarError};
|
||||
use std::ffi::OsStr;
|
||||
use std::path::Path;
|
||||
|
||||
use crate::BridgeMethods;
|
||||
|
||||
/// Retrieve an environment variable and add it to build dependency info.
|
||||
/// The build system executing the compiler will know that the variable was accessed during
|
||||
/// compilation, and will be able to rerun the build when the value of that variable changes.
|
||||
|
|
@ -1624,9 +1623,8 @@ pub mod tracked {
|
|||
#[unstable(feature = "proc_macro_tracked_env", issue = "99515")]
|
||||
pub fn env_var<K: AsRef<OsStr> + AsRef<str>>(key: K) -> Result<String, VarError> {
|
||||
let key: &str = key.as_ref();
|
||||
let value =
|
||||
crate::bridge::client::Methods::injected_env_var(key).map_or_else(|| env::var(key), Ok);
|
||||
crate::bridge::client::Methods::track_env_var(key, value.as_deref().ok());
|
||||
let value = BridgeMethods::injected_env_var(key).map_or_else(|| env::var(key), Ok);
|
||||
BridgeMethods::track_env_var(key, value.as_deref().ok());
|
||||
value
|
||||
}
|
||||
|
||||
|
|
@ -1636,6 +1634,6 @@ pub mod tracked {
|
|||
#[unstable(feature = "proc_macro_tracked_path", issue = "99515")]
|
||||
pub fn path<P: AsRef<Path>>(path: P) {
|
||||
let path: &str = path.as_ref().to_str().unwrap();
|
||||
crate::bridge::client::Methods::track_path(path);
|
||||
BridgeMethods::track_path(path);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,18 +72,18 @@ impl server::Server for RaSpanServer<'_> {
|
|||
// FIXME handle diagnostic
|
||||
}
|
||||
|
||||
fn tt_drop(&mut self, stream: Self::TokenStream) {
|
||||
fn ts_drop(&mut self, stream: Self::TokenStream) {
|
||||
drop(stream);
|
||||
}
|
||||
|
||||
fn tt_clone(&mut self, stream: &Self::TokenStream) -> Self::TokenStream {
|
||||
fn ts_clone(&mut self, stream: &Self::TokenStream) -> Self::TokenStream {
|
||||
stream.clone()
|
||||
}
|
||||
|
||||
fn tt_is_empty(&mut self, stream: &Self::TokenStream) -> bool {
|
||||
fn ts_is_empty(&mut self, stream: &Self::TokenStream) -> bool {
|
||||
stream.is_empty()
|
||||
}
|
||||
fn tt_from_str(&mut self, src: &str) -> Self::TokenStream {
|
||||
fn ts_from_str(&mut self, src: &str) -> Self::TokenStream {
|
||||
Self::TokenStream::from_str(src, self.call_site).unwrap_or_else(|e| {
|
||||
Self::TokenStream::from_str(
|
||||
&format!("compile_error!(\"failed to parse str to token stream: {e}\")"),
|
||||
|
|
@ -92,15 +92,15 @@ impl server::Server for RaSpanServer<'_> {
|
|||
.unwrap()
|
||||
})
|
||||
}
|
||||
fn tt_to_string(&mut self, stream: &Self::TokenStream) -> String {
|
||||
fn ts_to_string(&mut self, stream: &Self::TokenStream) -> String {
|
||||
stream.to_string()
|
||||
}
|
||||
|
||||
fn tt_from_token_tree(&mut self, tree: TokenTree<Self::Span>) -> Self::TokenStream {
|
||||
fn ts_from_token_tree(&mut self, tree: TokenTree<Self::Span>) -> Self::TokenStream {
|
||||
Self::TokenStream::new(vec![tree])
|
||||
}
|
||||
|
||||
fn tt_expand_expr(&mut self, self_: &Self::TokenStream) -> Result<Self::TokenStream, ()> {
|
||||
fn ts_expand_expr(&mut self, self_: &Self::TokenStream) -> Result<Self::TokenStream, ()> {
|
||||
// FIXME: requires db, more importantly this requires name resolution so we would need to
|
||||
// eagerly expand this proc-macro, but we can't know that this proc-macro is eager until we
|
||||
// expand it ...
|
||||
|
|
@ -109,7 +109,7 @@ impl server::Server for RaSpanServer<'_> {
|
|||
Ok(self_.clone())
|
||||
}
|
||||
|
||||
fn tt_concat_trees(
|
||||
fn ts_concat_trees(
|
||||
&mut self,
|
||||
base: Option<Self::TokenStream>,
|
||||
trees: Vec<TokenTree<Self::Span>>,
|
||||
|
|
@ -125,7 +125,7 @@ impl server::Server for RaSpanServer<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
fn tt_concat_streams(
|
||||
fn ts_concat_streams(
|
||||
&mut self,
|
||||
base: Option<Self::TokenStream>,
|
||||
streams: Vec<Self::TokenStream>,
|
||||
|
|
@ -137,7 +137,7 @@ impl server::Server for RaSpanServer<'_> {
|
|||
stream
|
||||
}
|
||||
|
||||
fn tt_into_trees(&mut self, stream: Self::TokenStream) -> Vec<TokenTree<Self::Span>> {
|
||||
fn ts_into_trees(&mut self, stream: Self::TokenStream) -> Vec<TokenTree<Self::Span>> {
|
||||
(*stream.0).clone()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -75,18 +75,18 @@ impl server::Server for SpanIdServer<'_> {
|
|||
|
||||
fn emit_diagnostic(&mut self, _: Diagnostic<Self::Span>) {}
|
||||
|
||||
fn tt_drop(&mut self, stream: Self::TokenStream) {
|
||||
fn ts_drop(&mut self, stream: Self::TokenStream) {
|
||||
drop(stream);
|
||||
}
|
||||
|
||||
fn tt_clone(&mut self, stream: &Self::TokenStream) -> Self::TokenStream {
|
||||
fn ts_clone(&mut self, stream: &Self::TokenStream) -> Self::TokenStream {
|
||||
stream.clone()
|
||||
}
|
||||
|
||||
fn tt_is_empty(&mut self, stream: &Self::TokenStream) -> bool {
|
||||
fn ts_is_empty(&mut self, stream: &Self::TokenStream) -> bool {
|
||||
stream.is_empty()
|
||||
}
|
||||
fn tt_from_str(&mut self, src: &str) -> Self::TokenStream {
|
||||
fn ts_from_str(&mut self, src: &str) -> Self::TokenStream {
|
||||
Self::TokenStream::from_str(src, self.call_site).unwrap_or_else(|e| {
|
||||
Self::TokenStream::from_str(
|
||||
&format!("compile_error!(\"failed to parse str to token stream: {e}\")"),
|
||||
|
|
@ -95,18 +95,18 @@ impl server::Server for SpanIdServer<'_> {
|
|||
.unwrap()
|
||||
})
|
||||
}
|
||||
fn tt_to_string(&mut self, stream: &Self::TokenStream) -> String {
|
||||
fn ts_to_string(&mut self, stream: &Self::TokenStream) -> String {
|
||||
stream.to_string()
|
||||
}
|
||||
fn tt_from_token_tree(&mut self, tree: TokenTree<Self::Span>) -> Self::TokenStream {
|
||||
fn ts_from_token_tree(&mut self, tree: TokenTree<Self::Span>) -> Self::TokenStream {
|
||||
Self::TokenStream::new(vec![tree])
|
||||
}
|
||||
|
||||
fn tt_expand_expr(&mut self, self_: &Self::TokenStream) -> Result<Self::TokenStream, ()> {
|
||||
fn ts_expand_expr(&mut self, self_: &Self::TokenStream) -> Result<Self::TokenStream, ()> {
|
||||
Ok(self_.clone())
|
||||
}
|
||||
|
||||
fn tt_concat_trees(
|
||||
fn ts_concat_trees(
|
||||
&mut self,
|
||||
base: Option<Self::TokenStream>,
|
||||
trees: Vec<TokenTree<Self::Span>>,
|
||||
|
|
@ -122,7 +122,7 @@ impl server::Server for SpanIdServer<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
fn tt_concat_streams(
|
||||
fn ts_concat_streams(
|
||||
&mut self,
|
||||
base: Option<Self::TokenStream>,
|
||||
streams: Vec<Self::TokenStream>,
|
||||
|
|
@ -134,7 +134,7 @@ impl server::Server for SpanIdServer<'_> {
|
|||
stream
|
||||
}
|
||||
|
||||
fn tt_into_trees(&mut self, stream: Self::TokenStream) -> Vec<TokenTree<Self::Span>> {
|
||||
fn ts_into_trees(&mut self, stream: Self::TokenStream) -> Vec<TokenTree<Self::Span>> {
|
||||
(*stream.0).clone()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue