Skip to content

Conversation

JohnTitor
Copy link
Member

Previously, when an impl Trait captured multiple higher-ranked
lifetimes from an outer impl Trait, the compiler would emit a
separate error for each captured lifetime. This resulted in verbose
and confusing diagnostics, especially in edition 2024 where implicit
captures caused duplicate errors.

This commit introduces error accumulation that collects all capture
spans and lifetime declaration spans, then emits a single consolidated
diagnostic using MultiSpan. The new error shows all captured lifetimes
with visual indicators and lists all declarations in a single note.

r? @estebank
Fixes #143022

  Previously, when an `impl Trait` captured multiple higher-ranked
  lifetimes from an outer `impl Trait`, the compiler would emit a
  separate error for each captured lifetime. This resulted in verbose
  and confusing diagnostics, especially in edition 2024 where implicit
  captures caused duplicate errors.

  This commit introduces error accumulation that collects all capture
  spans and lifetime declaration spans, then emits a single consolidated
  diagnostic using MultiSpan. The new error shows all captured lifetimes
  with visual indicators and lists all declarations in a single note.
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Higher-ranked lifetimes captured by impl Trait result in too many errors in 2024 edition

3 participants