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

Rustc (nightly) panic!s on macro definition #39388

Closed
BattyBoopers opened this issue Jan 29, 2017 · 1 comment · Fixed by #39674
Closed

Rustc (nightly) panic!s on macro definition #39388

BattyBoopers opened this issue Jan 29, 2017 · 1 comment · Fixed by #39674
Assignees
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@BattyBoopers
Copy link

BattyBoopers commented Jan 29, 2017

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
@BattyBoopers BattyBoopers changed the title Rust (nightly) panic!s on macro definition Rustc (nightly) panic!s on macro definition Jan 29, 2017
@sfackler sfackler added A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Jan 29, 2017
@arielb1 arielb1 added regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 7, 2017
@jseyfried jseyfried self-assigned this Feb 8, 2017
@jseyfried
Copy link
Contributor

jseyfried commented Feb 9, 2017

Fixed in #39674.

frewsxcv added a commit to frewsxcv/rust that referenced this issue Feb 10, 2017
…E, r=nrc

parser: fix ICE when parsing token trees after an error

Fixes rust-lang#39388, fixes rust-lang#39616.
r? @nrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants