ast: remove implicit pprust dependency via Display.

Instead just use `pprust::path_to_string(..)` where needed.

This has two benefits:

a) The AST definition is now independent of printing it.
   (Therefore we get closer to extracting a data-crate.)

b) Debugging should be easier as program flow is clearer.
This commit is contained in:
Mazdak Farrokhzad 2019-10-08 22:17:46 +02:00
parent d131abefc3
commit 742ec4b9bf
15 changed files with 88 additions and 47 deletions

View file

@ -7,7 +7,6 @@ pub use crate::util::parser::ExprPrecedence;
use crate::ext::hygiene::ExpnId;
use crate::parse::token::{self, DelimToken};
use crate::print::pprust;
use crate::ptr::P;
use crate::source_map::{dummy_spanned, respan, Spanned};
use crate::symbol::{kw, sym, Symbol};
@ -86,12 +85,6 @@ impl PartialEq<Symbol> for Path {
}
}
impl fmt::Display for Path {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", pprust::path_to_string(self))
}
}
impl Path {
// Convert a span and an identifier to the corresponding
// one-segment path.