tokenstream: don't depend on pprust
This commit is contained in:
parent
742ec4b9bf
commit
ab8105ee97
3 changed files with 7 additions and 11 deletions
|
@ -174,7 +174,8 @@ fn generic_extension<'cx>(
|
|||
rhses: &[mbe::TokenTree],
|
||||
) -> Box<dyn MacResult + 'cx> {
|
||||
if cx.trace_macros() {
|
||||
trace_macros_note(cx, sp, format!("expanding `{}! {{ {} }}`", name, arg));
|
||||
let msg = format!("expanding `{}! {{ {} }}`", name, pprust::tts_to_string(arg.clone()));
|
||||
trace_macros_note(cx, sp, msg);
|
||||
}
|
||||
|
||||
// Which arm's failure should we report? (the one furthest along)
|
||||
|
@ -212,7 +213,8 @@ fn generic_extension<'cx>(
|
|||
}
|
||||
|
||||
if cx.trace_macros() {
|
||||
trace_macros_note(cx, sp, format!("to `{}`", tts));
|
||||
let msg = format!("to `{}`", pprust::tts_to_string(tts.clone()));
|
||||
trace_macros_note(cx, sp, msg);
|
||||
}
|
||||
|
||||
let directory = Directory {
|
||||
|
|
|
@ -2,6 +2,7 @@ use crate::ast;
|
|||
use crate::ext::base::ExtCtxt;
|
||||
use crate::parse::{self, token, ParseSess};
|
||||
use crate::parse::lexer::comments;
|
||||
use crate::print::pprust;
|
||||
use crate::tokenstream::{self, DelimSpan, IsJoint::*, TokenStream, TreeAndJoint};
|
||||
|
||||
use errors::Diagnostic;
|
||||
|
@ -407,7 +408,7 @@ impl server::TokenStream for Rustc<'_> {
|
|||
)
|
||||
}
|
||||
fn to_string(&mut self, stream: &Self::TokenStream) -> String {
|
||||
stream.to_string()
|
||||
pprust::tts_to_string(stream.clone())
|
||||
}
|
||||
fn from_token_tree(
|
||||
&mut self,
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
//! ownership of the original.
|
||||
|
||||
use crate::parse::token::{self, DelimToken, Token, TokenKind};
|
||||
use crate::print::pprust;
|
||||
|
||||
use syntax_pos::{BytePos, Span, DUMMY_SP};
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
|
@ -23,7 +22,7 @@ use rustc_data_structures::sync::Lrc;
|
|||
use rustc_serialize::{Decoder, Decodable, Encoder, Encodable};
|
||||
use smallvec::{SmallVec, smallvec};
|
||||
|
||||
use std::{fmt, iter, mem};
|
||||
use std::{iter, mem};
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
@ -507,12 +506,6 @@ impl Cursor {
|
|||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for TokenStream {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.write_str(&pprust::tts_to_string(self.clone()))
|
||||
}
|
||||
}
|
||||
|
||||
impl Encodable for TokenStream {
|
||||
fn encode<E: Encoder>(&self, encoder: &mut E) -> Result<(), E::Error> {
|
||||
self.trees().collect::<Vec<_>>().encode(encoder)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue