@@ -43,9 +43,6 @@ pub trait Repr {
43
43
/// Produces a string suitable for showing to the user.
44
44
pub trait UserString {
45
45
fn user_string ( & self , tcx : & ctxt ) -> String ;
46
- fn user_string_with_var_ids ( & self , tcx : & ctxt , _: bool ) -> String {
47
- self . user_string ( tcx)
48
- }
49
46
}
50
47
51
48
pub fn note_and_explain_region ( cx : & ctxt ,
@@ -231,14 +228,10 @@ pub fn mutability_to_string(m: ast::Mutability) -> String {
231
228
}
232
229
}
233
230
234
- pub fn mt_to_string_with_var_ids ( cx : & ctxt , m : & mt , print_var_ids : bool ) -> String {
231
+ pub fn mt_to_string ( cx : & ctxt , m : & mt ) -> String {
235
232
format ! ( "{}{}" ,
236
233
mutability_to_string( m. mutbl) ,
237
- ty_to_string_with_var_ids( cx, m. ty, print_var_ids) )
238
- }
239
-
240
- pub fn mt_to_string ( cx : & ctxt , m : & mt ) -> String {
241
- mt_to_string_with_var_ids ( cx, m, false )
234
+ ty_to_string( cx, m. ty) )
242
235
}
243
236
244
237
pub fn trait_store_to_string ( cx : & ctxt , s : ty:: TraitStore ) -> String {
@@ -265,17 +258,11 @@ pub fn trait_ref_to_string(cx: &ctxt, trait_ref: &ty::TraitRef) -> String {
265
258
}
266
259
267
260
pub fn ty_to_string ( cx : & ctxt , typ : t ) -> String {
268
- ty_to_string_with_var_ids ( cx, typ, true )
269
- }
270
-
271
- pub fn ty_to_string_with_var_ids ( cx : & ctxt , typ : t , mut print_var_ids : bool ) -> String {
272
- print_var_ids = print_var_ids || cx. sess . verbose ( ) ;
273
261
fn bare_fn_to_string ( cx : & ctxt ,
274
262
fn_style : ast:: FnStyle ,
275
263
abi : abi:: Abi ,
276
264
ident : Option < ast:: Ident > ,
277
- sig : & ty:: FnSig ,
278
- print_var_ids : bool )
265
+ sig : & ty:: FnSig )
279
266
-> String {
280
267
let mut s = String :: new ( ) ;
281
268
match fn_style {
@@ -300,12 +287,12 @@ pub fn ty_to_string_with_var_ids(cx: &ctxt, typ: t, mut print_var_ids: bool) ->
300
287
_ => { }
301
288
}
302
289
303
- push_sig_to_string ( cx, & mut s, '(' , ')' , sig, "" , print_var_ids ) ;
290
+ push_sig_to_string ( cx, & mut s, '(' , ')' , sig, "" ) ;
304
291
305
292
s
306
293
}
307
294
308
- fn closure_to_string ( cx : & ctxt , cty : & ty:: ClosureTy , print_var_ids : bool ) -> String {
295
+ fn closure_to_string ( cx : & ctxt , cty : & ty:: ClosureTy ) -> String {
309
296
let mut s = String :: new ( ) ;
310
297
311
298
match cty. store {
@@ -330,15 +317,15 @@ pub fn ty_to_string_with_var_ids(cx: &ctxt, typ: t, mut print_var_ids: bool) ->
330
317
assert_eq ! ( cty. onceness, ast:: Once ) ;
331
318
s. push_str ( "proc" ) ;
332
319
push_sig_to_string ( cx, & mut s, '(' , ')' , & cty. sig ,
333
- bounds_str. as_slice ( ) , print_var_ids ) ;
320
+ bounds_str. as_slice ( ) ) ;
334
321
}
335
322
ty:: RegionTraitStore ( ..) => {
336
323
match cty. onceness {
337
324
ast:: Many => { }
338
325
ast:: Once => s. push_str ( "once " )
339
326
}
340
327
push_sig_to_string ( cx, & mut s, '|' , '|' , & cty. sig ,
341
- bounds_str. as_slice ( ) , print_var_ids ) ;
328
+ bounds_str. as_slice ( ) ) ;
342
329
}
343
330
}
344
331
@@ -350,12 +337,11 @@ pub fn ty_to_string_with_var_ids(cx: &ctxt, typ: t, mut print_var_ids: bool) ->
350
337
bra : char ,
351
338
ket : char ,
352
339
sig : & ty:: FnSig ,
353
- bounds : & str ,
354
- print_var_ids : bool ) {
340
+ bounds : & str ) {
355
341
s. push ( bra) ;
356
342
let strs = sig. inputs
357
343
. iter ( )
358
- . map ( |a| ty_to_string_with_var_ids ( cx, * a, print_var_ids ) )
344
+ . map ( |a| ty_to_string ( cx, * a) )
359
345
. collect :: < Vec < _ > > ( ) ;
360
346
s. push_str ( strs. connect ( ", " ) . as_slice ( ) ) ;
361
347
if sig. variadic {
@@ -372,7 +358,7 @@ pub fn ty_to_string_with_var_ids(cx: &ctxt, typ: t, mut print_var_ids: bool) ->
372
358
ty:: FnConverging ( t) => {
373
359
if !ty:: type_is_nil ( t) {
374
360
s. push_str ( " -> " ) ;
375
- s. push_str ( ty_to_string_with_var_ids ( cx, t, print_var_ids ) . as_slice ( ) ) ;
361
+ s. push_str ( ty_to_string ( cx, t) . as_slice ( ) ) ;
376
362
}
377
363
}
378
364
ty:: FnDiverging => {
@@ -381,21 +367,20 @@ pub fn ty_to_string_with_var_ids(cx: &ctxt, typ: t, mut print_var_ids: bool) ->
381
367
}
382
368
}
383
369
384
- fn infer_ty_to_string ( ty : ty:: InferTy , print_var_ids : bool ) -> String {
370
+ fn infer_ty_to_string ( cx : & ctxt , ty : ty:: InferTy ) -> String {
371
+ let print_var_ids = cx. sess . verbose ( ) ;
385
372
match ty {
386
- ty:: TyVar ( ty:: TyVid { index : vid } ) |
387
- ty:: IntVar ( ty:: IntVid { index : vid } ) |
388
- ty:: FloatVar ( ty:: FloatVid { index : vid } ) => {
389
- match ty {
390
- ty:: TyVar ( _) if print_var_ids => format ! ( "_#{}" , vid) ,
391
- ty:: TyVar ( _) => "_" . to_string ( ) ,
392
- ty:: IntVar ( _) => format ! ( "_#{}i" , vid) ,
393
- ty:: FloatVar ( _) => format ! ( "_#{}f" , vid) ,
394
- _ => unreachable ! ( )
395
- }
396
- }
373
+ ty:: TyVar ( ty:: TyVid { index : vid } ) if print_var_ids =>
374
+ format ! ( "_#{}" , vid) ,
375
+ ty:: IntVar ( ty:: IntVid { index : vid } ) if print_var_ids =>
376
+ format ! ( "_#{}i" , vid) ,
377
+ ty:: FloatVar ( ty:: FloatVid { index : vid } ) if print_var_ids =>
378
+ format ! ( "_#{}f" , vid) ,
379
+ ty:: TyVar ( _) => "_" . to_string ( ) ,
380
+ ty:: IntVar ( _) => "_#i" . to_string ( ) ,
381
+ ty:: FloatVar ( _) => "_#f" . to_string ( ) ,
397
382
ty:: SkolemizedTy ( v) => format ! ( "SkolemizedTy({})" , v) ,
398
- ty:: SkolemizedIntTy ( v) => format ! ( "SkolemizedIntTy({})" , v) ,
383
+ ty:: SkolemizedIntTy ( v) => format ! ( "SkolemizedIntTy({})" , v)
399
384
}
400
385
}
401
386
@@ -407,7 +392,7 @@ pub fn ty_to_string_with_var_ids(cx: &ctxt, typ: t, mut print_var_ids: bool) ->
407
392
ty_int( t) => ast_util:: int_ty_to_string ( t, None ) . to_string ( ) ,
408
393
ty_uint( t) => ast_util:: uint_ty_to_string ( t, None ) . to_string ( ) ,
409
394
ty_float( t) => ast_util:: float_ty_to_string ( t) . to_string ( ) ,
410
- ty_uniq( typ) => format ! ( "Box<{}>" , ty_to_string_with_var_ids ( cx, typ, print_var_ids ) ) ,
395
+ ty_uniq( typ) => format ! ( "Box<{}>" , ty_to_string ( cx, typ) ) ,
411
396
ty_ptr( ref tm) => {
412
397
format ! ( "*{} {}" , match tm. mutbl {
413
398
ast:: MutMutable => "mut" ,
@@ -416,42 +401,42 @@ pub fn ty_to_string_with_var_ids(cx: &ctxt, typ: t, mut print_var_ids: bool) ->
416
401
}
417
402
ty_rptr( r, ref tm) => {
418
403
let mut buf = region_ptr_to_string ( cx, r) ;
419
- buf. push_str ( mt_to_string_with_var_ids ( cx, tm, print_var_ids ) . as_slice ( ) ) ;
404
+ buf. push_str ( mt_to_string ( cx, tm) . as_slice ( ) ) ;
420
405
buf
421
406
}
422
407
ty_open( typ) =>
423
- format ! ( "opened<{}>" , ty_to_string_with_var_ids ( cx, typ, print_var_ids ) ) ,
408
+ format ! ( "opened<{}>" , ty_to_string ( cx, typ) ) ,
424
409
ty_tup( ref elems) => {
425
410
let strs = elems
426
411
. iter ( )
427
- . map ( |elem| ty_to_string_with_var_ids ( cx, * elem, print_var_ids ) )
412
+ . map ( |elem| ty_to_string ( cx, * elem) )
428
413
. collect :: < Vec < _ > > ( ) ;
429
414
match strs. as_slice ( ) {
430
415
[ ref string] => format ! ( "({},)" , string) ,
431
416
strs => format ! ( "({})" , strs. connect( ", " ) )
432
417
}
433
418
}
434
419
ty_closure( ref f) => {
435
- closure_to_string ( cx, & * * f, print_var_ids )
420
+ closure_to_string ( cx, & * * f)
436
421
}
437
422
ty_bare_fn( ref f) => {
438
- bare_fn_to_string ( cx, f. fn_style , f. abi , None , & f. sig , print_var_ids )
423
+ bare_fn_to_string ( cx, f. fn_style , f. abi , None , & f. sig )
439
424
}
440
- ty_infer( infer_ty) => infer_ty_to_string ( infer_ty , print_var_ids ) ,
425
+ ty_infer( infer_ty) => infer_ty_to_string ( cx , infer_ty ) ,
441
426
ty_err => "[type error]" . to_string ( ) ,
442
427
ty_param( ref param_ty) => param_ty. repr ( cx) ,
443
428
ty_enum( did, ref substs) | ty_struct( did, ref substs) => {
444
429
let base = ty:: item_path_str ( cx, did) ;
445
430
let generics = ty:: lookup_item_type ( cx, did) . generics ;
446
- parameterized ( cx, base. as_slice ( ) , substs, & generics, print_var_ids )
431
+ parameterized ( cx, base. as_slice ( ) , substs, & generics)
447
432
}
448
433
ty_trait( box ty:: TyTrait {
449
434
def_id : did, ref substs, ref bounds
450
435
} ) => {
451
436
let base = ty:: item_path_str ( cx, did) ;
452
437
let trait_def = ty:: lookup_trait_def ( cx, did) ;
453
438
let ty = parameterized ( cx, base. as_slice ( ) ,
454
- substs, & trait_def. generics , print_var_ids ) ;
439
+ substs, & trait_def. generics ) ;
455
440
let bound_str = bounds. user_string ( cx) ;
456
441
let bound_sep = if bound_str. is_empty ( ) { "" } else { "+" } ;
457
442
format ! ( "{}{}{}" ,
@@ -463,11 +448,11 @@ pub fn ty_to_string_with_var_ids(cx: &ctxt, typ: t, mut print_var_ids: bool) ->
463
448
ty_unboxed_closure( ref did, _, ref substs) => {
464
449
let unboxed_closures = cx. unboxed_closures . borrow ( ) ;
465
450
unboxed_closures. find ( did) . map ( |cl| {
466
- closure_to_string ( cx, & cl. closure_type . subst ( cx, substs) , print_var_ids )
451
+ closure_to_string ( cx, & cl. closure_type . subst ( cx, substs) )
467
452
} ) . unwrap_or_else ( || "closure" . to_string ( ) )
468
453
}
469
454
ty_vec( t, sz) => {
470
- let inner_str = ty_to_string_with_var_ids ( cx, t, print_var_ids ) ;
455
+ let inner_str = ty_to_string ( cx, t) ;
471
456
match sz {
472
457
Some ( n) => format ! ( "[{}, ..{}]" , inner_str, n) ,
473
458
None => format ! ( "[{}]" , inner_str) ,
@@ -492,8 +477,7 @@ pub fn explicit_self_category_to_str(category: &ty::ExplicitSelfCategory)
492
477
pub fn parameterized ( cx : & ctxt ,
493
478
base : & str ,
494
479
substs : & subst:: Substs ,
495
- generics : & ty:: Generics ,
496
- print_var_ids : bool )
480
+ generics : & ty:: Generics )
497
481
-> String
498
482
{
499
483
let mut strs = Vec :: new ( ) ;
@@ -532,7 +516,7 @@ pub fn parameterized(cx: &ctxt,
532
516
} ;
533
517
534
518
for t in tps[ ..tps. len ( ) - num_defaults] . iter ( ) {
535
- strs. push ( ty_to_string_with_var_ids ( cx, * t, print_var_ids ) )
519
+ strs. push ( ty_to_string ( cx, * t) )
536
520
}
537
521
538
522
if cx. sess . verbose ( ) {
@@ -743,7 +727,7 @@ impl Repr for ty::TraitRef {
743
727
let trait_def = ty:: lookup_trait_def ( tcx, self . def_id ) ;
744
728
format ! ( "<{} as {}>" ,
745
729
self . substs. self_ty( ) . repr( tcx) ,
746
- parameterized( tcx, base. as_slice( ) , & self . substs, & trait_def. generics, false ) )
730
+ parameterized( tcx, base. as_slice( ) , & self . substs, & trait_def. generics) )
747
731
}
748
732
}
749
733
@@ -1128,22 +1112,16 @@ impl UserString for ty::BuiltinBounds {
1128
1112
1129
1113
impl UserString for ty:: TraitRef {
1130
1114
fn user_string ( & self , tcx : & ctxt ) -> String {
1131
- self . user_string_with_var_ids ( tcx, false )
1132
- }
1133
- fn user_string_with_var_ids ( & self , tcx : & ctxt , print_var_ids : bool ) -> String {
1134
1115
let base = ty:: item_path_str ( tcx, self . def_id ) ;
1135
1116
let trait_def = ty:: lookup_trait_def ( tcx, self . def_id ) ;
1136
- parameterized ( tcx, base. as_slice ( ) , & self . substs , & trait_def. generics , print_var_ids )
1117
+ parameterized ( tcx, base. as_slice ( ) , & self . substs , & trait_def. generics )
1137
1118
}
1138
1119
}
1139
1120
1140
1121
impl UserString for ty:: t {
1141
1122
fn user_string ( & self , tcx : & ctxt ) -> String {
1142
1123
ty_to_string ( tcx, * self )
1143
1124
}
1144
- fn user_string_with_var_ids ( & self , tcx : & ctxt , print_var_ids : bool ) -> String {
1145
- ty_to_string_with_var_ids ( tcx, * self , print_var_ids)
1146
- }
1147
1125
}
1148
1126
1149
1127
impl UserString for ast:: Ident {
0 commit comments