Skip to content

ICE in macro: doc meta with expr on an item, string concat, stringify!(...) #55414

Closed

Description

code

macro_rules! bug {
    () => {
        bug!("bug" + stringify!(found));
    };
    ($test:expr) => {
        #[doc = $test]
        struct Test {} // looks like any item works
    };
}

bug!();

description

Any of the following actions stop the panic:

  • Removing or commenting the doc attribute:
    // #[doc = $test]
  • Replacing macro call with:
    bug!("");
  • Removing concatenation:
    () => {
        bug!(stringify!(anything));
    };
  • Replacing stringify!(...):
    () => {
        bug!("bug" + "test");
    };

stderr

Show output
thread 'main' panicked at 'no entry found for key', libcore/option.rs:1000:5
stack backtrace:
   0:     0x7f381365575e - std::sys::unix::backtrace::tracing::imp::unwind_backtrace::hf5316c67202e23c8
                               at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1:     0x7f381362e946 - std::sys_common::backtrace::print::h3068ed2a6dc7ac86
                               at libstd/sys_common/backtrace.rs:71
                               at libstd/sys_common/backtrace.rs:59
   2:     0x7f381362c54d - std::panicking::default_hook::{{closure}}::h1b9d29cc09d41897
                               at libstd/panicking.rs:211
   3:     0x7f381362c2c0 - std::panicking::default_hook::h3a27b204a313406b
                               at libstd/panicking.rs:227
   4:     0x7f380fe769f1 - rustc::util::common::panic_hook::hf9d72254884e6e21
   5:     0x7f381362cc53 - std::panicking::rust_panic_with_hook::h0e12cb2fc86d00fa
                               at libstd/panicking.rs:481
   6:     0x7f381362c7b9 - std::panicking::continue_panic_fmt::h141671b29fe0e27d
                               at libstd/panicking.rs:391
   7:     0x7f381362c6b5 - rust_begin_unwind
                               at libstd/panicking.rs:326
   8:     0x7f38136a55db - core::panicking::panic_fmt::h429a06507aba9228
                               at libcore/panicking.rs:77
   9:     0x7f38136a5671 - core::option::expect_failed::h4c79c3aae6612643
                               at libcore/option.rs:1000
  10:     0x7f38128de274 - rustc_resolve::macros::<impl syntax::ext::base::Resolver for rustc_resolve::Resolver<'a, 'crateloader>>::resolve_macro_invocation::hcacc2b568dda6de5
  11:     0x7f380eecdf28 - syntax::ext::expand::MacroExpander::expand_fragment::h26fd612375b32814
  12:     0x7f380eecd6b1 - syntax::ext::expand::MacroExpander::expand_crate::h3497aacb05bd8e53
  13:     0x7f38139c0303 - rustc_driver::driver::phase_2_configure_and_expand_inner::{{closure}}::h3d4d02fec2b68db2
  14:     0x7f38139bedda - rustc::util::common::time::ha1804c2290179406
  15:     0x7f38139d7b54 - rustc_driver::driver::phase_2_configure_and_expand::h2c60f5950dd2995f
  16:     0x7f38139d356b - rustc_driver::driver::compile_input::h6a302c45b9b8d410
  17:     0x7f3813a7b20c - rustc_driver::run_compiler_with_pool::h2a396394cdff52b0
  18:     0x7f38139d2f34 - rustc_driver::driver::spawn_thread_pool::h5dec0f6efcb9456b
  19:     0x7f3813a7a221 - rustc_driver::run_compiler::he4a6ce0f80da709f
  20:     0x7f38139c169c - <scoped_tls::ScopedKey<T>>::set::h0d2c211708f72196
  21:     0x7f38139fd651 - syntax::with_globals::hcc4912b6b554b6a2
  22:     0x7f381366c469 - __rust_maybe_catch_panic
                               at libpanic_unwind/lib.rs:103
  23:     0x7f3813a7847c - rustc_driver::run::h9e76da7d522d5bdd
  24:     0x7f3813a864ba - rustc_driver::main::h979d81f5800d15a6
  25:     0x55b562390992 - std::rt::lang_start::{{closure}}::h5cee4df267a41ddd
  26:     0x7f381362c652 - std::panicking::try::do_call::h572dc6f90deb1a4d
                               at libstd/rt.rs:59
                               at libstd/panicking.rs:310
  27:     0x7f381366c469 - __rust_maybe_catch_panic
                               at libpanic_unwind/lib.rs:103
  28:     0x7f3813642b45 - std::rt::lang_start_internal::hce01021c3c1cf20d
                               at libstd/panicking.rs:289
                               at libstd/panic.rs:392
                               at libstd/rt.rs:58
  29:     0x55b562390983 - main
  30:     0x7f3813400222 - __libc_start_main
  31:     0x55b562390838 - <unknown>
query stack during panic:
end of query stack

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: rustc 1.30.0 (da5f414c2 2018-10-24) running on x86_64-unknown-linux-gnu

rustc

$ rustc --version --verbose
rustc 1.30.0 (da5f414c2 2018-10-24)
binary: rustc
commit-hash: da5f414c2c0bfe5198934493f04c676e2b23ff2e
commit-date: 2018-10-24
host: x86_64-unknown-linux-gnu
release: 1.30.0
LLVM version: 8.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-resolveArea: Name resolutionC-bugCategory: This is a bug.E-help-wantedCall for participation: Help is requested to fix this issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions