-
Notifications
You must be signed in to change notification settings - Fork 898
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
internal error: entered unreachable code #4357
Comments
Thanks for sharing @ehuss , and providing the additional details and minimal repro! Invalid code scenarios are a little tricky. The general rule of thumb is that if the rustc parser can still successfully generate an AST (which is clearly the case here) then rustfmt should be able to format. However, there's been a few other cases where invalid code was too problematic to be format-able. If anyone knows a valid minimal repro scenario please feel free to share |
* Add a test for #4357 * Format error and typeof types
* Add a test for rust-lang#4357 * Format error and typeof types
* Add a test for #4357 * Format error and typeof types
Backported in v1.4.30 |
Describe the bug
In some situations, rustfmt will panic with the following error:
thread 'main' panicked at 'internal error: entered unreachable code', src/tools/rustfmt/src/types.rs:764:59
To Reproduce
This is a repost of rust-lang/cargo#8388, so I don't know the original code (the reporter said it was close source and could not share). However, here are some examples that can trigger it:
Of course these aren't valid, but they hit this line. I'm not sure if there are legitimate cases that would hit this. Another guess is that maybe the user had format-on-save, and was in the middle of some unfinished code?
Meta
rustfmt 1.4.19-nightly (cef1c0d5 2020-07-21)
cargo fmt
The text was updated successfully, but these errors were encountered: