-
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
Catch panics in the parser #753
Comments
The Rust parser reports some errors by panicking, the Rust compiler has a panic catcher to prevent these appearing as panics to the user. We don't do that in rustfmt, so when there is a parsing error like this, rustfmt panics. We should fix this by adding a panic catcher around the parser (or wait for the parser to become non-panicking, which should happen eventually). |
debug $ dd if=/dev/zero of=c bs=1 count=1
1+0 records in
1+0 records out
1 byte copied, 0.0001716 s, 5.8 kB/s
Press any key to continue...
debug $ RUST_BACKTRACE=1 ./rustfmt c
c:1:1: 1:2 error: unknown start of token: \u{0}
c:1
^
thread '<main>' panicked at 'Box<Any>', /home/censoredbyfbi/.cargo/registry/src/github.com-1ecc6299db9ec823/syntex_syntax-0.32.0/src/parse/lexer/mod.rs:199
stack backtrace:
1: 0x55a87ad946f0 - std::sys::backtrace::tracing::imp::write::h82353b94d9957b5a
2: 0x55a87ad9764b - std::panicking::default_hook::_$u7b$$u7b$closure$u7d$$u7d$::hd08c9fd28a21a931
3: 0x55a87ad972d3 - std::panicking::default_hook::h9f5ce461fe95b992
4: 0x55a87ad88d18 - std::panicking::rust_panic_with_hook::hfb9137c9fa89bbb0
5: 0x55a87ab0e796 - std::panicking::begin_panic::h68586c3453bafff6
at src/libstd/panicking.rs:327
6: 0x55a87ab8bb27 - syntex_syntax::parse::lexer::StringReader::new::h2c3a6ffb705c7baa
at /home/censoredbyfbi/build/censoredbyfbi/rustfmt/<std macros>:3
7: 0x55a87ab8b529 - syntex_syntax::parse::filemap_to_tts::h64dc05b9ab861c82
at /home/censoredbyfbi/.cargo/registry/src/github.com-1ecc6299db9ec823/syntex_syntax-0.32.0/src/parse/mod.rs:254
8: 0x55a87ab8a707 - syntex_syntax::parse::filemap_to_parser::h8960db47fe0329aa
at /home/censoredbyfbi/.cargo/registry/src/github.com-1ecc6299db9ec823/syntex_syntax-0.32.0/src/parse/mod.rs:212
9: 0x55a87ab868f9 - syntex_syntax::parse::new_parser_from_file::h9f65919cff698456
at /home/censoredbyfbi/.cargo/registry/src/github.com-1ecc6299db9ec823/syntex_syntax-0.32.0/src/parse/mod.rs:189
10: 0x55a87ab8678c - syntex_syntax::parse::parse_crate_from_file::hdfa93fc2ba898f92
at /home/censoredbyfbi/.cargo/registry/src/github.com-1ecc6299db9ec823/syntex_syntax-0.32.0/src/parse/mod.rs:77
11: 0x55a87a80f85a - rustfmt::parse_input::h35adeee7f5f2dbec
at src/lib.rs:389
12: 0x55a87a81d373 - rustfmt::format_input::h5152d86c8e0e887d
at src/lib.rs:424
13: 0x55a87a81a520 - rustfmt::run::hc3c3f45cca8c2090
at src/lib.rs:480
14: 0x55a87a7eabdd - rustfmt::execute::h1567d35cf029b277
at src/bin/rustfmt.rs:231
15: 0x55a87a7fa17f - rustfmt::main::h72bee7f7a14fa8c0
at src/bin/rustfmt.rs:243
16: 0x55a87ad96f18 - std::panicking::try::call::h707222b2d912b2ed
17: 0x55a87ada190b - __rust_try
18: 0x55a87ada18ae - __rust_maybe_catch_panic
19: 0x55a87ad96943 - std::rt::lang_start::h801b666f82634252
20: 0x55a87a7fd169 - main
21: 0x7f9ee390570f - __libc_start_main
22: 0x55a87a7e3aa8 - _start
23: 0x0 - <unknown> |
|
I'm not sure whether this is the right repo, but: When running rust-fmt on a special line of code, I get a panic from syntex_syntax.
Code:
Error message + backtrace:
Versions:
The text was updated successfully, but these errors were encountered: