Skip to content

Panic with macro_rules #23701

Closed
Closed
@agbaroni

Description

@agbaroni

The following snippet:

macro_rules! getarg {
    (x => $e:expr) => (println! ("x = {}", $e));
    $b:block => $b;
}

fn main() {
    getarg! (x => 1 + 2);
    getarg! {
    }
}

gives the following error:

src/main.rs:3:1: 4:2 error: internal compiler error: wrong-structured lhs for follow check (didn't find a TtDelimited or TtSequence)

This is the backtrace:

stack backtrace:
   1:        0x104fe5da3 - sys::backtrace::write::h36da3fb1e07e78da0nC
   2:        0x105013da5 - panicking::on_panic::haade6d6d86433bf5HOL
   3:        0x104f3d5d8 - rt::unwind::begin_unwind_inner::h00317caea0131299UvL
   4:        0x1045efb5f - rt::unwind::begin_unwind::h15168281961459128075
   5:        0x1045efb0c - diagnostic::SpanHandler::span_bug::hbfe227f81d0cd8devYE
   6:        0x104741719 - ext::base::ExtCtxt<'a>::span_bug::hdb7ec5648176a7f89y7
   7:        0x104740ed5 - ext::tt::macro_rules::compile::ha9fc6d551176d0ddx5i
   8:        0x104740265 - ext::base::ExtCtxt<'a>::insert_macro::h91b42296cf30a29dSw7
   9:        0x1047b49f0 - ext::expand::expand_item_mac::hb9eabd9a17097c78v5d
  10:        0x1047a0227 - ext::expand::expand_annotatable::hb2c7b6cf1688383b0ze
  11:        0x10479c230 - ext::expand::expand_item::h82a19f3ce454f84daZd
  12:        0x1047ab7a2 - ext::expand::MacroExpander<'a, 'b>.Folder::fold_item::h7f85720548281771dSe
  13:        0x1047ab578 - fold::noop_fold_mod::closure.58932
  14:        0x1047ab316 - iter::FlatMap<I, U, F>.Iterator::next::h10055531995118448306
  15:        0x1047aaf60 - vec::Vec<T>.FromIterator<T>::from_iter::h8228182012818297599
  16:        0x1047aab9f - fold::noop_fold_mod::h3115526397988167409
  17:        0x1047a6a7c - ext::expand::expand_item_underscore::h52c4b03ceb86d01b02d
  18:        0x10480f552 - fold::Folder::fold_item_simple::h4379758381320372925
  19:        0x10480ecd3 - ptr::P<T>::map::h1390305908052494351
  20:        0x1047a1b95 - ext::expand::expand_annotatable::hb2c7b6cf1688383b0ze
  21:        0x10479c230 - ext::expand::expand_item::h82a19f3ce454f84daZd
  22:        0x1047ab7a2 - ext::expand::MacroExpander<'a, 'b>.Folder::fold_item::h7f85720548281771dSe
  23:        0x10481be94 - ext::expand::expand_crate::h8ce8d9aec4e20430IYe
  24:        0x1016c70d4 - driver::phase_2_configure_and_expand::closure.20378
  25:        0x10167a90b - driver::phase_2_configure_and_expand::h7df30fbfe33501e73ta
  26:        0x10166a436 - driver::compile_input::h1408964d65bdd4c4Gba
  27:        0x101743bf7 - run_compiler::hc234a0e393bd73edZbc
  28:        0x101741071 - thunk::F.Invoke<A, R>::invoke::h15756873051927943851
  29:        0x10173fcd0 - rt::unwind::try::try_fn::h4998921728403241693
  30:        0x10508ae09 - rust_try_inner
  31:        0x10508adf6 - rust_try
  32:        0x101740435 - thunk::F.Invoke<A, R>::invoke::h14944404643238507248
  33:        0x104ffcc83 - sys::thread::thread_start::h384864084e567330e4G
  34:     0x7fff8e031268 - _pthread_body
  35:     0x7fff8e0311e5 - _pthread_body

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