@@ -2,11 +2,6 @@ use crate::def::{DefKind, Namespace, Res};
2
2
use crate :: def_id:: DefId ;
3
3
crate use crate :: hir_id:: HirId ;
4
4
use crate :: itemlikevisit;
5
- use crate :: print;
6
-
7
- crate use BlockCheckMode :: * ;
8
- crate use FnRetTy :: * ;
9
- crate use UnsafeSource :: * ;
10
5
11
6
use rustc_ast:: ast:: { self , AsmDialect , CrateSugar , Ident , Name } ;
12
7
use rustc_ast:: ast:: { AttrVec , Attribute , FloatTy , IntTy , Label , LitKind , StrStyle , UintTy } ;
@@ -169,12 +164,7 @@ impl fmt::Display for Lifetime {
169
164
170
165
impl fmt:: Debug for Lifetime {
171
166
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( ) )
178
168
}
179
169
}
180
170
@@ -191,7 +181,7 @@ impl Lifetime {
191
181
/// A `Path` is essentially Rust's notion of a name; for instance,
192
182
/// `std::cmp::PartialEq`. It's represented as a sequence of identifiers,
193
183
/// along with a bunch of supporting information.
194
- #[ derive( RustcEncodable , RustcDecodable , HashStable_Generic ) ]
184
+ #[ derive( RustcEncodable , RustcDecodable , Debug , HashStable_Generic ) ]
195
185
pub struct Path < ' hir > {
196
186
pub span : Span ,
197
187
/// The resolution for the path.
@@ -206,18 +196,6 @@ impl Path<'_> {
206
196
}
207
197
}
208
198
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
-
221
199
/// A segment of a path: an identifier, an optional lifetime, and a set of
222
200
/// types.
223
201
#[ derive( RustcEncodable , RustcDecodable , Debug , HashStable_Generic ) ]
@@ -758,25 +736,14 @@ pub struct Block<'hir> {
758
736
pub targeted_by_break : bool ,
759
737
}
760
738
761
- #[ derive( RustcEncodable , RustcDecodable , HashStable_Generic ) ]
739
+ #[ derive( Debug , RustcEncodable , RustcDecodable , HashStable_Generic ) ]
762
740
pub struct Pat < ' hir > {
763
741
#[ stable_hasher( ignore) ]
764
742
pub hir_id : HirId ,
765
743
pub kind : PatKind < ' hir > ,
766
744
pub span : Span ,
767
745
}
768
746
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
-
780
747
impl Pat < ' _ > {
781
748
// FIXME(#19596) this is a workaround, but there should be a better way
782
749
fn walk_short_ ( & self , it : & mut impl FnMut ( & Pat < ' _ > ) -> bool ) -> bool {
@@ -1118,26 +1085,15 @@ impl UnOp {
1118
1085
}
1119
1086
1120
1087
/// A statement.
1121
- #[ derive( RustcEncodable , RustcDecodable , HashStable_Generic ) ]
1088
+ #[ derive( RustcEncodable , RustcDecodable , Debug , HashStable_Generic ) ]
1122
1089
pub struct Stmt < ' hir > {
1123
1090
pub hir_id : HirId ,
1124
1091
pub kind : StmtKind < ' hir > ,
1125
1092
pub span : Span ,
1126
1093
}
1127
1094
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
-
1139
1095
/// The contents of a statement.
1140
- #[ derive( RustcEncodable , RustcDecodable , HashStable_Generic ) ]
1096
+ #[ derive( RustcEncodable , RustcDecodable , Debug , HashStable_Generic ) ]
1141
1097
pub enum StmtKind < ' hir > {
1142
1098
/// A local (`let`) binding.
1143
1099
Local ( & ' hir Local < ' hir > ) ,
@@ -1351,7 +1307,7 @@ pub struct AnonConst {
1351
1307
}
1352
1308
1353
1309
/// An expression.
1354
- #[ derive( RustcEncodable , RustcDecodable ) ]
1310
+ #[ derive( Debug , RustcEncodable , RustcDecodable ) ]
1355
1311
pub struct Expr < ' hir > {
1356
1312
pub hir_id : HirId ,
1357
1313
pub kind : ExprKind < ' hir > ,
@@ -1472,17 +1428,6 @@ impl Expr<'_> {
1472
1428
}
1473
1429
}
1474
1430
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
-
1486
1431
/// Checks if the specified expression is a built-in range literal.
1487
1432
/// (See: `LoweringContext::lower_expr()`).
1488
1433
///
@@ -1965,19 +1910,13 @@ impl TypeBinding<'_> {
1965
1910
}
1966
1911
}
1967
1912
1968
- #[ derive( RustcEncodable , RustcDecodable ) ]
1913
+ #[ derive( Debug , RustcEncodable , RustcDecodable ) ]
1969
1914
pub struct Ty < ' hir > {
1970
1915
pub hir_id : HirId ,
1971
1916
pub kind : TyKind < ' hir > ,
1972
1917
pub span : Span ,
1973
1918
}
1974
1919
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
-
1981
1920
/// Not represented directly in the AST; referred to by name through a `ty_path`.
1982
1921
#[ derive( Copy , Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
1983
1922
#[ derive( HashStable_Generic ) ]
@@ -2182,15 +2121,6 @@ pub enum FnRetTy<'hir> {
2182
2121
Return ( & ' hir Ty < ' hir > ) ,
2183
2122
}
2184
2123
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
-
2194
2124
impl FnRetTy < ' _ > {
2195
2125
pub fn span ( & self ) -> Span {
2196
2126
match * self {
0 commit comments