From 373a154679d868cf690ffa53de01f689069afd4b Mon Sep 17 00:00:00 2001 From: Boshen Date: Wed, 19 Mar 2025 14:41:06 +0800 Subject: [PATCH] fix: "Formatting argument out of range" in rustc nightly relates https://github.com/rust-lang/rust/pull/136932 fixes #9738 --- src/handlers/graphical.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/handlers/graphical.rs b/src/handlers/graphical.rs index 7948e38..c77cfec 100644 --- a/src/handlers/graphical.rs +++ b/src/handlers/graphical.rs @@ -1041,6 +1041,8 @@ impl GraphicalReportHandler { let vbar_offset = (start + end) / 2; let num_left = vbar_offset - start; let num_right = end - vbar_offset - 1; + // Throws `Formatting argument out of range` when width is above u16::MAX. + let width = start.saturating_sub(highest).min(u16::MAX as usize); underlines.push_str( &format!( "{:width$}{}{}{}", @@ -1054,7 +1056,6 @@ impl GraphicalReportHandler { chars.underline }, chars.underline.to_string().repeat(num_right), - width = start.saturating_sub(highest), ) .style(hl.style) .to_string(),