From 0af97c623e8d25ce8d2ad905f6e98089be6b1061 Mon Sep 17 00:00:00 2001 From: Soon Date: Mon, 6 May 2024 13:31:31 +0800 Subject: [PATCH] fix(rspack_loader_runner): char_boundary panic when debug content (#6412) --- crates/rspack_loader_runner/src/content.rs | 5 ++++- crates/rspack_loader_runner/src/lib.rs | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/rspack_loader_runner/src/content.rs b/crates/rspack_loader_runner/src/content.rs index 96078d10ed8..421c3aeb171 100644 --- a/crates/rspack_loader_runner/src/content.rs +++ b/crates/rspack_loader_runner/src/content.rs @@ -87,7 +87,10 @@ impl Debug for Content { }; content - .field(ty, &s[0..usize::min(s.len(), 20)].to_owned()) + .field( + ty, + &s[0..usize::min(s.len(), s.ceil_char_boundary(20))].to_owned(), + ) .finish() } } diff --git a/crates/rspack_loader_runner/src/lib.rs b/crates/rspack_loader_runner/src/lib.rs index 1d8e3c6c40a..a3a0987c4c7 100644 --- a/crates/rspack_loader_runner/src/lib.rs +++ b/crates/rspack_loader_runner/src/lib.rs @@ -1,4 +1,5 @@ #![feature(let_chains)] +#![feature(round_char_boundary)] mod content; mod loader;