From: AnthonyMikh Date: Sat, 5 Oct 2019 00:08:05 +0000 (+0300) Subject: Correctly estimate required space for string X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=4414068cc49803b0dacba133b7788b8b95b0b473;p=rust.git Correctly estimate required space for string `.len()` returns length in bytes so it overestimates the required space --- diff --git a/src/librustc_errors/styled_buffer.rs b/src/librustc_errors/styled_buffer.rs index 6e03618d2b0..b12ab9e4576 100644 --- a/src/librustc_errors/styled_buffer.rs +++ b/src/librustc_errors/styled_buffer.rs @@ -111,7 +111,7 @@ pub fn puts(&mut self, line: usize, col: usize, string: &str, style: Style) { pub fn prepend(&mut self, line: usize, string: &str, style: Style) { self.ensure_lines(line); - let string_len = string.len(); + let string_len = string.chars().count(); // Push the old content over to make room for new content for _ in 0..string_len {