Skip to content
New issue

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

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

Already on GitHub? # to your account

unexpected token: <eof> although it's not eof, but eoi #112458

Closed
hellow554 opened this issue Jun 9, 2023 · 0 comments · Fixed by #112518
Closed

unexpected token: <eof> although it's not eof, but eoi #112458

hellow554 opened this issue Jun 9, 2023 · 0 comments · Fixed by #112518
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-parser Area: The parsing of Rust source code to an AST T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@hellow554
Copy link
Contributor

hellow554 commented Jun 9, 2023

Code

fn main() {
    println!("", x.);
}

Current output

error: unexpected token: `<eof>`
 --> src/main.rs:2:19
  |
2 |     println!("", x.);
  |                   ^

Desired output

error: unexpected token: `)`
 --> src/main.rs:2:19
  |
2 |     println!("", x.);
  |                    ^

Rationale and extra context

While I fully understand, why it is saying <eof>, I'm not sure if this can be improved, e.g. if the subparser says eof but the current parser has a character at that position, it could say which one it is.
Also the spike ^ points to the "eof" of the macro input, which can be improved I guess.

If we remove the !, it is exactly what I'd like to see:

error: unexpected token: `)`
 --> src/main.rs:2:19
  |
2 |     println("", x.);
  |                   ^
@hellow554 hellow554 added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 9, 2023
@jyn514 jyn514 added A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-parser Area: The parsing of Rust source code to an AST labels Jun 9, 2023
@chenyukang chenyukang self-assigned this Jun 10, 2023
@bors bors closed this as completed in 9f2c21c Jun 27, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-parser Area: The parsing of Rust source code to an AST T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants