@@ -17,11 +17,16 @@ impl<'tcx> Printer<'tcx> for TypeNamePrinter<'tcx> {
17
17
self . tcx
18
18
}
19
19
20
- fn print_region ( & mut self , _region : ty:: Region < ' _ > ) -> Result < ( ) , PrintError > {
20
+ fn print_region ( & mut self , region : ty:: Region < ' _ > ) -> Result < ( ) , PrintError > {
21
21
// FIXME: most regions have been erased by the time this code runs.
22
- // Just printing `'_` is a bit hacky but gives mostly good results, and
23
- // doing better is difficult. See `should_print_optional_region`.
24
- write ! ( self , "'_" )
22
+ // Printing `'_` for non-static regions is a bit hacky but gives mostly
23
+ // good results, and doing better is difficult. See
24
+ // `should_print_optional_region`.
25
+ let s = match region. kind ( ) {
26
+ ty:: ReStatic => "'static" ,
27
+ _ => "'_" ,
28
+ } ;
29
+ write ! ( self , "{}" , s)
25
30
}
26
31
27
32
fn print_type ( & mut self , ty : Ty < ' tcx > ) -> Result < ( ) , PrintError > {
@@ -168,10 +173,11 @@ impl<'tcx> PrettyPrinter<'tcx> for TypeNamePrinter<'tcx> {
168
173
// Bound regions are always printed (as `'_`), which gives some idea that they are special,
169
174
// even though the `for` is omitted by the pretty printer.
170
175
// E.g. `for<'a, 'b> fn(&'a u32, &'b u32)` is printed as "fn(&'_ u32, &'_ u32)".
176
+ let kind = region. kind ( ) ;
171
177
match region. kind ( ) {
172
178
ty:: ReErased | ty:: ReEarlyParam ( _) => false ,
173
- ty:: ReBound ( ..) => true ,
174
- _ => unreachable ! ( ) ,
179
+ ty:: ReBound ( ..) | ty :: ReStatic => true ,
180
+ _ => panic ! ( "type_name unhandled region: {kind:?}" ) ,
175
181
}
176
182
}
177
183
0 commit comments