Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE when macros are used in types. #36540

Closed
Stebalien opened this issue Sep 16, 2016 · 3 comments
Closed

ICE when macros are used in types. #36540

Stebalien opened this issue Sep 16, 2016 · 3 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Stebalien
Copy link
Contributor

Stebalien commented Sep 16, 2016

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>
@apasel422 apasel422 added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Sep 16, 2016
@Stebalien
Copy link
Contributor Author

Note: this is actually a regression from stable to nightly:

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

trait Foo {
    type Assoc;
}

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

fn main() {}

@TimNN TimNN added regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 17, 2016
@TimNN
Copy link
Contributor

TimNN commented Sep 17, 2016

nightly-2016-09-15 is still good nightly-2016-09-16 ICEs (Changes)

I expect this was an effect of #36438, cc @jseyfried

@jseyfried
Copy link
Contributor

@TimNN Yeah this was caused by #36438 -- thanks for the cc!
Fixed in #36555.

bors added a commit that referenced this issue Sep 18, 2016
Visit and fold macro invocations in the same order

Fixes #36540.
r? @nrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants