Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ICE when pointing at multi bytes character #80185

Merged
merged 1 commit into from
Dec 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions compiler/rustc_parse/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 12 additions & 0 deletions src/test/ui/parser/multibyte-char-use-seperator-issue-80134.rs
Original file line number Diff line number Diff line change
@@ -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
}
52 changes: 52 additions & 0 deletions src/test/ui/parser/multibyte-char-use-seperator-issue-80134.stderr
Original file line number Diff line number Diff line change
@@ -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`.
13 changes: 0 additions & 13 deletions src/test/ui/similar-tokens.fixed

This file was deleted.

2 changes: 0 additions & 2 deletions src/test/ui/similar-tokens.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// run-rustfix

#![allow(unused_imports)]

pub mod x {
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/similar-tokens.stderr
Original file line number Diff line number Diff line change
@@ -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};
| ^
Expand Down