Skip to content

ICE with space in macro_rules ! #7023

Closed as duplicate
Closed as duplicate

Description

@robertbastian

The code macro_rules ! x { } causes an ICE, due to the space in macro_rules !. This started failing with on the nightly channel on 2026-08-07 at 14:00 UTC (CI).

thread 'main' (17) panicked at src/tools/rustfmt/src/source_map.rs:31:13:
bad span: `macro_rules!`: `macro_rules ! x { }`
stack backtrace:
   0:     0x7c90ec906146 - <<std[8adf1e0a8fdad74e]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[f9b16b9dc2e8e3d7]::fmt::Display>::fmt
   1:     0x7c90ed01140f - core[f9b16b9dc2e8e3d7]::fmt::write
   2:     0x7c90ec91b06c - <std[8adf1e0a8fdad74e]::sys::stdio::unix::Stderr as core[f9b16b9dc2e8e3d7]::io::write::Write>::write_fmt
   3:     0x7c90ec8d91ba - std[8adf1e0a8fdad74e]::panicking::default_hook::{closure#0}
   4:     0x7c90ec8f9ed3 - std[8adf1e0a8fdad74e]::panicking::default_hook
   5:     0x7c90eb85392a - std[8adf1e0a8fdad74e]::panicking::update_hook::<alloc[9e757d82aeab4d68]::boxed::Box<rustc_driver_impl[64fa20c1c6c1d0c7]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7c90ec8fa372 - std[8adf1e0a8fdad74e]::panicking::panic_with_hook
   7:     0x7c90ec8d9272 - std[8adf1e0a8fdad74e]::panicking::panic_handler::{closure#0}
   8:     0x7c90ec8d0409 - std[8adf1e0a8fdad74e]::sys::backtrace::__rust_end_short_backtrace::<std[8adf1e0a8fdad74e]::panicking::panic_handler::{closure#0}, !>
   9:     0x7c90ec8dac4d - __rustc[921b188eb83a821]::rust_begin_unwind
  10:     0x7c90e94e3b8c - core[f9b16b9dc2e8e3d7]::panicking::panic_fmt
  11:     0x5efe840935be - <rustfmt_nightly[b091d890d2e52c23]::visitor::SnippetProvider as rustfmt_nightly[b091d890d2e52c23]::source_map::SpanUtils>::span_after::{closure#0}
  12:     0x5efe8411ef4b - rustfmt_nightly[b091d890d2e52c23]::macros::rewrite_macro_def
  13:     0x5efe8409cc53 - <rustfmt_nightly[b091d890d2e52c23]::visitor::FmtVisitor>::visit_item
  14:     0x5efe840e5966 - <rustfmt_nightly[b091d890d2e52c23]::visitor::FmtVisitor>::visit_items_with_reordering
  15:     0x5efe840a1a20 - <rustfmt_nightly[b091d890d2e52c23]::visitor::FmtVisitor>::walk_mod_items
  16:     0x5efe8401462a - <scoped_tls[83572d244c562f9b]::ScopedKey<rustc_span[7878bc114b1648f5]::SessionGlobals>>::with::<<rustfmt_nightly[b091d890d2e52c23]::Session<std[8adf1e0a8fdad74e]::io::stdio::Stdout>>::format_input_inner::{closure#0}, core[f9b16b9dc2e8e3d7]::result::Result<rustfmt_nightly[b091d890d2e52c23]::FormatReport, rustfmt_nightly[b091d890d2e52c23]::ErrorKind>>
  17:     0x5efe8400e7af - rustfmt[38dffbda7532d1b1]::format_and_emit_report::<std[8adf1e0a8fdad74e]::io::stdio::Stdout>
  18:     0x5efe84023dce - rustfmt[38dffbda7532d1b1]::execute
  19:     0x5efe8401f16a - rustfmt[38dffbda7532d1b1]::main
  20:     0x5efe8401d41b - std[8adf1e0a8fdad74e]::sys::backtrace::__rust_begin_short_backtrace::<fn(), ()>
  21:     0x5efe8401dc19 - std[8adf1e0a8fdad74e]::rt::lang_start::<()>::{closure#0}
  22:     0x7c90ee2a2d13 - std[8adf1e0a8fdad74e]::rt::lang_start_internal
  23:     0x5efe8402e218 - main
  24:     0x7c90e78181ca - <unknown>
  25:     0x7c90e781828b - __libc_start_main
  26:     0x5efe83f0b6f9 - <unknown>
  27:                0x0 - <unknown>

error: the compiler unexpectedly panicked. This is a bug

note: we would appreciate a bug report: https://github.com/rust-lang/rustfmt/issues/new?labels=bug

note: please make sure that you have updated to the latest nightly

note: please attach the file at `/playground/rustc-ice-2026-08-10T15_15_06-17.txt` to your bug report

note: rustc 1.99.0-nightly (969b803cb 2026-08-09) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack

Activity

  1. added
    needs-triage
    on Aug 10, 2026
  2. removed
    needs-triage
    on Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions