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.
27 lines
914 B
Text
27 lines
914 B
Text
error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from `dyn` type
|
|
--> $DIR/E0657.rs:10:27
|
|
|
|
|
LL | -> Box<dyn for<'a> Id<impl Lt<'a>>>
|
|
| ^^^^^^^^--^ `impl Trait` implicitly captures all lifetimes in scope
|
|
|
|
|
note: lifetime declared here
|
|
--> $DIR/E0657.rs:10:20
|
|
|
|
|
LL | -> Box<dyn for<'a> Id<impl Lt<'a>>>
|
|
| ^^
|
|
|
|
error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from `dyn` type
|
|
--> $DIR/E0657.rs:19:31
|
|
|
|
|
LL | -> Box<dyn for<'a> Id<impl Lt<'a>>>
|
|
| ^^^^^^^^--^ `impl Trait` implicitly captures all lifetimes in scope
|
|
|
|
|
note: lifetime declared here
|
|
--> $DIR/E0657.rs:19:24
|
|
|
|
|
LL | -> Box<dyn for<'a> Id<impl Lt<'a>>>
|
|
| ^^
|
|
|
|
error: aborting due to 2 previous errors
|
|
|
|
For more information about this error, try `rustc --explain E0657`.
|