Skip to content

resolve_macro_to_def panics #43860

Closed
@debris

Description

@debris

rustc 1.19.0 (0ade33941 2017-07-17)

I have 3 crates

crate a:

#[proc_macro_derive(EthabiContract, attributes(ethabi_contract_options))]
pub fn ethabi_derive(input: TokenStream) -> TokenStream {
// do something
}

crate b:

#[macro_export]
macro_rules! use_contract {
	($name: ident, $path: expr) => {
		#[derive(EthabiContract)]
		#[ethabi_contract_options(path = $path)]
		pub struct $name<T, C> {
			api: T,
			contract: C,
		}
	}
}

crate c:

use_contract!(ContractName, file!());

building crate c results in compiler panic

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 'no entry found for key', src/libcore/option.rs:823
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
   1: std::panicking::default_hook::{{closure}}
   2: std::panicking::default_hook
   3: std::panicking::rust_panic_with_hook
   4: std::panicking::begin_panic
   5: std::panicking::begin_panic_fmt
   6: rust_begin_unwind
   7: core::panicking::panic_fmt
   8: core::option::expect_failed
   9: rustc_resolve::macros::<impl rustc_resolve::Resolver<'a>>::resolve_macro_to_def
  10: rustc_resolve::macros::<impl syntax::ext::base::Resolver for rustc_resolve::Resolver<'a>>::resolve_invoc
  11: syntax::ext::expand::MacroExpander::expand
  12: syntax::ext::expand::MacroExpander::expand_crate
  13: rustc_driver::driver::phase_2_configure_and_expand::{{closure}}
  14: rustc_driver::driver::phase_2_configure_and_expand
  15: rustc_driver::driver::compile_input
  16: rustc_driver::run_compiler

error: Could not compile `ethabi_contract`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-proc-macrosArea: Procedural macrosC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions