1
1
//! A pretty-printer for HIR.
2
+ #![ allow( dead_code) ]
2
3
3
4
use std:: {
4
5
fmt:: { self , Write } ,
@@ -10,15 +11,14 @@ use itertools::Itertools;
10
11
use span:: Edition ;
11
12
12
13
use crate :: {
13
- DefWithBodyId , ItemTreeLoc , TypeOrConstParamId , TypeParamId ,
14
+ DefWithBodyId , ItemTreeLoc , TypeParamId ,
14
15
expr_store:: path:: { GenericArg , GenericArgs } ,
15
16
hir:: {
16
17
Array , BindingAnnotation , CaptureBy , ClosureKind , Literal , Movability , Statement ,
17
18
generics:: { GenericParams , WherePredicate , WherePredicateTypeTarget } ,
18
19
} ,
19
- item_tree:: FieldsShape ,
20
20
lang_item:: LangItemTarget ,
21
- signatures:: { FunctionSignature , StructSignature } ,
21
+ signatures:: { FnFlags , FunctionSignature , StructSignature } ,
22
22
type_ref:: { ConstRef , Mutability , TraitBoundModifier , TypeBound , UseArgRef } ,
23
23
} ;
24
24
@@ -113,7 +113,6 @@ pub(crate) fn print_body_hir(
113
113
p. buf
114
114
}
115
115
116
- #[ cfg( test) ]
117
116
pub ( crate ) fn print_path (
118
117
db : & dyn DefDatabase ,
119
118
store : & ExpressionStore ,
@@ -132,12 +131,12 @@ pub(crate) fn print_path(
132
131
p. buf
133
132
}
134
133
135
- #[ cfg( test) ]
136
134
pub ( crate ) fn print_struct (
137
135
db : & dyn DefDatabase ,
138
136
StructSignature { name, generic_params, store, flags, shape, repr } : & StructSignature ,
139
137
edition : Edition ,
140
138
) -> String {
139
+ use crate :: item_tree:: FieldsShape ;
141
140
use crate :: signatures:: StructFlags ;
142
141
143
142
let mut p = Printer {
@@ -182,7 +181,6 @@ pub(crate) fn print_struct(
182
181
p. buf
183
182
}
184
183
185
- #[ cfg( test) ]
186
184
pub ( crate ) fn print_function (
187
185
db : & dyn DefDatabase ,
188
186
FunctionSignature {
@@ -197,8 +195,6 @@ pub(crate) fn print_function(
197
195
} : & FunctionSignature ,
198
196
edition : Edition ,
199
197
) -> String {
200
- use crate :: signatures:: FnFlags ;
201
-
202
198
let mut p = Printer {
203
199
db,
204
200
store,
@@ -247,7 +243,6 @@ pub(crate) fn print_function(
247
243
p. buf
248
244
}
249
245
250
- #[ cfg( test) ]
251
246
fn print_where_clauses ( db : & dyn DefDatabase , generic_params : & GenericParams , p : & mut Printer < ' _ > ) {
252
247
if !generic_params. where_predicates . is_empty ( ) {
253
248
w ! ( p, "\n where\n " ) ;
@@ -258,8 +253,8 @@ fn print_where_clauses(db: &dyn DefDatabase, generic_params: &GenericParams, p:
258
253
}
259
254
match pred {
260
255
WherePredicate :: TypeBound { target, bound } => match target {
261
- WherePredicateTypeTarget :: TypeRef ( idx) => {
262
- p. print_type_ref ( * idx) ;
256
+ & WherePredicateTypeTarget :: TypeRef ( idx) => {
257
+ p. print_type_ref ( idx) ;
263
258
w ! ( p, ": " ) ;
264
259
p. print_type_bounds ( std:: slice:: from_ref ( bound) ) ;
265
260
}
@@ -312,7 +307,6 @@ fn print_where_clauses(db: &dyn DefDatabase, generic_params: &GenericParams, p:
312
307
}
313
308
}
314
309
315
- #[ cfg( test) ]
316
310
fn print_generic_params ( db : & dyn DefDatabase , generic_params : & GenericParams , p : & mut Printer < ' _ > ) {
317
311
if !generic_params. is_empty ( ) {
318
312
w ! ( p, "<" ) ;
0 commit comments