Skip to content

ICE when macros are used in types. #36540

Closed
@Stebalien

Description

@Stebalien

Using a macro in both the impl target and an associated type triggers an ICE. I believe this was introduced sometime between September 12th nightly and 1265cbf.

Minimal repro:

macro_rules! mac {
    () => { i32 }
}

trait Foo {
    type Assoc;
}

impl Foo for mac!() {
    type Assoc = mac!();
}

Backtrace:

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 'assertion failed: `(left == right)` (left: `3`, right: `2`)', ../src/librustc_resolve/macros.rs:138
stack backtrace:
   1:      0x392ca39c773 - std::sys::backtrace::tracing::imp::write::h4b09e6e8c01db097
   2:      0x392ca3b5f3d - std::panicking::default_hook::{{closure}}::h1d3243f546573ff4
   3:      0x392ca3ab08e - std::panicking::default_hook::h96c288d728df3ebf
   4:      0x392ca3ab778 - std::panicking::rust_panic_with_hook::hb1322e5f2588b4db
   5:      0x392ca3ab612 - std::panicking::begin_panic::hfbeda5aad583dc32
   6:      0x392ca3ab550 - std::panicking::begin_panic_fmt::h4fe9fb9d5109c4bf
   7:      0x392c89e408a - rustc_resolve::macros::ExpansionVisitor::visit_invoc::hd3288ffa1e19e7a3
   8:      0x392c89dbd0e - syntax::visit::walk_item::hf86c1e7b104454de
   9:      0x392c89dbaaf - syntax::visit::walk_item::hf86c1e7b104454de
  10:      0x392c89e448a - <rustc_resolve::macros::ExpansionVisitor<'a, 'b> as syntax::visit::Visitor>::visit_item::hb63de4723690c077
  11:      0x392c89e22ca - rustc_resolve::macros::<impl syntax::ext::base::Resolver for rustc_resolve::Resolver<'a>>::visit_expansion::hbc70678eeb0f70e7
  12:      0x392c311ac15 - syntax::ext::expand::MacroExpander::collect_invocations::h394c2a558f484088
  13:      0x392c31172ee - syntax::ext::expand::MacroExpander::expand::h959b262d25638add
  14:      0x392c3116619 - syntax::ext::expand::MacroExpander::expand_crate::h08dcfa5db99b42c9
  15:      0x392c3120d84 - syntax::ext::expand::expand_crate::hc240d93cfea63653
  16:      0x392ca7b18ed - rustc_driver::driver::phase_2_configure_and_expand::{{closure}}::h2d39fc9f02dd8655
  17:      0x392ca765b18 - rustc_driver::driver::phase_2_configure_and_expand::hb41c4aa3b639bda4
  18:      0x392ca75f2d8 - rustc_driver::driver::compile_input::hc0edbed7edb3eb18
  19:      0x392ca78c6b6 - rustc_driver::run_compiler::h22d678d32fb7c300
  20:      0x392ca6c6aa3 - std::panicking::try::do_call::h4d040997e2efdaf3
  21:      0x392ca3bde36 - __rust_maybe_catch_panic
  22:      0x392ca6e5b59 - <F as alloc::boxed::FnBox<A>>::call_box::hba0b436c79e56b23
  23:      0x392ca3a9ac0 - std::sys::thread::Thread::new::thread_start::h022e3887023c6290
  24:      0x392c249f453 - start_thread
  25:      0x392ca0027de - __GI___clone
  26:                0x0 - <unknown>

Metadata

Metadata

Assignees

No one assigned

    Labels

    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.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions