@@ -129,21 +129,16 @@ pub(super) fn note_and_explain_region<'tcx>(
129129    alt_span :  Option < Span > , 
130130)  { 
131131    let  ( description,  span)  = match  * region { 
132-         ty:: ReEarlyBound ( _)  | ty:: ReFree ( _)  | ty:: ReStatic  => { 
133-             msg_span_from_free_region ( tcx,  region,  alt_span) 
132+         ty:: ReEarlyBound ( _)  | ty:: ReFree ( _)  | ty:: RePlaceholder ( _ )  | ty :: ReStatic  => { 
133+             msg_span_from_named_region ( tcx,  region,  alt_span) 
134134        } 
135135
136-         ty:: RePlaceholder ( _)  => return , 
137- 
138136        ty:: ReError ( _)  => return , 
139137
140-         // FIXME(#13998) RePlaceholder should probably print like 
141-         // ReFree rather than dumping Debug output on the user. 
142-         // 
143138        // We shouldn't really be having unification failures with ReVar 
144139        // and ReLateBound though. 
145140        ty:: ReVar ( _)  | ty:: ReLateBound ( ..)  | ty:: ReErased  => { 
146-             ( format ! ( "lifetime {:?}"  ,  region ) ,  alt_span) 
141+             ( format ! ( "lifetime `{region}`"  ) ,  alt_span) 
147142        } 
148143    } ; 
149144
@@ -157,12 +152,12 @@ fn explain_free_region<'tcx>(
157152    region :  ty:: Region < ' tcx > , 
158153    suffix :  & str , 
159154)  { 
160-     let  ( description,  span)  = msg_span_from_free_region ( tcx,  region,  None ) ; 
155+     let  ( description,  span)  = msg_span_from_named_region ( tcx,  region,  None ) ; 
161156
162157    label_msg_span ( err,  prefix,  description,  span,  suffix) ; 
163158} 
164159
165- fn  msg_span_from_free_region < ' tcx > ( 
160+ fn  msg_span_from_named_region < ' tcx > ( 
166161    tcx :  TyCtxt < ' tcx > , 
167162    region :  ty:: Region < ' tcx > , 
168163    alt_span :  Option < Span > , 
@@ -173,6 +168,18 @@ fn msg_span_from_free_region<'tcx>(
173168            ( msg,  Some ( span) ) 
174169        } 
175170        ty:: ReStatic  => ( "the static lifetime" . to_owned ( ) ,  alt_span) , 
171+         ty:: RePlaceholder ( ty:: PlaceholderRegion  { 
172+             name :  ty:: BoundRegionKind :: BrNamed ( def_id,  name) , 
173+             ..
174+         } )  => ( format ! ( "the lifetime `{name}` as defined here" ) ,  Some ( tcx. def_span ( def_id) ) ) , 
175+         ty:: RePlaceholder ( ty:: PlaceholderRegion  { 
176+             name :  ty:: BoundRegionKind :: BrAnon ( _,  Some ( span) ) , 
177+             ..
178+         } )  => ( format ! ( "the anonymous lifetime defined here" ) ,  Some ( span) ) , 
179+         ty:: RePlaceholder ( ty:: PlaceholderRegion  { 
180+             name :  ty:: BoundRegionKind :: BrAnon ( _,  None ) , 
181+             ..
182+         } )  => ( format ! ( "an anonymous lifetime" ) ,  None ) , 
176183        _ => bug ! ( "{:?}" ,  region) , 
177184    } 
178185} 
0 commit comments