Skip to content

unexpected panic with path+idents in Macro #41719

Closed
@insipx

Description

@insipx

I tried this code:
lib.rs

#![feature(associated_consts)]
#![feature(concat_idents)]
#![feature(use_extern_macros)]

#[macro_use]
mod macros;
// m.foo = regs[GlobalRegisters::r_kon] 
macro_rules! reg {
    ($n:path) => {
        {
            m.regs[GlobalRegisters::concat_idents!(r_, $n)]
        }
    }

I expected to see this happen: Able to use ident with path

Instead, this happened:
thread rustc panicked at 'Expected Def::Macro(..)', /checkout/src/librustc_resolve/build_reduced_graph.rs:513

Meta

rustc --version --verbose:

rustc 1.19.0-nightly (777ee2079 2017-05-01)
binary: rustc
commit-hash: 777ee20796e80a31d4b7c985dd68eda2941460d6
commit-date: 2017-05-01
host: x86_64-unknown-linux-gnu
release: 1.19.0-nightly
LLVM version: 4.0

Backtrace:

   Compiling SPC_DSP v0.1.0 (file:///home/insi/Projects/smpd/SPC_DSP)
     Running `rustc --crate-name SPC_DSP src/lib.rs --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=32ecbd31718c60b7 -C extra-filename=-32ecbd31718c60b7 --out-dir /home/insi/Projects/smpd/SPC_DSP/target/debug/deps -L dependency=/home/insi/Projects/smpd/SPC_DSP/target/debug/deps`
error: expected type, found `'a`
  --> src/state.rs:46:26
   |
46 |     pub fn create() -> &<'a> mut State<'a> {
   |                          ^^

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: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'Expected Def::Macro(..)', /checkout/src/librustc_resolve/build_reduced_graph.rs:513
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:355
   3: std::panicking::default_hook
             at /checkout/src/libstd/panicking.rs:365
   4: std::panicking::rust_panic_with_hook
             at /checkout/src/libstd/panicking.rs:549
   5: std::panicking::begin_panic
   6: rustc_resolve::build_reduced_graph::<impl rustc_resolve::Resolver<'a>>::get_macro
   7: rustc_resolve::macros::<impl syntax::ext::base::Resolver for rustc_resolve::Resolver<'a>>::resolve_invoc
   8: syntax::ext::expand::MacroExpander::expand
   9: syntax::ext::expand::MacroExpander::expand_crate
  10: rustc_driver::driver::phase_2_configure_and_expand::{{closure}}
  11: rustc_driver::driver::phase_2_configure_and_expand
  12: rustc_driver::driver::compile_input
  13: rustc_driver::run_compiler
  14: std::panicking::try::do_call
  15: __rust_maybe_catch_panic
             at /checkout/src/libpanic_unwind/lib.rs:98
  16: <F as alloc::boxed::FnBox<A>>::call_box
  17: std::sys::imp::thread::Thread::new::thread_start
             at /checkout/src/liballoc/boxed.rs:658
             at /checkout/src/libstd/sys_common/thread.rs:21
             at /checkout/src/libstd/sys/unix/thread.rs:84
  18: start_thread
  19: clone

error: Could not compile `SPC_DSP`.

Caused by:
  process didn't exit successfully: `rustc --crate-name SPC_DSP src/lib.rs --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=32ecbd31718c60b7 -C extra-filename=-32ecbd31718c60b7 --out-dir /home/insi/Projects/smpd/SPC_DSP/target/debug/deps -L dependency=/home/insi/Projects/smpd/SPC_DSP/target/debug/deps` (exit code: 101)

Hope this helps. I tried searching for an issue but did not see one

Metadata

Metadata

Assignees

Labels

A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-bugCategory: This is a bug.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