@@ -43,9 +43,6 @@ pub trait Repr {
4343/// Produces a string suitable for showing to the user.
4444pub trait UserString {
4545 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- }
4946}
5047
5148pub fn note_and_explain_region ( cx : & ctxt ,
@@ -231,14 +228,10 @@ pub fn mutability_to_string(m: ast::Mutability) -> String {
231228 }
232229}
233230
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 {
235232 format ! ( "{}{}" ,
236233 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) )
242235}
243236
244237pub 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 {
265258}
266259
267260pub 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 ( ) ;
273261 fn bare_fn_to_string ( cx : & ctxt ,
274262 fn_style : ast:: FnStyle ,
275263 abi : abi:: Abi ,
276264 ident : Option < ast:: Ident > ,
277- sig : & ty:: FnSig ,
278- print_var_ids : bool )
265+ sig : & ty:: FnSig )
279266 -> String {
280267 let mut s = String :: new ( ) ;
281268 match fn_style {
@@ -300,12 +287,12 @@ pub fn ty_to_string_with_var_ids(cx: &ctxt, typ: t, mut print_var_ids: bool) ->
300287 _ => { }
301288 }
302289
303- push_sig_to_string ( cx, & mut s, '(' , ')' , sig, "" , print_var_ids ) ;
290+ push_sig_to_string ( cx, & mut s, '(' , ')' , sig, "" ) ;
304291
305292 s
306293 }
307294
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 {
309296 let mut s = String :: new ( ) ;
310297
311298 match cty. store {
@@ -330,15 +317,15 @@ pub fn ty_to_string_with_var_ids(cx: &ctxt, typ: t, mut print_var_ids: bool) ->
330317 assert_eq ! ( cty. onceness, ast:: Once ) ;
331318 s. push_str ( "proc" ) ;
332319 push_sig_to_string ( cx, & mut s, '(' , ')' , & cty. sig ,
333- bounds_str. as_slice ( ) , print_var_ids ) ;
320+ bounds_str. as_slice ( ) ) ;
334321 }
335322 ty:: RegionTraitStore ( ..) => {
336323 match cty. onceness {
337324 ast:: Many => { }
338325 ast:: Once => s. push_str ( "once " )
339326 }
340327 push_sig_to_string ( cx, & mut s, '|' , '|' , & cty. sig ,
341- bounds_str. as_slice ( ) , print_var_ids ) ;
328+ bounds_str. as_slice ( ) ) ;
342329 }
343330 }
344331
@@ -350,12 +337,11 @@ pub fn ty_to_string_with_var_ids(cx: &ctxt, typ: t, mut print_var_ids: bool) ->
350337 bra : char ,
351338 ket : char ,
352339 sig : & ty:: FnSig ,
353- bounds : & str ,
354- print_var_ids : bool ) {
340+ bounds : & str ) {
355341 s. push ( bra) ;
356342 let strs = sig. inputs
357343 . iter ( )
358- . map ( |a| ty_to_string_with_var_ids ( cx, * a, print_var_ids ) )
344+ . map ( |a| ty_to_string ( cx, * a) )
359345 . collect :: < Vec < _ > > ( ) ;
360346 s. push_str ( strs. connect ( ", " ) . as_slice ( ) ) ;
361347 if sig. variadic {
@@ -372,7 +358,7 @@ pub fn ty_to_string_with_var_ids(cx: &ctxt, typ: t, mut print_var_ids: bool) ->
372358 ty:: FnConverging ( t) => {
373359 if !ty:: type_is_nil ( t) {
374360 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 ( ) ) ;
376362 }
377363 }
378364 ty:: FnDiverging => {
@@ -381,21 +367,20 @@ pub fn ty_to_string_with_var_ids(cx: &ctxt, typ: t, mut print_var_ids: bool) ->
381367 }
382368 }
383369
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 ( ) ;
385372 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 ( ) ,
397382 ty:: SkolemizedTy ( v) => format ! ( "SkolemizedTy({})" , v) ,
398- ty:: SkolemizedIntTy ( v) => format ! ( "SkolemizedIntTy({})" , v) ,
383+ ty:: SkolemizedIntTy ( v) => format ! ( "SkolemizedIntTy({})" , v)
399384 }
400385 }
401386
@@ -407,7 +392,7 @@ pub fn ty_to_string_with_var_ids(cx: &ctxt, typ: t, mut print_var_ids: bool) ->
407392 ty_int( t) => ast_util:: int_ty_to_string ( t, None ) . to_string ( ) ,
408393 ty_uint( t) => ast_util:: uint_ty_to_string ( t, None ) . to_string ( ) ,
409394 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) ) ,
411396 ty_ptr( ref tm) => {
412397 format ! ( "*{} {}" , match tm. mutbl {
413398 ast:: MutMutable => "mut" ,
@@ -416,42 +401,42 @@ pub fn ty_to_string_with_var_ids(cx: &ctxt, typ: t, mut print_var_ids: bool) ->
416401 }
417402 ty_rptr( r, ref tm) => {
418403 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 ( ) ) ;
420405 buf
421406 }
422407 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) ) ,
424409 ty_tup( ref elems) => {
425410 let strs = elems
426411 . iter ( )
427- . map ( |elem| ty_to_string_with_var_ids ( cx, * elem, print_var_ids ) )
412+ . map ( |elem| ty_to_string ( cx, * elem) )
428413 . collect :: < Vec < _ > > ( ) ;
429414 match strs. as_slice ( ) {
430415 [ ref string] => format ! ( "({},)" , string) ,
431416 strs => format ! ( "({})" , strs. connect( ", " ) )
432417 }
433418 }
434419 ty_closure( ref f) => {
435- closure_to_string ( cx, & * * f, print_var_ids )
420+ closure_to_string ( cx, & * * f)
436421 }
437422 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 )
439424 }
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 ) ,
441426 ty_err => "[type error]" . to_string ( ) ,
442427 ty_param( ref param_ty) => param_ty. repr ( cx) ,
443428 ty_enum( did, ref substs) | ty_struct( did, ref substs) => {
444429 let base = ty:: item_path_str ( cx, did) ;
445430 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)
447432 }
448433 ty_trait( box ty:: TyTrait {
449434 def_id : did, ref substs, ref bounds
450435 } ) => {
451436 let base = ty:: item_path_str ( cx, did) ;
452437 let trait_def = ty:: lookup_trait_def ( cx, did) ;
453438 let ty = parameterized ( cx, base. as_slice ( ) ,
454- substs, & trait_def. generics , print_var_ids ) ;
439+ substs, & trait_def. generics ) ;
455440 let bound_str = bounds. user_string ( cx) ;
456441 let bound_sep = if bound_str. is_empty ( ) { "" } else { "+" } ;
457442 format ! ( "{}{}{}" ,
@@ -463,11 +448,11 @@ pub fn ty_to_string_with_var_ids(cx: &ctxt, typ: t, mut print_var_ids: bool) ->
463448 ty_unboxed_closure( ref did, _, ref substs) => {
464449 let unboxed_closures = cx. unboxed_closures . borrow ( ) ;
465450 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) )
467452 } ) . unwrap_or_else ( || "closure" . to_string ( ) )
468453 }
469454 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) ;
471456 match sz {
472457 Some ( n) => format ! ( "[{}, ..{}]" , inner_str, n) ,
473458 None => format ! ( "[{}]" , inner_str) ,
@@ -492,8 +477,7 @@ pub fn explicit_self_category_to_str(category: &ty::ExplicitSelfCategory)
492477pub fn parameterized ( cx : & ctxt ,
493478 base : & str ,
494479 substs : & subst:: Substs ,
495- generics : & ty:: Generics ,
496- print_var_ids : bool )
480+ generics : & ty:: Generics )
497481 -> String
498482{
499483 let mut strs = Vec :: new ( ) ;
@@ -532,7 +516,7 @@ pub fn parameterized(cx: &ctxt,
532516 } ;
533517
534518 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) )
536520 }
537521
538522 if cx. sess . verbose ( ) {
@@ -743,7 +727,7 @@ impl Repr for ty::TraitRef {
743727 let trait_def = ty:: lookup_trait_def ( tcx, self . def_id ) ;
744728 format ! ( "<{} as {}>" ,
745729 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) )
747731 }
748732}
749733
@@ -1128,22 +1112,16 @@ impl UserString for ty::BuiltinBounds {
11281112
11291113impl UserString for ty:: TraitRef {
11301114 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 {
11341115 let base = ty:: item_path_str ( tcx, self . def_id ) ;
11351116 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 )
11371118 }
11381119}
11391120
11401121impl UserString for ty:: t {
11411122 fn user_string ( & self , tcx : & ctxt ) -> String {
11421123 ty_to_string ( tcx, * self )
11431124 }
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- }
11471125}
11481126
11491127impl UserString for ast:: Ident {
0 commit comments