about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYuki Okushi <huyuumi.dev@gmail.com>2020-12-30 22:49:16 +0900
committerGitHub <noreply@github.com>2020-12-30 22:49:16 +0900
commit1caa5b00d5ec25db3888e0010663a0a053ef2e20 (patch)
tree0786fcfd161fac2bc6d8630b57d8705bc581d198
parentd107a87d34c1fc3521aaab7a2576ffbaf59cb2cb (diff)
parent4ae99cc843b923d05e5c0993f732c5e0a9097852 (diff)
downloadrust-1caa5b00d5ec25db3888e0010663a0a053ef2e20.tar.gz
rust-1caa5b00d5ec25db3888e0010663a0a053ef2e20.zip
Rollup merge of #80185 - JohnTitor:issue-80134, r=davidtwco
Fix ICE when pointing at multi bytes character

Fixes #80134

Seems this ICE was introduced by #73953, checking width of span to avoid ICE.
-rw-r--r--compiler/rustc_parse/src/parser/mod.rs6
-rw-r--r--src/test/ui/parser/multibyte-char-use-seperator-issue-80134.rs12
-rw-r--r--src/test/ui/parser/multibyte-char-use-seperator-issue-80134.stderr52
-rw-r--r--src/test/ui/similar-tokens.fixed13
-rw-r--r--src/test/ui/similar-tokens.rs2
-rw-r--r--src/test/ui/similar-tokens.stderr2
6 files changed, 66 insertions, 21 deletions
diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs
index e19ebb8fd2f..1062000fede 100644
--- a/compiler/rustc_parse/src/parser/mod.rs
+++ b/compiler/rustc_parse/src/parser/mod.rs
@@ -721,13 +721,9 @@ impl<'a> Parser<'a> {
                                 Ok(t) => {
                                     // Parsed successfully, therefore most probably the code only
                                     // misses a separator.
-                                    let mut exp_span = self.sess.source_map().next_point(sp);
-                                    if self.sess.source_map().is_multiline(exp_span) {
-                                        exp_span = sp;
-                                    }
                                     expect_err
                                         .span_suggestion_short(
-                                            exp_span,
+                                            sp,
                                             &format!("missing `{}`", token_str),
                                             token_str,
                                             Applicability::MaybeIncorrect,
diff --git a/src/test/ui/parser/multibyte-char-use-seperator-issue-80134.rs b/src/test/ui/parser/multibyte-char-use-seperator-issue-80134.rs
new file mode 100644
index 00000000000..f3ae3aba9b9
--- /dev/null
+++ b/src/test/ui/parser/multibyte-char-use-seperator-issue-80134.rs
@@ -0,0 +1,12 @@
+// Regression test for #80134.
+
+fn main() {
+    (()é);
+    //~^ ERROR: expected one of `)`, `,`, `.`, `?`, or an operator
+    //~| ERROR: cannot find value `é` in this scope
+    //~| ERROR: non-ascii idents are not fully supported
+    (()氷);
+    //~^ ERROR: expected one of `)`, `,`, `.`, `?`, or an operator
+    //~| ERROR: cannot find value `氷` in this scope
+    //~| ERROR: non-ascii idents are not fully supported
+}
diff --git a/src/test/ui/parser/multibyte-char-use-seperator-issue-80134.stderr b/src/test/ui/parser/multibyte-char-use-seperator-issue-80134.stderr
new file mode 100644
index 00000000000..892cc92b1bd
--- /dev/null
+++ b/src/test/ui/parser/multibyte-char-use-seperator-issue-80134.stderr
@@ -0,0 +1,52 @@
+error: expected one of `)`, `,`, `.`, `?`, or an operator, found `é`
+  --> $DIR/multibyte-char-use-seperator-issue-80134.rs:4:8
+   |
+LL |     (()é);
+   |        ^
+   |        |
+   |        expected one of `)`, `,`, `.`, `?`, or an operator
+   |        help: missing `,`
+
+error: expected one of `)`, `,`, `.`, `?`, or an operator, found `氷`
+  --> $DIR/multibyte-char-use-seperator-issue-80134.rs:8:8
+   |
+LL |     (()氷);
+   |        -^
+   |        |
+   |        expected one of `)`, `,`, `.`, `?`, or an operator
+   |        help: missing `,`
+
+error[E0425]: cannot find value `é` in this scope
+  --> $DIR/multibyte-char-use-seperator-issue-80134.rs:4:8
+   |
+LL |     (()é);
+   |        ^ not found in this scope
+
+error[E0425]: cannot find value `氷` in this scope
+  --> $DIR/multibyte-char-use-seperator-issue-80134.rs:8:8
+   |
+LL |     (()氷);
+   |        ^^ not found in this scope
+
+error[E0658]: non-ascii idents are not fully supported
+  --> $DIR/multibyte-char-use-seperator-issue-80134.rs:4:8
+   |
+LL |     (()é);
+   |        ^
+   |
+   = note: see issue #55467 <https://github.com/rust-lang/rust/issues/55467> for more information
+   = help: add `#![feature(non_ascii_idents)]` to the crate attributes to enable
+
+error[E0658]: non-ascii idents are not fully supported
+  --> $DIR/multibyte-char-use-seperator-issue-80134.rs:8:8
+   |
+LL |     (()氷);
+   |        ^^
+   |
+   = note: see issue #55467 <https://github.com/rust-lang/rust/issues/55467> for more information
+   = help: add `#![feature(non_ascii_idents)]` to the crate attributes to enable
+
+error: aborting due to 6 previous errors
+
+Some errors have detailed explanations: E0425, E0658.
+For more information about an error, try `rustc --explain E0425`.
diff --git a/src/test/ui/similar-tokens.fixed b/src/test/ui/similar-tokens.fixed
deleted file mode 100644
index addba76ae3b..00000000000
--- a/src/test/ui/similar-tokens.fixed
+++ /dev/null
@@ -1,13 +0,0 @@
-// run-rustfix
-
-#![allow(unused_imports)]
-
-pub mod x {
-    pub struct A;
-    pub struct B;
-}
-
-// `.` is similar to `,` so list parsing should continue to closing `}`
-use x::{A, B}; //~ ERROR expected one of `,`, `::`, `as`, or `}`, found `.`
-
-fn main() {}
diff --git a/src/test/ui/similar-tokens.rs b/src/test/ui/similar-tokens.rs
index 3d1bf5fe54a..e3024c61ad2 100644
--- a/src/test/ui/similar-tokens.rs
+++ b/src/test/ui/similar-tokens.rs
@@ -1,5 +1,3 @@
-// run-rustfix
-
 #![allow(unused_imports)]
 
 pub mod x {
diff --git a/src/test/ui/similar-tokens.stderr b/src/test/ui/similar-tokens.stderr
index 6a8d09ebae6..90acfc052dd 100644
--- a/src/test/ui/similar-tokens.stderr
+++ b/src/test/ui/similar-tokens.stderr
@@ -1,5 +1,5 @@
 error: expected one of `,`, `::`, `as`, or `}`, found `.`
-  --> $DIR/similar-tokens.rs:11:10
+  --> $DIR/similar-tokens.rs:9:10
    |
 LL | use x::{A. B};
    |          ^