about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2023-09-24 23:30:09 +0200
committerRalf Jung <post@ralfj.de>2023-09-24 23:32:36 +0200
commit4f86c69184adc53051a97c658ba9f691665799f5 (patch)
tree77ef5bc8d3564fd8301ae6582dc92237a751366a /compiler/rustc_resolve/src
parent19c65022fc1ad9cc3d3dcf50a0bdf50e4ab572ab (diff)
downloadrust-4f86c69184adc53051a97c658ba9f691665799f5.tar.gz
rust-4f86c69184adc53051a97c658ba9f691665799f5.zip
fix ICE due to empty span and empty suggestions
Diffstat (limited to 'compiler/rustc_resolve/src')
-rw-r--r--compiler/rustc_resolve/src/diagnostics.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs
index 9b7fd76d103..907a6b1c46c 100644
--- a/compiler/rustc_resolve/src/diagnostics.rs
+++ b/compiler/rustc_resolve/src/diagnostics.rs
@@ -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),