Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
ast: don't use pprust in Debug
  • Loading branch information
Centril committed Oct 13, 2019
commit d131abefc3aa53fc6376593729e6931326270503
47 changes: 6 additions & 41 deletions src/libsyntax/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl fmt::Display for Lifetime {
/// along with a bunch of supporting information.
///
/// E.g., `std::cmp::PartialEq`.
#[derive(Clone, RustcEncodable, RustcDecodable)]
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct Path {
pub span: Span,
/// The segments in the path: the things separated by `::`.
Expand All @@ -86,12 +86,6 @@ impl PartialEq<Symbol> for Path {
}
}

impl fmt::Debug for Path {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "path({})", pprust::path_to_string(self))
}
}

impl fmt::Display for Path {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", pprust::path_to_string(self))
Expand Down Expand Up @@ -507,19 +501,13 @@ pub struct Block {
pub span: Span,
}

#[derive(Clone, RustcEncodable, RustcDecodable)]
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct Pat {
pub id: NodeId,
pub kind: PatKind,
pub span: Span,
}

impl fmt::Debug for Pat {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "pat({}: {})", self.id, pprust::pat_to_string(self))
}
}

impl Pat {
/// Attempt reparsing the pattern as a type.
/// This is intended for use by diagnostics.
Expand Down Expand Up @@ -831,7 +819,7 @@ impl UnOp {
}

/// A statement
#[derive(Clone, RustcEncodable, RustcDecodable)]
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct Stmt {
pub id: NodeId,
pub kind: StmtKind,
Expand Down Expand Up @@ -865,18 +853,7 @@ impl Stmt {
}
}

impl fmt::Debug for Stmt {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"stmt({}: {})",
self.id.to_string(),
pprust::stmt_to_string(self)
)
}
}

#[derive(Clone, RustcEncodable, RustcDecodable)]
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum StmtKind {
/// A local (let) binding.
Local(P<Local>),
Expand Down Expand Up @@ -973,7 +950,7 @@ pub struct AnonConst {
}

/// An expression.
#[derive(Clone, RustcEncodable, RustcDecodable)]
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct Expr {
pub id: NodeId,
pub kind: ExprKind,
Expand Down Expand Up @@ -1100,12 +1077,6 @@ impl Expr {
}
}

impl fmt::Debug for Expr {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "expr({}: {})", self.id, pprust::expr_to_string(self))
}
}

/// Limit types of a range (inclusive or exclusive)
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)]
pub enum RangeLimits {
Expand Down Expand Up @@ -1660,19 +1631,13 @@ pub enum AssocTyConstraintKind {
},
}

#[derive(Clone, RustcEncodable, RustcDecodable)]
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct Ty {
pub id: NodeId,
pub kind: TyKind,
pub span: Span,
}

impl fmt::Debug for Ty {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "type({})", pprust::ty_to_string(self))
}
}

#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct BareFnTy {
pub unsafety: Unsafety,
Expand Down