@@ -129,21 +129,16 @@ pub(super) fn note_and_explain_region<'tcx>(
129
129
alt_span : Option < Span > ,
130
130
) {
131
131
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)
134
134
}
135
135
136
- ty:: RePlaceholder ( _) => return ,
137
-
138
136
ty:: ReError ( _) => return ,
139
137
140
- // FIXME(#13998) RePlaceholder should probably print like
141
- // ReFree rather than dumping Debug output on the user.
142
- //
143
138
// We shouldn't really be having unification failures with ReVar
144
139
// and ReLateBound though.
145
140
ty:: ReVar ( _) | ty:: ReLateBound ( ..) | ty:: ReErased => {
146
- ( format ! ( "lifetime {:?}" , region ) , alt_span)
141
+ ( format ! ( "lifetime `{region}`" ) , alt_span)
147
142
}
148
143
} ;
149
144
@@ -157,12 +152,12 @@ fn explain_free_region<'tcx>(
157
152
region : ty:: Region < ' tcx > ,
158
153
suffix : & str ,
159
154
) {
160
- let ( description, span) = msg_span_from_free_region ( tcx, region, None ) ;
155
+ let ( description, span) = msg_span_from_named_region ( tcx, region, None ) ;
161
156
162
157
label_msg_span ( err, prefix, description, span, suffix) ;
163
158
}
164
159
165
- fn msg_span_from_free_region < ' tcx > (
160
+ fn msg_span_from_named_region < ' tcx > (
166
161
tcx : TyCtxt < ' tcx > ,
167
162
region : ty:: Region < ' tcx > ,
168
163
alt_span : Option < Span > ,
@@ -173,6 +168,18 @@ fn msg_span_from_free_region<'tcx>(
173
168
( msg, Some ( span) )
174
169
}
175
170
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 ) ,
176
183
_ => bug ! ( "{:?}" , region) ,
177
184
}
178
185
}
0 commit comments