1
Fork 0

Proper span for new generic param suggestion

This commit is contained in:
stoozy 2022-09-28 00:33:52 -04:00
parent 24c8e27a1d
commit e7cb6ad8ce
2 changed files with 17 additions and 4 deletions

View file

@ -1333,11 +1333,16 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
);
diag.span_label(lifetime_ref.span, "expected named lifetime parameter");
diag.multipart_suggestion("consider introducing a named lifetime parameter",
vec![
(lifetime_ref.span.shrink_to_hi(), "'a ".to_owned()),
(generics.span, "<'a>".to_owned())
match generics.span_for_param_suggestion() {
Some(_) => {
(self.tcx.sess.source_map().span_through_char(generics.span, '<').shrink_to_hi(), "'a, ".to_owned())
}
None => (generics.span, "<'a>".to_owned()),
}
], rustc_errors::Applicability::MaybeIncorrect);
diag.emit();