about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-08-26 12:50:11 +0000
committerbors <bors@rust-lang.org>2017-08-26 12:50:11 +0000
commit669d4770f2bac53a58bc9be0907f879b451be9b2 (patch)
tree4bf2646693e45f74df9a17a75842c88bd8690719
parente7070dd019d70b089a9983571dc40b2f9ee16cf5 (diff)
parent5a71e1235137fdcdef124b3af914ef06a24d65c4 (diff)
downloadrust-669d4770f2bac53a58bc9be0907f879b451be9b2.tar.gz
rust-669d4770f2bac53a58bc9be0907f879b451be9b2.zip
Auto merge of #44081 - est31:master, r=eddyb
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.
-rw-r--r--src/librustc_errors/emitter.rs4
-rw-r--r--src/test/ui/issue-44023.rs16
-rw-r--r--src/test/ui/issue-44023.stderr13
-rw-r--r--src/test/ui/issue-44078.rs13
-rw-r--r--src/test/ui/issue-44078.stderr10
5 files changed, 55 insertions, 1 deletions
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 {
diff --git a/src/test/ui/issue-44023.rs b/src/test/ui/issue-44023.rs
new file mode 100644
index 00000000000..295d4808289
--- /dev/null
+++ b/src/test/ui/issue-44023.rs
@@ -0,0 +1,16 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(non_ascii_idents)]
+
+pub fn main () {}
+
+fn საჭმელად_გემრიელი_სადილი ( ) -> isize {
+}
diff --git a/src/test/ui/issue-44023.stderr b/src/test/ui/issue-44023.stderr
new file mode 100644
index 00000000000..a17512ba4ab
--- /dev/null
+++ b/src/test/ui/issue-44023.stderr
@@ -0,0 +1,13 @@
+error[E0308]: mismatched types
+  --> $DIR/issue-44023.rs:15:42
+   |
+15 |   fn საჭმელად_გემრიელი_სადილი ( ) -> isize {
+   |  __________________________________________^
+16 | | }
+   | |_^ expected isize, found ()
+   |
+   = note: expected type `isize`
+              found type `()`
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/issue-44078.rs b/src/test/ui/issue-44078.rs
new file mode 100644
index 00000000000..ef47214f2b3
--- /dev/null
+++ b/src/test/ui/issue-44078.rs
@@ -0,0 +1,13 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+    "😊"";
+}
diff --git a/src/test/ui/issue-44078.stderr b/src/test/ui/issue-44078.stderr
new file mode 100644
index 00000000000..389f3b2479a
--- /dev/null
+++ b/src/test/ui/issue-44078.stderr
@@ -0,0 +1,10 @@
+error: unterminated double quote string
+  --> $DIR/issue-44078.rs:12:8
+   |
+12 |       "😊"";
+   |  ________^
+13 | | }
+   | |__^
+
+error: aborting due to previous error
+