Closed
Description
I made a typo in a peg rule using the peg
crate, and the compile failed with a rustc panic.
Not sure if this is a duplicate of #70787 ; if so, please feel free to close in favour of that issue.
Code
I used peg
version 0.6.2
with the following lib.rs
:
use peg;
peg::parser!{
grammar test_parser() for str {
rule num() -> u32
= n:$(['0..='9']) { n.parse().unwrap() }
}
}
I expected to get an error that '0
wasn't terminated, but instead I got the panic shown below.
Meta
>rustc --version --verbose
rustc 1.43.1 (8d69840ab 2020-05-04)
binary: rustc
commit-hash: 8d69840ab92ea7f4d323420088dd8c9775f180cd
commit-date: 2020-05-04
host: x86_64-pc-windows-msvc
release: 1.43.1
LLVM version: 9.0
Backtrace:
>cargo build --lib
Compiling test v0.1.0 (C:\Keith\code\purlcraft)
error: lifetimes cannot start with a number
--> src\lib.rs:5:20
|
5 | = n:$(['0..='9']) { n.parse().unwrap() }
| ^^
thread 'rustc' panicked at '`"0"` is not a valid identifier', src\librustc_expand\proc_macro_server.rs:329:13
stack backtrace:
0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
1: core::fmt::write
2: <std::io::IoSlice as core::fmt::Debug>::fmt
3: std::panicking::take_hook
4: std::panicking::take_hook
5: rustc_driver::report_ice
6: std::panicking::rust_panic_with_hook
7: rust_begin_unwind
8: std::panicking::begin_panic_fmt
9: rustc_expand::expand::AstFragment::make_variants
10: ZN648_$LT$proc_macro..bridge..TokenTree$LT$rustc_expand..proc_macro_server..Group$C$rustc_expand..proc_macro_server..Punct$C$rustc_expand..proc_macro_server..Ident$C$rustc_expand..proc_macro_server..Literal$GT$$u20$as$u20$rustc_expand..proc_macro_server..
11: <rustc_expand::proc_macro_server::Rustc as proc_macro::bridge::server::TokenStreamIter>::next
12: <rustc_expand::mbe::transcribe::Frame as core::iter::traits::iterator::Iterator>::next
13: <rustc_expand::mbe::macro_rules::TokenSet as core::fmt::Debug>::fmt
14: _rust_maybe_catch_panic
15: rustc_expand::base::MacEager::ty
16: rustc_expand::base::MacEager::ty
17: proc_macro::bridge::scoped_cell::ScopedCell<proc_macro::bridge::client::BridgeStateL>::replace
at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd\/src\libproc_macro\bridge\scoped_cell.rs:74
18: proc_macro::bridge::client::{{impl}}::with::{{closure}}
at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd\/src\libproc_macro\bridge\client.rs:284
19: std::thread::local::LocalKey<proc_macro::bridge::scoped_cell::ScopedCell<proc_macro::bridge::client::BridgeStateL>>::try_with
at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd\src\libstd\thread\local.rs:262
20: std::thread::local::LocalKey<proc_macro::bridge::scoped_cell::ScopedCell<proc_macro::bridge::client::BridgeStateL>>::with
at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd\src\libstd\thread\local.rs:239
21: proc_macro::bridge::client::BridgeState::with
at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd\/src\libproc_macro\bridge\client.rs:283
22: proc_macro::bridge::Bridge::with
at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd\/src\libproc_macro\bridge\client.rs:314
23: proc_macro::bridge::client::TokenStreamIter::next
at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd\/src\libproc_macro\bridge\client.rs:230
24: proc_macro::token_stream::{{impl}}::next
at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd\/src\libproc_macro\lib.rs:199
25: proc_macro2::imp::{{impl}}::next
at C:\Users\ksw\.cargo\registry\src\github.com-1ecc6299db9ec823\proc-macro2-1.0.12\src\wrapper.rs:286
26: proc_macro2::token_stream::{{impl}}::next
at C:\Users\ksw\.cargo\registry\src\github.com-1ecc6299db9ec823\proc-macro2-1.0.12\src\lib.rs:1185
27: peg_macros::tokens::{{impl}}::new::flatten
at C:\Users\ksw\.cargo\registry\src\github.com-1ecc6299db9ec823\peg-macros-0.6.2\tokens.rs:31
28: peg_macros::tokens::{{impl}}::new::flatten
at C:\Users\ksw\.cargo\registry\src\github.com-1ecc6299db9ec823\peg-macros-0.6.2\tokens.rs:32
29: peg_macros::tokens::{{impl}}::new::flatten
at C:\Users\ksw\.cargo\registry\src\github.com-1ecc6299db9ec823\peg-macros-0.6.2\tokens.rs:32
30: peg_macros::tokens::FlatTokenStream::new
at C:\Users\ksw\.cargo\registry\src\github.com-1ecc6299db9ec823\peg-macros-0.6.2\tokens.rs:43
31: peg_macros::parser
at C:\Users\ksw\.cargo\registry\src\github.com-1ecc6299db9ec823\peg-macros-0.6.2\lib.rs:22
32: core::ops::function::FnOnce::call_once<fn(proc_macro::TokenStream) -> proc_macro::TokenStream,(proc_macro::TokenStream)>
at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd\src\libcore\ops\function.rs:232
33: proc_macro::bridge::client::{{impl}}::expand1::run::{{closure}}<fn(proc_macro::TokenStream) -> proc_macro::TokenStream>
at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd\src\libproc_macro\bridge\client.rs:394
34: proc_macro::bridge::client::run_client::{{closure}}::{{closure}}<proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::TokenStream,closure-0>
at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd\src\libproc_macro\bridge\client.rs:362
35: proc_macro::bridge::scoped_cell::{{impl}}::set::{{closure}}<proc_macro::bridge::client::BridgeStateL,(),closure-0> at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd\src\libproc_macro\bridge\scoped_cell.rs:79
36: proc_macro::bridge::scoped_cell::ScopedCell<proc_macro::bridge::client::BridgeStateL>::replace<proc_macro::bridge::client::BridgeStateL,(),closure-0>
at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd\src\libproc_macro\bridge\scoped_cell.rs:74
37: proc_macro::bridge::scoped_cell::ScopedCell<proc_macro::bridge::client::BridgeStateL>::set<proc_macro::bridge::client::BridgeStateL,(),closure-0>
at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd\src\libproc_macro\bridge\scoped_cell.rs:79
38: proc_macro::bridge::client::{{impl}}::enter::{{closure}}<(),closure-0>
at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd\src\libproc_macro\bridge\client.rs:310
39: std::thread::local::LocalKey<proc_macro::bridge::scoped_cell::ScopedCell<proc_macro::bridge::client::BridgeStateL>>::try_with<proc_macro::bridge::scoped_cell::ScopedCell<proc_macro::bridge::client::BridgeStateL>,closure-1,()>
at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd\src\libstd\thread\local.rs:262
40: std::thread::local::LocalKey<proc_macro::bridge::scoped_cell::ScopedCell<proc_macro::bridge::client::BridgeStateL>>::with<proc_macro::bridge::scoped_cell::ScopedCell<proc_macro::bridge::client::BridgeStateL>,closure-1,()>
at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd\src\libstd\thread\local.rs:239
41: proc_macro::bridge::Bridge::enter<(),closure-0>
at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd\src\libproc_macro\bridge\client.rs:310
42: proc_macro::bridge::client::run_client::{{closure}}<proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::TokenStream,closure-0>
at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd\src\libproc_macro\bridge\client.rs:355
43: std::panic::{{impl}}::call_once<(),closure-0>
at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd\src\libstd\panic.rs:318
44: std::panicking::try::do_call<std::panic::AssertUnwindSafe<closure-0>,()>
at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd\src\libstd\panicking.rs:303
45: panic_unwind::__rust_maybe_catch_panic
at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd\/src\libpanic_unwind\lib.rs:86
46: std::panicking::try<(),std::panic::AssertUnwindSafe<closure-0>>
at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd\src\libstd\panicking.rs:281
47: std::panic::catch_unwind<std::panic::AssertUnwindSafe<closure-0>,()>
at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd\src\libstd\panic.rs:394
48: proc_macro::bridge::client::run_client<proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::TokenStream,closure-0>
at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd\src\libproc_macro\bridge\client.rs:354
49: proc_macro::bridge::client::{{impl}}::expand1::run<fn(proc_macro::TokenStream) -> proc_macro::TokenStream>
at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd\src\libproc_macro\bridge\client.rs:394
50: rustc_expand::base::MacEager::ty
51: <rustc_expand::proc_macro::BangProcMacro as rustc_expand::base::ProcMacro>::expand
52: rustc_expand::expand::MacroExpander::fully_expand_fragment
53: rustc_expand::expand::MacroExpander::expand_crate
54: rustc_interface::queries::Linker::link
55: rustc_interface::passes::BoxedResolver::to_resolver_outputs
56: <rustc_interface::util::ReplaceBodyWithLoop as rustc_ast::mut_visit::MutVisitor>::visit_mac
57: <rustc_interface::util::ReplaceBodyWithLoop as rustc_ast::mut_visit::MutVisitor>::visit_mac
58: rustc_interface::interface::parse_cfgspecs
59: rustc_interface::queries::Queries::expansion
60: <rustc_ast::ast::Item as rustc_ast::attr::HasAttrs>::attrs
61: <rustc_driver::DEFAULT_HOOK as core::ops::deref::Deref>::deref
62: _rust_maybe_catch_panic
63: <rustc_ast::ast::Item as rustc_ast::attr::HasAttrs>::attrs
64: ZN244_$LT$std..error..$LT$impl$u20$core..convert..From$LT$alloc..string..String$GT$$u20$for$u20$alloc..boxed..Box$LT$dyn$u20$std..error..Error$u2b$core..marker..Sync$u2b$core..marker..Send$GT$$GT$..from..StringError$u20$as$u20$core..fmt..Display$GT$3fmt17
65: std::sys::windows::thread::Thread::new
66: BaseThreadInitThunk
67: RtlUserThreadStart
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: rustc 1.43.1 (8d69840ab 2020-05-04) running on x86_64-pc-windows-msvc
note: compiler flags: -C debuginfo=2 -C incremental --crate-type lib
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
end of query stack
error: proc macro panicked
--> src\lib.rs:2:1
|
2 | / peg::parser!{
3 | | grammar test_parser() for str {
4 | | rule num() -> u32
5 | | = n:$(['0..='9']) { n.parse().unwrap() }
6 | | }
7 | | }
| |_^
|
= help: message: `"0"` is not a valid identifier
error: aborting due to 2 previous errors
error: could not compile `test`.
To learn more, run the command again with --verbose.
Metadata
Metadata
Assignees
Labels
No labels