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

failed to parse Real("...") #4418

Closed
dtolnay opened this issue Sep 9, 2020 · 1 comment · Fixed by #4439
Closed

failed to parse Real("...") #4418

dtolnay opened this issue Sep 9, 2020 · 1 comment · Fixed by #4439
Assignees
Labels
a-parser bug Panic, non-idempotency, invalid code, etc.

Comments

@dtolnay
Copy link
Member

dtolnay commented Sep 9, 2020

Describe the bug

This message sometimes (but not always) appears at the bottom of output after a parse error. It seems unintentional and maybe like some accidental debug logging.

$  target/release/rustfmt src/openbrace.rs 
error: this file contains an unclosed delimiter
 --> /git/rustfmt/src/openbrace.rs:1:3
  |
1 | {
  | - ^
  | |
  | unclosed delimiter

error: expected item, found `{`
 --> /git/rustfmt/src/openbrace.rs:1:1
  |
1 | {
  | ^ expected item

failed to parse Real("/git/rustfmt/src/openbrace.rs")

$  target/release/rustfmt src/closebrace.rs 
error: unexpected closing delimiter: `}`
 --> /git/rustfmt/src/closebrace.rs:1:1
  |
1 | }
  | ^ unexpected closing delimiter

$  

To Reproduce

Build rustfmt from master branch (currently 6646248). Write { to openbrace.rs and } to closebrace.rs. Run rustfmt on each as shown above. failed to parse Real("...") appears for openbrace.rs, though not for closebrace.rs. It should be for neither.

Expected behavior

Just the compiler-style diagnostics would be sufficient. failed to parse Real("...") should not appear also at the end.

@dtolnay dtolnay added the bug Panic, non-idempotency, invalid code, etc. label Sep 9, 2020
@calebcartwright calebcartwright self-assigned this Sep 26, 2020
@calebcartwright
Copy link
Member

Thanks for the report! There were indeed two bugs here:

  1. A typo/issue in how we we were using thiserror on the parsing error variant which was causing the spurious failed to parse Real("...") instead of the expected failed to parse /home/caleb/dev/rustfmt-sandbox/....
  2. An unhandled rustc parser panic that was only hit with certain types of input in the entry point file (closedbrace.rs in your example)

Just the compiler-style diagnostics would be sufficient. failed to parse Real("...") should not appear also at the end.

We actually do want to surface up the rustfmt operation error, including the parsing variants (just without the formatting bug). It's important because users can actually instruct rustfmt to disable the compiler diagnostics via certain config options, like hide_parser_errors, and we don't want to fail completely silently, and it's also useful for us in bug reports since there's a few different code branches that can have the compiler-style parser error emissions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-parser bug Panic, non-idempotency, invalid code, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants