@@ -148,28 +148,36 @@ pub fn parameterized<GG>(f: &mut fmt::Formatter,
148148 write ! ( f, "{}" , cont)
149149 }
150150 } ;
151- let print_region = |f : & mut fmt:: Formatter , region : & ty:: Region | -> _ {
152- if verbose {
153- write ! ( f, "{:?}" , region)
154- } else {
155- let s = region. to_string ( ) ;
156- if s. is_empty ( ) {
157- // This happens when the value of the region
158- // parameter is not easily serialized. This may be
159- // because the user omitted it in the first place,
160- // or because it refers to some block in the code,
161- // etc. I'm not sure how best to serialize this.
162- write ! ( f, "'_" )
151+
152+ let print_regions = |f : & mut fmt:: Formatter , start : & str , regions : & [ ty:: Region ] | {
153+ // Don't print any regions if they're all erased.
154+ if regions. iter ( ) . all ( |r| * r == ty:: ReErased ) {
155+ return Ok ( ( ) ) ;
156+ }
157+
158+ for region in regions {
159+ start_or_continue ( f, start, ", " ) ?;
160+ if verbose {
161+ write ! ( f, "{:?}" , region) ?;
163162 } else {
164- write ! ( f, "{}" , s)
163+ let s = region. to_string ( ) ;
164+ if s. is_empty ( ) {
165+ // This happens when the value of the region
166+ // parameter is not easily serialized. This may be
167+ // because the user omitted it in the first place,
168+ // or because it refers to some block in the code,
169+ // etc. I'm not sure how best to serialize this.
170+ write ! ( f, "'_" ) ?;
171+ } else {
172+ write ! ( f, "{}" , s) ?;
173+ }
165174 }
166175 }
176+
177+ Ok ( ( ) )
167178 } ;
168179
169- for region in substs. regions . get_slice ( subst:: TypeSpace ) {
170- start_or_continue ( f, "<" , ", " ) ?;
171- print_region ( f, region) ?;
172- }
180+ print_regions ( f, "<" , substs. regions . get_slice ( subst:: TypeSpace ) ) ?;
173181
174182 let num_supplied_defaults = if verbose {
175183 0
@@ -211,10 +219,7 @@ pub fn parameterized<GG>(f: &mut fmt::Formatter,
211219 write ! ( f, "::{}" , item_name) ?;
212220 }
213221
214- for region in substs. regions . get_slice ( subst:: FnSpace ) {
215- start_or_continue ( f, "::<" , ", " ) ?;
216- print_region ( f, region) ?;
217- }
222+ print_regions ( f, "::<" , substs. regions . get_slice ( subst:: FnSpace ) ) ?;
218223
219224 // FIXME: consider being smart with defaults here too
220225 for ty in substs. types . get_slice ( subst:: FnSpace ) {
@@ -536,7 +541,9 @@ impl fmt::Debug for ty::Region {
536541 write ! ( f, "ReSkolemized({}, {:?})" , id. index, bound_region)
537542 }
538543
539- ty:: ReEmpty => write ! ( f, "ReEmpty" )
544+ ty:: ReEmpty => write ! ( f, "ReEmpty" ) ,
545+
546+ ty:: ReErased => write ! ( f, "ReErased" )
540547 }
541548 }
542549}
@@ -600,7 +607,8 @@ impl fmt::Display for ty::Region {
600607 write ! ( f, "{}" , br)
601608 }
602609 ty:: ReScope ( _) |
603- ty:: ReVar ( _) => Ok ( ( ) ) ,
610+ ty:: ReVar ( _) |
611+ ty:: ReErased => Ok ( ( ) ) ,
604612 ty:: ReStatic => write ! ( f, "'static" ) ,
605613 ty:: ReEmpty => write ! ( f, "'<empty>" ) ,
606614 }
0 commit comments