Skip to content

Commit d131abe

Browse files
committed
ast: don't use pprust in Debug
1 parent 1721c96 commit d131abe

File tree

1 file changed

+6
-41
lines changed

1 file changed

+6
-41
lines changed

src/libsyntax/ast.rs

Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl fmt::Display for Lifetime {
7070
/// along with a bunch of supporting information.
7171
///
7272
/// E.g., `std::cmp::PartialEq`.
73-
#[derive(Clone, RustcEncodable, RustcDecodable)]
73+
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
7474
pub struct Path {
7575
pub span: Span,
7676
/// The segments in the path: the things separated by `::`.
@@ -86,12 +86,6 @@ impl PartialEq<Symbol> for Path {
8686
}
8787
}
8888

89-
impl fmt::Debug for Path {
90-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
91-
write!(f, "path({})", pprust::path_to_string(self))
92-
}
93-
}
94-
9589
impl fmt::Display for Path {
9690
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
9791
write!(f, "{}", pprust::path_to_string(self))
@@ -507,19 +501,13 @@ pub struct Block {
507501
pub span: Span,
508502
}
509503

510-
#[derive(Clone, RustcEncodable, RustcDecodable)]
504+
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
511505
pub struct Pat {
512506
pub id: NodeId,
513507
pub kind: PatKind,
514508
pub span: Span,
515509
}
516510

517-
impl fmt::Debug for Pat {
518-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
519-
write!(f, "pat({}: {})", self.id, pprust::pat_to_string(self))
520-
}
521-
}
522-
523511
impl Pat {
524512
/// Attempt reparsing the pattern as a type.
525513
/// This is intended for use by diagnostics.
@@ -831,7 +819,7 @@ impl UnOp {
831819
}
832820

833821
/// A statement
834-
#[derive(Clone, RustcEncodable, RustcDecodable)]
822+
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
835823
pub struct Stmt {
836824
pub id: NodeId,
837825
pub kind: StmtKind,
@@ -865,18 +853,7 @@ impl Stmt {
865853
}
866854
}
867855

868-
impl fmt::Debug for Stmt {
869-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
870-
write!(
871-
f,
872-
"stmt({}: {})",
873-
self.id.to_string(),
874-
pprust::stmt_to_string(self)
875-
)
876-
}
877-
}
878-
879-
#[derive(Clone, RustcEncodable, RustcDecodable)]
856+
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
880857
pub enum StmtKind {
881858
/// A local (let) binding.
882859
Local(P<Local>),
@@ -973,7 +950,7 @@ pub struct AnonConst {
973950
}
974951

975952
/// An expression.
976-
#[derive(Clone, RustcEncodable, RustcDecodable)]
953+
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
977954
pub struct Expr {
978955
pub id: NodeId,
979956
pub kind: ExprKind,
@@ -1100,12 +1077,6 @@ impl Expr {
11001077
}
11011078
}
11021079

1103-
impl fmt::Debug for Expr {
1104-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1105-
write!(f, "expr({}: {})", self.id, pprust::expr_to_string(self))
1106-
}
1107-
}
1108-
11091080
/// Limit types of a range (inclusive or exclusive)
11101081
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)]
11111082
pub enum RangeLimits {
@@ -1660,19 +1631,13 @@ pub enum AssocTyConstraintKind {
16601631
},
16611632
}
16621633

1663-
#[derive(Clone, RustcEncodable, RustcDecodable)]
1634+
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
16641635
pub struct Ty {
16651636
pub id: NodeId,
16661637
pub kind: TyKind,
16671638
pub span: Span,
16681639
}
16691640

1670-
impl fmt::Debug for Ty {
1671-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1672-
write!(f, "type({})", pprust::ty_to_string(self))
1673-
}
1674-
}
1675-
16761641
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
16771642
pub struct BareFnTy {
16781643
pub unsafety: Unsafety,

0 commit comments

Comments
 (0)