From 5a71e1235137fdcdef124b3af914ef06a24d65c4 Mon Sep 17 00:00:00 2001 From: est31 Date: Fri, 25 Aug 2017 12:25:22 +0200 Subject: Fix a byte/char confusion issue in the error emitter Fixes #44078. Fixes #44023. The start_col member is given in chars, while the code previously assumed it was given in bytes. The more basic issue #44080 doesn't get fixed. --- src/librustc_errors/emitter.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/librustc_errors') diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index 3b1414ef83a..53d90531cc9 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -311,7 +311,9 @@ impl EmitterWriter { if line.annotations.len() == 1 { if let Some(ref ann) = line.annotations.get(0) { if let AnnotationType::MultilineStart(depth) = ann.annotation_type { - if source_string[0..ann.start_col].trim() == "" { + if source_string.chars() + .take(ann.start_col) + .all(|c| c.is_whitespace()) { let style = if ann.is_primary { Style::UnderlinePrimary } else { -- cgit 1.4.1-3-g733a5