@@ -116,7 +116,7 @@ pub(super) fn note_and_explain_region(
116116 emit_msg_span ( err, prefix, description, span, suffix) ;
117117}
118118
119- pub ( super ) fn note_and_explain_free_region (
119+ fn explain_free_region (
120120 tcx : TyCtxt < ' tcx > ,
121121 err : & mut DiagnosticBuilder < ' _ > ,
122122 prefix : & str ,
@@ -125,7 +125,7 @@ pub(super) fn note_and_explain_free_region(
125125) {
126126 let ( description, span) = msg_span_from_free_region ( tcx, region, None ) ;
127127
128- emit_msg_span ( err, prefix, description, span, suffix) ;
128+ label_msg_span ( err, prefix, description, span, suffix) ;
129129}
130130
131131fn msg_span_from_free_region (
@@ -210,6 +210,22 @@ fn emit_msg_span(
210210 }
211211}
212212
213+ fn label_msg_span (
214+ err : & mut DiagnosticBuilder < ' _ > ,
215+ prefix : & str ,
216+ description : String ,
217+ span : Option < Span > ,
218+ suffix : & str ,
219+ ) {
220+ let message = format ! ( "{}{}{}" , prefix, description, suffix) ;
221+
222+ if let Some ( span) = span {
223+ err. span_label ( span, & message) ;
224+ } else {
225+ err. note ( & message) ;
226+ }
227+ }
228+
213229pub fn unexpected_hidden_region_diagnostic (
214230 tcx : TyCtxt < ' tcx > ,
215231 span : Span ,
@@ -244,7 +260,7 @@ pub fn unexpected_hidden_region_diagnostic(
244260 //
245261 // (*) if not, the `tainted_by_errors` field would be set to
246262 // `Some(ErrorReported)` in any case, so we wouldn't be here at all.
247- note_and_explain_free_region (
263+ explain_free_region (
248264 tcx,
249265 & mut err,
250266 & format ! ( "hidden type `{}` captures " , hidden_ty) ,
0 commit comments