Rollup merge of #91764 - cjgillot:elide-anyway, r=jackh726

Do not ICE when suggesting elided lifetimes on non-existent spans.

Fixes https://github.com/rust-lang/rust/issues/91763

r? `@jackh726`
This commit is contained in:
Matthias Krüger 2021-12-11 23:31:52 +01:00 committed by GitHub
commit 72b6a91fe7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 78 additions and 21 deletions

View file

@ -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",