Skip to content

Commit 373a154

Browse files
committed
fix: "Formatting argument out of range" in rustc nightly
relates rust-lang/rust#136932 fixes #9738
1 parent b0e7a0f commit 373a154

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/handlers/graphical.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,8 @@ impl GraphicalReportHandler {
10411041
let vbar_offset = (start + end) / 2;
10421042
let num_left = vbar_offset - start;
10431043
let num_right = end - vbar_offset - 1;
1044+
// Throws `Formatting argument out of range` when width is above u16::MAX.
1045+
let width = start.saturating_sub(highest).min(u16::MAX as usize);
10441046
underlines.push_str(
10451047
&format!(
10461048
"{:width$}{}{}{}",
@@ -1054,7 +1056,6 @@ impl GraphicalReportHandler {
10541056
chars.underline
10551057
},
10561058
chars.underline.to_string().repeat(num_right),
1057-
width = start.saturating_sub(highest),
10581059
)
10591060
.style(hl.style)
10601061
.to_string(),

0 commit comments

Comments
 (0)