Skip to content

Commit

Permalink
tokenstream: don't depend on pprust
Browse files Browse the repository at this point in the history
  • Loading branch information
Centril committed Oct 13, 2019
1 parent 742ec4b commit ab8105e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
6 changes: 4 additions & 2 deletions src/libsyntax/ext/mbe/macro_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion src/libsyntax/ext/proc_macro_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
9 changes: 1 addition & 8 deletions src/libsyntax/tokenstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand All @@ -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;
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit ab8105e

Please sign in to comment.