Skip to content

Commit 96b5d0b

Browse files
authored
fix: truncate width into u16::MAX for graphical reporter (#10180)
1 parent 80544ee commit 96b5d0b

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

crates/rspack_error/src/graphical.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -696,12 +696,9 @@ impl GraphicalReportHandler {
696696
let num_left = vbar_offset - start;
697697
let num_right = end - vbar_offset - 1;
698698
if start < end {
699-
let width = start.saturating_sub(highest);
700699
// CHANGE:
701700
// Rust PR https://github.com/rust-lang/rust/issues/99012 limited format string width and precision to 16 bits, causing panics when dynamic padding exceeds `u16::MAX`.
702-
// This fixes exessively large width that exceeds `u16::MAX` by directly printing exceeded width.
703-
let pre_width = width.saturating_sub(u16::MAX as usize);
704-
underlines.push_str(&format!("{:width$}", "", width = pre_width));
701+
let width = start.saturating_sub(highest).min(u16::MAX as usize);
705702
underlines.push_str(
706703
&format!(
707704
"{:width$}{}{}{}",
@@ -715,7 +712,6 @@ impl GraphicalReportHandler {
715712
chars.underline
716713
},
717714
chars.underline.to_string().repeat(num_right),
718-
width = width.min(u16::MAX as usize),
719715
)
720716
.style(hl.style)
721717
.to_string(),

0 commit comments

Comments
 (0)