Closed
Description
I tried the following code. Just the macro definition already causes rustc to panic.
macro_rules! assign {
( ($($a:tt)*) = ($($b:tt))*) => { $($a)* = $($b)* }
}
I expected this code to generate a macro that would expand in the following way:
1) assign!( (a) = (1) );
2) a = 1;
edit: No, the macro is obviously wrong. I'd expect the compiler to give an error message for
($($b:tt))*
, since the *
is in the wrong place.
But what I got was:
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: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'internal error: entered unreachable code', /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libsyntax/parse/parser.rs:2738
stack backtrace:
1: 0x7f6487d9b96c - std::sys::imp::backtrace::tracing::imp::write::h9c41d2f69e5caabf
at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:42
2: 0x7f6487da9e6e - std::panicking::default_hook::{{closure}}::hcc803c8663cda123
at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panicking.rs:351
3: 0x7f6487da9a13 - std::panicking::default_hook::hd5bda4e453dfb4be
at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panicking.rs:361
4: 0x7f6487daa30b - std::panicking::rust_panic_with_hook::hffbc74969c7b5d87
at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panicking.rs:555
5: 0x7f64808423bf - std::panicking::begin_panic::h7dfac1ff7a8b8eaf
6: 0x7f64809a7c56 - syntax::parse::parser::Parser::parse_token_tree::h7d5c51d876ec62d2
7: 0x7f64809a7314 - syntax::parse::parser::Parser::parse_token_tree::h7d5c51d876ec62d2
8: 0x7f6480a70360 - syntax::ext::tt::macro_parser::parse::h30d211cdc82bec3d
9: 0x7f6480a747a7 - syntax::ext::tt::macro_rules::compile::h336bfca3e5a4db16
10: 0x7f64852aa4d2 - rustc_resolve::macros::<impl rustc_resolve::Resolver<'a>>::define_macro::hf035a235d7f60246
11: 0x7f64852b392f - <rustc_resolve::build_reduced_graph::BuildReducedGraphVisitor<'a, 'b> as syntax::visit::Visitor<'a>>::visit_item::h220e5c529f36a7a1
12: 0x7f64852a736f - rustc_resolve::macros::<impl syntax::ext::base::Resolver for rustc_resolve::Resolver<'a>>::visit_expansion::hf2f69d86db69f9ff
13: 0x7f6480a47992 - syntax::ext::expand::MacroExpander::collect_invocations::hb7286b5215f6cabe
14: 0x7f6480a455d7 - syntax::ext::expand::MacroExpander::expand::he64090ad698e4ac4
15: 0x7f6480a45095 - syntax::ext::expand::MacroExpander::expand_crate::h9effb4e2a488a85d
16: 0x7f648813b1ec - rustc_driver::driver::phase_2_configure_and_expand::{{closure}}::h3ddcf02b571a1c51
17: 0x7f6488132905 - rustc_driver::driver::phase_2_configure_and_expand::hd0c4535cf8df7dea
18: 0x7f6488128dee - rustc_driver::driver::compile_input::h44853ffed84a12cb
19: 0x7f6488172554 - rustc_driver::run_compiler::hdc4bb0fcf7d0917a
20: 0x7f648807ec2b - std::panicking::try::do_call::h84a15e0d2b943318
21: 0x7f6487db314a - __rust_maybe_catch_panic
at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libpanic_unwind/lib.rs:98
22: 0x7f64880a6e62 - <F as alloc::boxed::FnBox<A>>::call_box::h61c78220cad685ea
23: 0x7f6487da8cc4 - std::sys::imp::thread::Thread::new::thread_start::h76badbf9b0ecaf58
at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/liballoc/boxed.rs:615
at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/sys_common/thread.rs:21
at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/sys/unix/thread.rs:84
24: 0x7f647fb7f063 - start_thread
25: 0x7f6487a5e62c - clone
26: 0x0 - <unknown>
$ rustc --version --verbose
rustc 1.16.0-nightly (df8debf6d 2017-01-25)
binary: rustc
commit-hash: df8debf6d9afc431adbbd8311dcaf2b70eb9762e
commit-date: 2017-01-25
host: x86_64-unknown-linux-gnu
release: 1.16.0-nightly
LLVM version: 3.9