@@ -2,11 +2,6 @@ use crate::def::{DefKind, Namespace, Res};
22use crate :: def_id:: DefId ;
33crate use crate :: hir_id:: HirId ;
44use crate :: itemlikevisit;
5- use crate :: print;
6-
7- crate use BlockCheckMode :: * ;
8- crate use FnRetTy :: * ;
9- crate use UnsafeSource :: * ;
105
116use rustc_ast:: ast:: { self , AsmDialect , CrateSugar , Ident , Name } ;
127use rustc_ast:: ast:: { AttrVec , Attribute , FloatTy , IntTy , Label , LitKind , StrStyle , UintTy } ;
@@ -169,12 +164,7 @@ impl fmt::Display for Lifetime {
169164
170165impl fmt:: Debug for Lifetime {
171166 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
172- write ! (
173- f,
174- "lifetime({}: {})" ,
175- self . hir_id,
176- print:: to_string( print:: NO_ANN , |s| s. print_lifetime( self ) )
177- )
167+ write ! ( f, "lifetime({}: {})" , self . hir_id, self . name. ident( ) )
178168 }
179169}
180170
@@ -191,7 +181,7 @@ impl Lifetime {
191181/// A `Path` is essentially Rust's notion of a name; for instance,
192182/// `std::cmp::PartialEq`. It's represented as a sequence of identifiers,
193183/// along with a bunch of supporting information.
194- #[ derive( RustcEncodable , RustcDecodable , HashStable_Generic ) ]
184+ #[ derive( RustcEncodable , RustcDecodable , Debug , HashStable_Generic ) ]
195185pub struct Path < ' hir > {
196186 pub span : Span ,
197187 /// The resolution for the path.
@@ -206,18 +196,6 @@ impl Path<'_> {
206196 }
207197}
208198
209- impl fmt:: Debug for Path < ' _ > {
210- fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
211- write ! ( f, "path({})" , self )
212- }
213- }
214-
215- impl fmt:: Display for Path < ' _ > {
216- fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
217- write ! ( f, "{}" , print:: to_string( print:: NO_ANN , |s| s. print_path( self , false ) ) )
218- }
219- }
220-
221199/// A segment of a path: an identifier, an optional lifetime, and a set of
222200/// types.
223201#[ derive( RustcEncodable , RustcDecodable , Debug , HashStable_Generic ) ]
@@ -758,25 +736,14 @@ pub struct Block<'hir> {
758736 pub targeted_by_break : bool ,
759737}
760738
761- #[ derive( RustcEncodable , RustcDecodable , HashStable_Generic ) ]
739+ #[ derive( Debug , RustcEncodable , RustcDecodable , HashStable_Generic ) ]
762740pub struct Pat < ' hir > {
763741 #[ stable_hasher( ignore) ]
764742 pub hir_id : HirId ,
765743 pub kind : PatKind < ' hir > ,
766744 pub span : Span ,
767745}
768746
769- impl fmt:: Debug for Pat < ' _ > {
770- fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
771- write ! (
772- f,
773- "pat({}: {})" ,
774- self . hir_id,
775- print:: to_string( print:: NO_ANN , |s| s. print_pat( self ) )
776- )
777- }
778- }
779-
780747impl Pat < ' _ > {
781748 // FIXME(#19596) this is a workaround, but there should be a better way
782749 fn walk_short_ ( & self , it : & mut impl FnMut ( & Pat < ' _ > ) -> bool ) -> bool {
@@ -1118,26 +1085,15 @@ impl UnOp {
11181085}
11191086
11201087/// A statement.
1121- #[ derive( RustcEncodable , RustcDecodable , HashStable_Generic ) ]
1088+ #[ derive( RustcEncodable , RustcDecodable , Debug , HashStable_Generic ) ]
11221089pub struct Stmt < ' hir > {
11231090 pub hir_id : HirId ,
11241091 pub kind : StmtKind < ' hir > ,
11251092 pub span : Span ,
11261093}
11271094
1128- impl fmt:: Debug for Stmt < ' _ > {
1129- fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
1130- write ! (
1131- f,
1132- "stmt({}: {})" ,
1133- self . hir_id,
1134- print:: to_string( print:: NO_ANN , |s| s. print_stmt( self ) )
1135- )
1136- }
1137- }
1138-
11391095/// The contents of a statement.
1140- #[ derive( RustcEncodable , RustcDecodable , HashStable_Generic ) ]
1096+ #[ derive( RustcEncodable , RustcDecodable , Debug , HashStable_Generic ) ]
11411097pub enum StmtKind < ' hir > {
11421098 /// A local (`let`) binding.
11431099 Local ( & ' hir Local < ' hir > ) ,
@@ -1351,7 +1307,7 @@ pub struct AnonConst {
13511307}
13521308
13531309/// An expression.
1354- #[ derive( RustcEncodable , RustcDecodable ) ]
1310+ #[ derive( Debug , RustcEncodable , RustcDecodable ) ]
13551311pub struct Expr < ' hir > {
13561312 pub hir_id : HirId ,
13571313 pub kind : ExprKind < ' hir > ,
@@ -1472,17 +1428,6 @@ impl Expr<'_> {
14721428 }
14731429}
14741430
1475- impl fmt:: Debug for Expr < ' _ > {
1476- fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
1477- write ! (
1478- f,
1479- "expr({}: {})" ,
1480- self . hir_id,
1481- print:: to_string( print:: NO_ANN , |s| s. print_expr( self ) )
1482- )
1483- }
1484- }
1485-
14861431/// Checks if the specified expression is a built-in range literal.
14871432/// (See: `LoweringContext::lower_expr()`).
14881433///
@@ -1965,19 +1910,13 @@ impl TypeBinding<'_> {
19651910 }
19661911}
19671912
1968- #[ derive( RustcEncodable , RustcDecodable ) ]
1913+ #[ derive( Debug , RustcEncodable , RustcDecodable ) ]
19691914pub struct Ty < ' hir > {
19701915 pub hir_id : HirId ,
19711916 pub kind : TyKind < ' hir > ,
19721917 pub span : Span ,
19731918}
19741919
1975- impl fmt:: Debug for Ty < ' _ > {
1976- fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
1977- write ! ( f, "type({})" , print:: to_string( print:: NO_ANN , |s| s. print_type( self ) ) )
1978- }
1979- }
1980-
19811920/// Not represented directly in the AST; referred to by name through a `ty_path`.
19821921#[ derive( Copy , Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
19831922#[ derive( HashStable_Generic ) ]
@@ -2182,15 +2121,6 @@ pub enum FnRetTy<'hir> {
21822121 Return ( & ' hir Ty < ' hir > ) ,
21832122}
21842123
2185- impl fmt:: Display for FnRetTy < ' _ > {
2186- fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
2187- match self {
2188- Self :: Return ( ref ty) => print:: to_string ( print:: NO_ANN , |s| s. print_type ( ty) ) . fmt ( f) ,
2189- Self :: DefaultReturn ( _) => "()" . fmt ( f) ,
2190- }
2191- }
2192- }
2193-
21942124impl FnRetTy < ' _ > {
21952125 pub fn span ( & self ) -> Span {
21962126 match * self {
0 commit comments