On long E0277 primary span label, move it to a help

Long span labels don't read well.
This commit is contained in:
Esteban Küber 2024-10-25 05:11:42 +00:00
parent 092ecca5b9
commit 1a0c502183
15 changed files with 93 additions and 78 deletions

View file

@ -328,6 +328,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
}
} else if let Some(custom_explanation) = safe_transmute_explanation {
err.span_label(span, custom_explanation);
} else if explanation.len() > self.tcx.sess.diagnostic_width() {
// Really long types don't look good as span labels, instead move it
// to a `help`.
err.span_label(span, "unsatisfied trait bound");
err.help(explanation);
} else {
err.span_label(span, explanation);
}