@@ -208,45 +208,34 @@ impl BorrowExplanation {
208
208
) ;
209
209
} ;
210
210
211
- self . add_lifetime_bound_suggestion_to_diagnostic (
212
- tcx,
213
- err,
214
- & category,
215
- span,
216
- region_name,
217
- ) ;
211
+ self . add_lifetime_bound_suggestion_to_diagnostic ( err, & category, span, region_name) ;
218
212
}
219
213
_ => { }
220
214
}
221
215
}
222
- pub ( in crate :: borrow_check) fn add_lifetime_bound_suggestion_to_diagnostic < ' tcx > (
216
+ pub ( in crate :: borrow_check) fn add_lifetime_bound_suggestion_to_diagnostic (
223
217
& self ,
224
- tcx : TyCtxt < ' tcx > ,
225
218
err : & mut DiagnosticBuilder < ' _ > ,
226
219
category : & ConstraintCategory ,
227
220
span : Span ,
228
221
region_name : & RegionName ,
229
222
) {
230
223
if let ConstraintCategory :: OpaqueType = category {
231
- if let Ok ( snippet) = tcx. sess . source_map ( ) . span_to_snippet ( span) {
232
- let suggestable_name = if region_name. was_named ( ) {
233
- region_name. to_string ( )
234
- } else {
235
- "'_" . to_string ( )
236
- } ;
224
+ let suggestable_name =
225
+ if region_name. was_named ( ) { region_name. to_string ( ) } else { "'_" . to_string ( ) } ;
237
226
238
- err . span_suggestion (
239
- span ,
240
- & format ! (
241
- "you can add a bound to the {}to make it last less than \
242
- `'static` and match `{}`" ,
243
- category . description ( ) ,
244
- region_name ,
245
- ) ,
246
- format ! ( "{} + {}" , snippet , suggestable_name ) ,
247
- Applicability :: Unspecified ,
248
- ) ;
249
- }
227
+ let msg = format ! (
228
+ "you can add a bound to the {}to make it last less than `'static` and match `{}`" ,
229
+ category . description ( ) ,
230
+ region_name ,
231
+ ) ;
232
+
233
+ err . span_suggestion_verbose (
234
+ span . shrink_to_hi ( ) ,
235
+ & msg ,
236
+ format ! ( " + {}" , suggestable_name ) ,
237
+ Applicability :: Unspecified ,
238
+ ) ;
250
239
}
251
240
}
252
241
}
0 commit comments