You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was working on a macro in a project of mine, and while I was experimenting the compiler started crashing. I managed to reduce the problem to this minimal example:
macro_rules! foo {($name:ident, $doc:expr) => {// It doesn't matter which attribute is used// For example the bug exists also with the serde attribute
#[doc = $doc]static $name:&'staticstr = "foo";};}macro_rules! bar {() => {"bar"}}foo!(BAZ, bar!());fnmain(){assert_eq!(BAZ,"bar");}
When I try to compile this, I get this output:
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.20.0 (f3d6973f4 2017-08-27) running on x86_64-unknown-linux-gnu
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'no entry found for key', /checkout/src/libcore/option.rs:819:4
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
1: std::sys_common::backtrace::_print
at /checkout/src/libstd/sys_common/backtrace.rs:71
2: std::panicking::default_hook::{{closure}}
at /checkout/src/libstd/sys_common/backtrace.rs:60
at /checkout/src/libstd/panicking.rs:380
3: std::panicking::default_hook
at /checkout/src/libstd/panicking.rs:390
4: std::panicking::rust_panic_with_hook
at /checkout/src/libstd/panicking.rs:611
5: std::panicking::begin_panic_new
at /checkout/src/libstd/panicking.rs:553
6: std::panicking::begin_panic_fmt
at /checkout/src/libstd/panicking.rs:521
7: rust_begin_unwind
at /checkout/src/libstd/panicking.rs:497
8: core::panicking::panic_fmt
at /checkout/src/libcore/panicking.rs:92
9: core::option::expect_failed
at /checkout/src/libcore/option.rs:819
10: rustc_resolve::macros::<impl rustc_resolve::Resolver<'a>>::resolve_macro_to_def
11: rustc_resolve::macros::<impl syntax::ext::base::Resolver for rustc_resolve::Resolver<'a>>::resolve_invoc
12: syntax::ext::expand::MacroExpander::expand
13: syntax::ext::expand::MacroExpander::expand_crate
14: rustc_driver::driver::phase_2_configure_and_expand::{{closure}}
15: rustc_driver::driver::phase_2_configure_and_expand
16: rustc_driver::driver::compile_input
17: rustc_driver::run_compiler
Note: I'm using rust 1.20 on this machine, but I tested the example on the playground and it crashes even on the latest stable.
If I change the macro invocation to foo!(BAZ, "bar"); it compiles successfully, and it fails with every other macro I passes as argument.
The text was updated successfully, but these errors were encountered:
I was working on a macro in a project of mine, and while I was experimenting the compiler started crashing. I managed to reduce the problem to this minimal example:
When I try to compile this, I get this output:
Note: I'm using rust 1.20 on this machine, but I tested the example on the playground and it crashes even on the latest stable.
If I change the macro invocation to
foo!(BAZ, "bar");
it compiles successfully, and it fails with every other macro I passes as argument.The text was updated successfully, but these errors were encountered: