Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Macro utilizing patterns results in an ICE #33728

Closed
Mark-Simulacrum opened this issue May 18, 2016 · 4 comments · Fixed by #33870
Closed

Macro utilizing patterns results in an ICE #33728

Mark-Simulacrum opened this issue May 18, 2016 · 4 comments · Fixed by #33870
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@Mark-Simulacrum
Copy link
Member

From this simplified version of the macro which originally caused the problem:

macro_rules! _test {
    ($pat: pat) => (
        fn test() {
            let $(pat)(ref vec) = *self;
        }
    )
}
_test!(None);

Backtrace:

     Running `rustc src/main.rs --crate-name fortress_finder --crate-type bin -C opt-level=3 --out-dir /Users/mark/projects/fortress-finder/target/release --emit=dep-info,link -L dependency=/Users/mark/projects/fortress-finder/target/release -L dependency=/Users/mark/projects/fortress-finder/target/release/deps --extern byteorder=/Users/mark/projects/fortress-finder/target/release/deps/libbyteorder-c882ee50a4e0aa4f.rlib`
src/main.rs:54:28: 54:31 error: expected `*` or `+`
src/main.rs:54                 let $(pat)(ref vec) = *self;
                                          ^~~
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', ../src/libsyntax/parse/parser.rs:2848
stack backtrace:
   1:        0x104d8b5d8 - std::sys::backtrace::tracing::imp::write::h9fb600083204ae7f
   2:        0x104d97b65 - std::panicking::default_hook::_$u7b$$u7b$closure$u7d$$u7d$::hca543c34f11229ac
   3:        0x104d9769f - std::panicking::default_hook::hc2c969e7453d080c
   4:        0x104d5d120 - std::panicking::rust_panic_with_hook::hfe203e3083c2b544
   5:        0x102055f24 - std::panicking::begin_panic::h4ebf9fe884b2415f
   6:        0x1021565d9 - syntax::parse::parser::Parser::parse_token_tree::hd7887691a0224788
   7:        0x10215590d - syntax::parse::parser::Parser::parse_token_tree::hd7887691a0224788
   8:        0x10215590d - syntax::parse::parser::Parser::parse_token_tree::hd7887691a0224788
   9:        0x10236c861 - syntax::ext::tt::macro_parser::parse_nt::h9776ef73ddf4d14c
  10:        0x1020be6f4 - syntax::ext::tt::macro_parser::parse::hf8420386b1b7feca
  11:        0x102296a00 - syntax::ext::tt::macro_rules::compile::h21c8262e7bf89324
  12:        0x102295fd0 - syntax::ext::base::ExtCtxt::insert_macro::h393439bf035c459e
  13:        0x1022ee2a7 - syntax::ext::expand::expand_item_mac::hb51c73877df56a79
  14:        0x1022db467 - syntax::ext::expand::expand_annotatable::hc0f78f406615b5e1
  15:        0x1022d8b5c - syntax::ext::expand::expand_item::hb99af7e0c910686e
  16:        0x1022e6831 - _<ext..expand..MacroExpander<'a, 'b> as fold..Folder>::fold_item::h8c27a95378ad2c28
  17:        0x1022e64e0 - syntax::fold::noop_fold_mod::hc2718611fc479597
  18:        0x1022e0014 - syntax::ext::expand::expand_item_kind::h0b21c6d930b6a1e4
  19:        0x10231f76d - syntax::fold::Folder::fold_item_simple::ha749d2ae63b235ad
  20:        0x10231f356 - _<ptr..P<T>>::map::he640c72a9f20f0a4
  21:        0x1022dcbf3 - syntax::ext::expand::expand_annotatable::hc0f78f406615b5e1
  22:        0x1022d8b5c - syntax::ext::expand::expand_item::hb99af7e0c910686e
  23:        0x1022e6a77 - _<ext..expand..MacroExpander<'a, 'b> as fold..Folder>::fold_item::h8c27a95378ad2c28
  24:        0x10232c951 - _<ext..expand..MacroExpander<'a, 'b> as fold..Folder>::fold_crate::h072fa0f078d6fae0
  25:        0x10232dd96 - syntax::ext::expand::expand_crate::h7e9f12d49472476d
  26:        0x10026af94 - rustc_driver::driver::phase_2_configure_and_expand::_$u7b$$u7b$closure$u7d$$u7d$::hcc02923f666dd3df
  27:        0x1002196b3 - rustc_driver::driver::phase_2_configure_and_expand::h70a47be7bf475f39
  28:        0x1001eac97 - rustc_driver::driver::compile_input::h0629572e6f316b31
  29:        0x1001e0941 - rustc_driver::run_compiler::h8902aebf8b1849a8
  30:        0x1001dd94f - std::panicking::try::call::hb9e578062982aefa
  31:        0x104d9efbb - __rust_try
  32:        0x104d9ef55 - __rust_maybe_catch_panic
  33:        0x1001de46b - _<F as std..boxed..FnBox<A>>::call_box::h27f542a39f1d61ef
  34:        0x104d969d8 - std::sys::thread::Thread::new::thread_start::h6f266e069bf4ec2b
  35:     0x7fff8baf799c - _pthread_body
  36:     0x7fff8baf7919 - _pthread_start

error: Could not compile `fortress-finder`.

Caused by:
  Process didn't exit successfully: `rustc src/main.rs --crate-name fortress_finder --crate-type bin -C opt-level=3 --out-dir /Users/mark/projects/fortress-finder/target/release --emit=dep-info,link -L dependency=/Users/mark/projects/fortress-finder/target/release -L dependency=/Users/mark/projects/fortress-finder/target/release/deps --extern byteorder=/Users/mark/projects/fortress-finder/target/release/deps/libbyteorder-c882ee50a4e0aa4f.rlib` (exit code: 101)

rustc version:

rustc 1.10.0-nightly (0667ae93f 2016-05-17)
binary: rustc
commit-hash: 0667ae93fb72eb25594258e55de9b4ae8f9f02a8
commit-date: 2016-05-17
host: x86_64-apple-darwin
release: 1.10.0-nightly

Please let me know if there is anything else that's needed.

@durka
Copy link
Contributor

durka commented May 18, 2016

This looks like it may be fixed by #33726 as it's the same unreachable!(). cc @c4rlo want to test this example on your branch?

@apasel422 apasel422 added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label May 19, 2016
@c4rlo
Copy link
Contributor

c4rlo commented May 19, 2016

Yes, it's fixed on my branch. Same issue.

@durka
Copy link
Contributor

durka commented May 20, 2016

Great. Btw, if you add "Fixes #33569. Fixes #33728." to the PR description then both issues will get closed automatically when the PR is merged.

@c4rlo
Copy link
Contributor

c4rlo commented May 20, 2016

Right, of course. Updated PR description.

This was referenced May 25, 2016
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue May 27, 2016
Fix ICE on parsing a bad metavariable in a macro definition

Fixes rust-lang#33569, fixes rust-lang#33728.
r? @pnkfelix
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
4 participants