Skip to content

Commit 4ae99cc

Browse files
committed
Fix ICE when pointing at multi bytes character
1 parent d107a87 commit 4ae99cc

File tree

6 files changed

+66
-21
lines changed

6 files changed

+66
-21
lines changed

compiler/rustc_parse/src/parser/mod.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -721,13 +721,9 @@ impl<'a> Parser<'a> {
721721
Ok(t) => {
722722
// Parsed successfully, therefore most probably the code only
723723
// misses a separator.
724-
let mut exp_span = self.sess.source_map().next_point(sp);
725-
if self.sess.source_map().is_multiline(exp_span) {
726-
exp_span = sp;
727-
}
728724
expect_err
729725
.span_suggestion_short(
730-
exp_span,
726+
sp,
731727
&format!("missing `{}`", token_str),
732728
token_str,
733729
Applicability::MaybeIncorrect,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Regression test for #80134.
2+
3+
fn main() {
4+
(()é);
5+
//~^ ERROR: expected one of `)`, `,`, `.`, `?`, or an operator
6+
//~| ERROR: cannot find value `é` in this scope
7+
//~| ERROR: non-ascii idents are not fully supported
8+
(());
9+
//~^ ERROR: expected one of `)`, `,`, `.`, `?`, or an operator
10+
//~| ERROR: cannot find value `氷` in this scope
11+
//~| ERROR: non-ascii idents are not fully supported
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
error: expected one of `)`, `,`, `.`, `?`, or an operator, found `é`
2+
--> $DIR/multibyte-char-use-seperator-issue-80134.rs:4:8
3+
|
4+
LL | (()é);
5+
| ^
6+
| |
7+
| expected one of `)`, `,`, `.`, `?`, or an operator
8+
| help: missing `,`
9+
10+
error: expected one of `)`, `,`, `.`, `?`, or an operator, found `氷`
11+
--> $DIR/multibyte-char-use-seperator-issue-80134.rs:8:8
12+
|
13+
LL | (()氷);
14+
| -^
15+
| |
16+
| expected one of `)`, `,`, `.`, `?`, or an operator
17+
| help: missing `,`
18+
19+
error[E0425]: cannot find value `é` in this scope
20+
--> $DIR/multibyte-char-use-seperator-issue-80134.rs:4:8
21+
|
22+
LL | (()é);
23+
| ^ not found in this scope
24+
25+
error[E0425]: cannot find value `氷` in this scope
26+
--> $DIR/multibyte-char-use-seperator-issue-80134.rs:8:8
27+
|
28+
LL | (()氷);
29+
| ^^ not found in this scope
30+
31+
error[E0658]: non-ascii idents are not fully supported
32+
--> $DIR/multibyte-char-use-seperator-issue-80134.rs:4:8
33+
|
34+
LL | (()é);
35+
| ^
36+
|
37+
= note: see issue #55467 <https://github.com/rust-lang/rust/issues/55467> for more information
38+
= help: add `#![feature(non_ascii_idents)]` to the crate attributes to enable
39+
40+
error[E0658]: non-ascii idents are not fully supported
41+
--> $DIR/multibyte-char-use-seperator-issue-80134.rs:8:8
42+
|
43+
LL | (()氷);
44+
| ^^
45+
|
46+
= note: see issue #55467 <https://github.com/rust-lang/rust/issues/55467> for more information
47+
= help: add `#![feature(non_ascii_idents)]` to the crate attributes to enable
48+
49+
error: aborting due to 6 previous errors
50+
51+
Some errors have detailed explanations: E0425, E0658.
52+
For more information about an error, try `rustc --explain E0425`.

src/test/ui/similar-tokens.fixed

-13
This file was deleted.

src/test/ui/similar-tokens.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// run-rustfix
2-
31
#![allow(unused_imports)]
42

53
pub mod x {

src/test/ui/similar-tokens.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: expected one of `,`, `::`, `as`, or `}`, found `.`
2-
--> $DIR/similar-tokens.rs:11:10
2+
--> $DIR/similar-tokens.rs:9:10
33
|
44
LL | use x::{A. B};
55
| ^

0 commit comments

Comments
 (0)