From db3cf486315471493c99a71338f37c92d45ea893 Mon Sep 17 00:00:00 2001 From: ElKowar Date: Thu, 9 Jul 2026 12:51:10 +0200 Subject: [PATCH] fix: don't drop cause-chain when rendering related errors as nested Previously, using the show_related_errors_as_nested feature introduced in 771a075, any cause-chain of those nested errors would be dropped, so the information would get lost. --- src/handlers/graphical.rs | 5 ++++- tests/test_diagnostic_source_macro.rs | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/handlers/graphical.rs b/src/handlers/graphical.rs index 37b6bf8..f82b1f0 100644 --- a/src/handlers/graphical.rs +++ b/src/handlers/graphical.rs @@ -504,7 +504,10 @@ impl GraphicalReportHandler { let mut inner_renderer = self.clone(); inner_renderer.footer = None; - inner_renderer.with_cause_chain = false; + // Each related error is an independent diagnostic whose cause + // chain has not been flattened, so keep printing it to avoid + // dropping the source chain and its details. + inner_renderer.with_cause_chain = true; inner_renderer.termwidth -= rest_indent.width(); inner_renderer.render_report_inner(&mut inner, rel, src)?; diff --git a/tests/test_diagnostic_source_macro.rs b/tests/test_diagnostic_source_macro.rs index 1349303..a6c3cfb 100644 --- a/tests/test_diagnostic_source_macro.rs +++ b/tests/test_diagnostic_source_macro.rs @@ -345,6 +345,16 @@ fn test_display_related_errors_as_nested() { × A multi-error happened ├─▶ × A multi-error happened │ ├─▶ × A nested error happened + │ │ ├─▶ × TestError + │ │ │ + │ │ ╰─▶ × A complex error happened + │ │ ╭──── + │ │ 1 │ This is another error + │ │ · ──┬─ + │ │ · ╰── here + │ │ ╰──── + │ │ help: You should fix this + │ │ │ │ ╭──── │ │ 1 │ right here │ │ · ──┬─