diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2021-12-11 00:58:13 +0100 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2021-12-11 11:08:46 +0100 |
| commit | 9a680037425b730787dc3071bb0837aaeee8d3fb (patch) | |
| tree | b063020d97a8f8959d6280f173f16b2627d456c6 | |
| parent | d9e997d9ebaf3b3d9bd547c22620ecdf3aee8a3e (diff) | |
| download | rust-9a680037425b730787dc3071bb0837aaeee8d3fb.tar.gz rust-9a680037425b730787dc3071bb0837aaeee8d3fb.zip | |
Do not ICE when suggesting elided lifetimes on non-existent spans.
| -rw-r--r-- | compiler/rustc_resolve/src/late/diagnostics.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 72ba3f7b980..feb4f82ce8d 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", |
