From 9a680037425b730787dc3071bb0837aaeee8d3fb Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 11 Dec 2021 00:58:13 +0100 Subject: [PATCH] Do not ICE when suggesting elided lifetimes on non-existent spans. --- compiler/rustc_resolve/src/late/diagnostics.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 72ba3f7b980c..feb4f82ce8dd 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -2115,6 +2115,11 @@ impl<'tcx> LifetimeContext<'_, 'tcx> { }) .map(|(formatter, span)| (*span, formatter(name))) .collect(); + if spans_suggs.is_empty() { + // If all the spans come from macros, we cannot extract snippets and then + // `formatters` only contains None and `spans_suggs` is empty. + return; + } err.multipart_suggestion_verbose( &format!( "consider using the `{}` lifetime",