@@ -112,7 +112,7 @@ pub fn explain_region_and_span(cx: ctxt, region: ty::Region)
112112 idx + 1 ) ,
113113 br_fresh( _) => fmt ! ( "an anonymous lifetime defined on" ) ,
114114 _ => fmt ! ( "the lifetime %s as defined on" ,
115- bound_region_to_str ( cx, fr. bound_region) )
115+ bound_region_ptr_to_str ( cx, fr. bound_region) )
116116 } ;
117117
118118 match cx. items . find ( & fr. scope_id ) {
@@ -147,22 +147,23 @@ pub fn explain_region_and_span(cx: ctxt, region: ty::Region)
147147 }
148148}
149149
150- pub fn bound_region_to_str ( cx : ctxt , br : bound_region ) -> ~str {
151- bound_region_to_str_space ( cx, "&" , br)
150+ pub fn bound_region_ptr_to_str ( cx : ctxt , br : bound_region ) -> ~str {
151+ bound_region_to_str ( cx, "&" , true , br)
152152}
153153
154- pub fn bound_region_to_str_space ( cx : ctxt ,
155- prefix : & str ,
156- br : bound_region )
157- -> ~str {
158- if cx. sess . verbose ( ) { return fmt ! ( "%s%? " , prefix, br) ; }
154+ pub fn bound_region_to_str ( cx : ctxt ,
155+ prefix : & str , space : bool ,
156+ br : bound_region ) -> ~str {
157+ let space_str = if space { " " } else { "" } ;
158+
159+ if cx. sess . verbose ( ) { return fmt ! ( "%s%?%s" , prefix, br, space_str) ; }
159160
160161 match br {
161- br_named( id) => fmt ! ( "%s'%s " , prefix, cx. sess. str_of( id) ) ,
162- br_self => fmt ! ( "%s'self " , prefix) ,
162+ br_named( id) => fmt ! ( "%s'%s%s " , prefix, cx. sess. str_of( id) , space_str ) ,
163+ br_self => fmt ! ( "%s'self%s " , prefix, space_str ) ,
163164 br_anon( _) => prefix. to_str ( ) ,
164165 br_fresh( _) => prefix. to_str ( ) ,
165- br_cap_avoid( _, br) => bound_region_to_str_space ( cx, prefix, * br)
166+ br_cap_avoid( _, br) => bound_region_to_str ( cx, prefix, space , * br)
166167 }
167168}
168169
@@ -208,13 +209,15 @@ pub fn re_scope_id_to_str(cx: ctxt, node_id: ast::node_id) -> ~str {
208209// In general, if you are giving a region error message,
209210// you should use `explain_region()` or, better yet,
210211// `note_and_explain_region()`
211- pub fn region_to_str ( cx : ctxt , region : Region ) -> ~str {
212- region_to_str_space ( cx, "&" , region)
212+ pub fn region_ptr_to_str ( cx : ctxt , region : Region ) -> ~str {
213+ region_to_str ( cx, "&" , true , region)
213214}
214215
215- pub fn region_to_str_space ( cx : ctxt , prefix : & str , region : Region ) -> ~str {
216+ pub fn region_to_str ( cx : ctxt , prefix : & str , space : bool , region : Region ) -> ~str {
217+ let space_str = if space { " " } else { "" } ;
218+
216219 if cx. sess . verbose ( ) {
217- return fmt ! ( "%s%? " , prefix, region) ;
220+ return fmt ! ( "%s%?%s " , prefix, region, space_str ) ;
218221 }
219222
220223 // These printouts are concise. They do not contain all the information
@@ -223,14 +226,14 @@ pub fn region_to_str_space(cx: ctxt, prefix: &str, region: Region) -> ~str {
223226 // `explain_region()` or `note_and_explain_region()`.
224227 match region {
225228 re_scope( _) => prefix. to_str ( ) ,
226- re_bound( br) => bound_region_to_str_space ( cx, prefix, br) ,
227- re_free( ref fr) => bound_region_to_str_space ( cx, prefix, fr. bound_region ) ,
229+ re_bound( br) => bound_region_to_str ( cx, prefix, space , br) ,
230+ re_free( ref fr) => bound_region_to_str ( cx, prefix, space , fr. bound_region ) ,
228231 re_infer( ReSkolemized ( _, br) ) => {
229- bound_region_to_str_space ( cx, prefix, br)
232+ bound_region_to_str ( cx, prefix, space , br)
230233 }
231234 re_infer( ReVar ( _) ) => prefix. to_str ( ) ,
232- re_static => fmt ! ( "%s'static " , prefix) ,
233- re_empty => fmt ! ( "%s'<empty> " , prefix)
235+ re_static => fmt ! ( "%s'static%s " , prefix, space_str ) ,
236+ re_empty => fmt ! ( "%s'<empty>%s " , prefix, space_str )
234237 }
235238}
236239
@@ -256,15 +259,15 @@ pub fn vstore_to_str(cx: ctxt, vs: ty::vstore) -> ~str {
256259 ty : : vstore_fixed( n) => fmt ! ( "%u" , n) ,
257260 ty : : vstore_uniq => ~"~",
258261 ty : : vstore_box => ~"@",
259- ty::vstore_slice(r) => region_to_str_space (cx, " & " , r)
262+ ty::vstore_slice(r) => region_ptr_to_str (cx, r)
260263 }
261264}
262265
263266pub fn trait_store_to_str(cx: ctxt, s: ty::TraitStore) -> ~str {
264267 match s {
265268 ty::UniqTraitStore => ~" ~",
266269 ty:: BoxTraitStore => ~"@",
267- ty:: RegionTraitStore ( r) => region_to_str_space ( cx, "&" , r)
270+ ty:: RegionTraitStore ( r) => region_ptr_to_str ( cx, r)
268271 }
269272}
270273
@@ -340,7 +343,7 @@ pub fn ty_to_str(cx: ctxt, typ: t) -> ~str {
340343 ( ast:: OwnedSigil , ty:: re_static) => { }
341344
342345 ( _, region) => {
343- s. push_str ( region_to_str_space ( cx, "" , region) ) ;
346+ s. push_str ( region_to_str ( cx, "" , true , region) ) ;
344347 }
345348 }
346349
@@ -414,7 +417,7 @@ pub fn ty_to_str(cx: ctxt, typ: t) -> ~str {
414417 ty_uniq( ref tm) => ~"~" + mt_to_str ( cx, tm) ,
415418 ty_ptr( ref tm) => ~"* " + mt_to_str(cx, tm),
416419 ty_rptr(r, ref tm) => {
417- region_to_str_space (cx, " & " , r) + mt_to_str(cx, tm)
420+ region_ptr_to_str (cx, r) + mt_to_str(cx, tm)
418421 }
419422 ty_unboxed_vec(ref tm) => { fmt!(" unboxed_vec<%s>", mt_to_str(cx, tm)) }
420423 ty_type => ~" type",
@@ -431,13 +434,15 @@ pub fn ty_to_str(cx: ctxt, typ: t) -> ~str {
431434 ty_infer( infer_ty) => infer_ty. to_str ( ) ,
432435 ty_err => ~"[ type error] ",
433436 ty_param( param_ty { idx : id, def_id : did} ) => {
437+ let mut parm = ( ( 'T' as uint ) + id) as char ;
438+ if ( parm as uint ) > ( 'Z' as uint ) {
439+ parm = ( parm as uint - 26 ) as char ;
440+ }
441+
434442 if cx. sess . verbose ( ) {
435- fmt ! ( "'%s:%?" ,
436- str :: from_bytes( [ ( 'a' as u8 ) + ( id as u8 ) ] ) ,
437- did)
443+ fmt ! ( "%c:%?" , parm, did)
438444 } else {
439- fmt ! ( "'%s" ,
440- str :: from_bytes( [ ( 'a' as u8 ) + ( id as u8 ) ] ) )
445+ fmt ! ( "%c" , parm)
441446 }
442447 }
443448 ty_self( * ) => ~"Self ",
@@ -468,18 +473,20 @@ pub fn parameterized(cx: ctxt,
468473 self_r : Option < ty:: Region > ,
469474 tps : & [ ty:: t ] ) -> ~str {
470475
471- let r_str = match self_r {
472- None => ~"",
476+ let mut strs = ~[ ] ;
477+ match self_r {
478+ None => ( ) ,
473479 Some ( r) => {
474- region_to_str ( cx, r )
480+ strs . push ( region_to_str ( cx, "" , false , r ) )
475481 }
476482 } ;
477483
478- if tps. len ( ) > 0 u {
479- let strs = vec:: map ( tps, |t| ty_to_str ( cx, * t) ) ;
480- fmt ! ( "%s%s<%s>" , r_str, base, strs. connect( "," ) )
484+ strs += vec:: map ( tps, |t| ty_to_str ( cx, * t) ) ;
485+
486+ if strs. len ( ) > 0 u {
487+ fmt ! ( "%s<%s>" , base, strs. connect( "," ) )
481488 } else {
482- fmt ! ( "%s%s" , r_str , base)
489+ fmt ! ( "%s" , base)
483490 }
484491}
485492
@@ -597,7 +604,7 @@ impl Repr for @ast::pat {
597604
598605impl Repr for ty:: Region {
599606 fn repr ( & self , tcx : ctxt ) -> ~str {
600- region_to_str ( tcx, * self )
607+ region_to_str ( tcx, "" , false , * self )
601608 }
602609}
603610
0 commit comments