fix ICE due to empty span and empty suggestions

This commit is contained in:
Ralf Jung 2023-09-24 23:30:09 +02:00
parent 19c65022fc
commit 4f86c69184

View File

@ -2596,7 +2596,9 @@ fn show_candidates(
);
if let [first, .., last] = &path[..] {
let sp = first.ident.span.until(last.ident.span);
if sp.can_be_used_for_suggestions() {
// Our suggestion is empty, so make sure the span is not empty (or we'd ICE).
// Can happen for derive-generated spans.
if sp.can_be_used_for_suggestions() && !sp.is_empty() {
err.span_suggestion_verbose(
sp,
format!("if you import `{}`, refer to it directly", last.ident),