@@ -17,11 +17,16 @@ impl<'tcx> Printer<'tcx> for TypeNamePrinter<'tcx> {
1717 self . tcx
1818 }
1919
20- fn print_region ( & mut self , _region : ty:: Region < ' _ > ) -> Result < ( ) , PrintError > {
20+ fn print_region ( & mut self , region : ty:: Region < ' _ > ) -> Result < ( ) , PrintError > {
2121 // 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)
2530 }
2631
2732 fn print_type ( & mut self , ty : Ty < ' tcx > ) -> Result < ( ) , PrintError > {
@@ -168,10 +173,11 @@ impl<'tcx> PrettyPrinter<'tcx> for TypeNamePrinter<'tcx> {
168173 // Bound regions are always printed (as `'_`), which gives some idea that they are special,
169174 // even though the `for` is omitted by the pretty printer.
170175 // E.g. `for<'a, 'b> fn(&'a u32, &'b u32)` is printed as "fn(&'_ u32, &'_ u32)".
176+ let kind = region. kind ( ) ;
171177 match region. kind ( ) {
172178 ty:: ReErased | ty:: ReEarlyParam ( _) => false ,
173- ty:: ReBound ( ..) => true ,
174- _ => unreachable ! ( ) ,
179+ ty:: ReBound ( ..) | ty :: ReStatic => true ,
180+ _ => panic ! ( "type_name unhandled region: {kind:?}" ) ,
175181 }
176182 }
177183
0 commit comments