Skip to content

Compiler crash on macro_rules #27092

Closed
Closed
@Nashenas88

Description

@Nashenas88

This macro code and invocation:

macro_rules! test_cases {
    (
        $(#[$case_name:ident($($test_case:expr),+)])+
        $test_name:ident ($($param_name:ident),+)
        $(use $paths::path;)*
        $test_code:block
    ) => ();
}

test_cases!(
    #[a(1)]
    t (c) { }
);

causes the following backtrace:

   Compiling compiler_bug v0.1.0 (file:///Users/paul/programming/crypto-challenges/rust/compiler_bug)
     Running `rustc src/lib.rs --crate-name compiler_bug --crate-type lib -g --out-dir /Users/paul/programming/crypto-challenges/rust/compiler_bug/target/debug --emit=dep-info,link -L dependency=/Users/paul/programming/crypto-challenges/rust/compiler_bug/target/debug -L dependency=/Users/paul/programming/crypto-challenges/rust/compiler_bug/target/debug/deps`
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
thread 'rustc' panicked at 'Cannot fill in a NT', ../src/libsyntax/ext/tt/macro_parser.rs:234

stack backtrace:
   1:        0x110dd3e65 - sys::backtrace::write::h70b2041760008869Yos
   2:        0x110ddcd03 - panicking::on_panic::h9b475f8994506859ZMw
   3:        0x110d97f12 - rt::unwind::begin_unwind_inner::he74af745bdaff759bvw
   4:        0x10e604c46 - rt::unwind::begin_unwind::h16174450654587449181
   5:        0x10e9333ff - ext::tt::macro_parser::nameize::n_rec::hcfdb28cfef92d20fHQf
   6:        0x10e931f27 - ext::tt::macro_parser::nameize::n_rec::hcfdb28cfef92d20fHQf
   7:        0x10e931db5 - ext::tt::macro_parser::nameize::h2b9ebd3a6f0d2a4fkQf
   8:        0x10e644df0 - ext::tt::macro_parser::parse::h6807f00f2a206301PXf
   9:        0x10e63fa4e - ast::TokenTree::parse::hfbf0d38135f4a437d8l
  10:        0x10e9366ad - ext::tt::macro_rules::MacroRulesMacroExpander.TTMacroExpander::expand::h4a0b3360049a63d69sg
  11:        0x10e884946 - ext::expand::expand_item_mac::h52e95ad5cea7e1157Cb
  12:        0x10e8723c7 - ext::expand::expand_annotatable::ha14bcb538e37526fy7b
  13:        0x10e86e701 - ext::expand::expand_item::h46f498d0025bee765zb
  14:        0x10e87b59a - iter::FlatMap<I, U, F>.Iterator::next::h2806753839147340092
  15:        0x10e87a557 - vec::Vec<T>.FromIterator<T>::from_iter::h7746685027599766033
  16:        0x10e879c6f - fold::noop_fold_mod::h8262654569662317362
  17:        0x10e875c5d - ext::expand::expand_item_underscore::h44e87dc09c0e560bGAb
  18:        0x10e8d8944 - fold::Folder::fold_item_simple::h13893162469570453607
  19:        0x10e8d8513 - ptr::P<T>::map::h18263047643979897990
  20:        0x10e87343d - ext::expand::expand_annotatable::ha14bcb538e37526fy7b
  21:        0x10e86e701 - ext::expand::expand_item::h46f498d0025bee765zb
  22:        0x10e8e1baf - ext::expand::expand_crate::hc3936c513fa4cc436yc
  23:        0x10d30c3e2 - driver::phase_2_configure_and_expand::closure.21536
  24:        0x10d2bc902 - driver::phase_2_configure_and_expand::h61a8e892965c822bita
  25:        0x10d2ab2bd - driver::compile_input::he37316fd3b638038Tba
  26:        0x10d391d7f - run_compiler::hfb0cce3b8e447a58A7b
  27:        0x10d38f633 - boxed::F.FnBox<A>::call_box::h6934248972739997927
  28:        0x10d38edf7 - rt::unwind::try::try_fn::h1907535934500506241
  29:        0x110e6a528 - rust_try_inner
  30:        0x110e6a515 - rust_try
  31:        0x110dc63d5 - rt::unwind::try::inner_try::hb0b2c8334dfc8a584qw
  32:        0x10d38f028 - boxed::F.FnBox<A>::call_box::h7914022192141927844
  33:        0x110ddb78d - sys::thread::Thread::new::thread_start::hf92f61e537ba20b2ePv
  34:     0x7fff95266267 - _pthread_body
  35:     0x7fff952661e4 - _pthread_start

Could not compile `compiler_bug`.

Caused by:
  Process didn't exit successfully: `rustc src/lib.rs --crate-name compiler_bug --crate-type lib -g --out-dir /Users/paul/programming/crypto-challenges/rust/compiler_bug/target/debug --emit=dep-info,link -L dependency=/Users/paul/programming/crypto-challenges/rust/compiler_bug/target/debug -L dependency=/Users/paul/programming/crypto-challenges/rust/compiler_bug/target/debug/deps` (exit code: 101)

Edit: Initially I thought this was malformed because of the use $paths line being a sequence just after the enclosed $param_name, but I see that the parentheses around the $param_name section is enclosed, so there aren't two sequences immediately next to each other.

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions