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

Associated types Order can cause ICE #18611

Closed
mitsuhiko opened this issue Nov 4, 2014 · 3 comments · Fixed by #19780
Closed

Associated types Order can cause ICE #18611

mitsuhiko opened this issue Nov 4, 2014 · 3 comments · Fixed by #19780
Labels
A-associated-items Area: Associated items such as associated types and consts. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@mitsuhiko
Copy link
Contributor

Not sure how to properly describe the bug, but this causes an ICE:

#![feature(associated_types)]

struct SimulationInfo;

impl SimulationInfo {
    fn add_state<T: HasState>(&mut self, op: || -> <T as HasState>::State)
        -> Option<&mut <T as HasState>::State> {
        None
    }
}

trait HasState {
    type State;
}

Whereas this compiles:

#![feature(associated_types)]

struct SimulationInfo;

trait HasState {
    type State;
}

impl SimulationInfo {
    fn add_state<T: HasState>(&mut self, op: || -> <T as HasState>::State)
        -> Option<&mut <T as HasState>::State> {
        None
    }
}

Failure:

error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' panicked at 'No def'n found for DefId { krate: 0, node: 33 } in tcx.impl_or_trait_items', /Users/rustbuild/src/rust-buildbot/slave/nightly-mac/build/src/librustc/middle/ty.rs:4066

stack backtrace:
   1:        0x10d45a619 - rt::backtrace::imp::write::h03fee16d4a0b6b41moq
   2:        0x10d45d85c - failure::on_fail::h3e0f6b3c6c4bbcc3VEq
   3:        0x10d6bcf05 - unwind::begin_unwind_inner::h6c7f4532e72658d7SJd
   4:        0x10d6bcb9f - unwind::begin_unwind_fmt::h9863b25c438d6314kHd
   5:        0x10a408d50 - middle::ty::impl_or_trait_item::h8676078de6338b03J2J
   6:        0x10a7fe51e - middle::typeck::collect::convert_methods::ty_of_method::h1b65fc29f839dd39kEi
   7:        0x10a7a4b84 - middle::typeck::collect::convert::hf5d19782a9342fbfL7i
   8:        0x10a79c993 - middle::typeck::collect::collect_item_types::h2af040048993f98298h
   9:        0x10a1bb556 - util::common::time::h11920059333862041717
  10:        0x10a965478 - middle::typeck::check_crate::h50fcc5c8b39993f4LVn
  11:        0x10a9cdbcf - driver::driver::phase_3_run_analysis_passes::h1425a4ca465c7b097DA
  12:        0x10a9c82b8 - driver::driver::compile_input::h60bc42ef7fabbfd4SkA
  13:        0x10aa45ca8 - driver::run_compiler::h4031243f49082a9fw7D
  14:        0x10aa43ece - driver::run::closure.145349
  15:        0x10a1d381b - task::TaskBuilder<S>::try_future::closure.103709
  16:        0x10a1d3713 - task::TaskBuilder<S>::spawn_internal::closure.103680
  17:        0x10a15398d - task::NativeSpawner.Spawner::spawn::closure.8526
  18:        0x10d72320c - rust_try_inner
  19:        0x10d7231f6 - rust_try
  20:        0x10d6ba677 - unwind::try::hab84862d0081b274cyd
  21:        0x10d6ba50c - task::Task::run::h39093ecd59554b49ZJc
  22:        0x10a1537b3 - task::NativeSpawner.Spawner::spawn::closure.8463
  23:        0x10d6bbd37 - thread::thread_start::h589be8c0a398d299e5c
  24:     0x7fff9260c2fc - _pthread_body
  25:     0x7fff9260c279 - _pthread_body
@huonw huonw added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Nov 4, 2014
@ghost
Copy link

ghost commented Nov 9, 2014

cc #18389

@huonw
Copy link
Member

huonw commented Nov 20, 2014

Simpler example with the same error message:

#![feature(associated_types)]

fn add_state(op: <int as HasState>::State) {}

trait HasState {
    type State;
}

@huonw huonw added the A-associated-items Area: Associated items such as associated types and consts. label Nov 20, 2014
@ghost ghost added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Dec 12, 2014
bors added a commit that referenced this issue Dec 18, 2014
Closes #5988.
Closes #10176.
Closes #10456.
Closes #12744.
Closes #13264.
Closes #13324.
Closes #14182.
Closes #15381.
Closes #15444.
Closes #15480.
Closes #15756.
Closes #16822.
Closes #16966.
Closes #17351.
Closes #17503.
Closes #17545.
Closes #17771.
Closes #17816.
Closes #17897.
Closes #17905.
Closes #18188.
Closes #18232.
Closes #18345.
Closes #18389.
Closes #18400.
Closes #18502.
Closes #18611.
Closes #18783.
Closes #19009.
Closes #19081.
Closes #19098.
Closes #19127.
Closes #19135.
@kstep
Copy link

kstep commented Dec 27, 2014

I just stubled upon this bug (or very similar to this one) with latest nightly build (rustc 0.13.0-nightly (5ba6102 2014-12-25 18:01:36 +0000):

ERROR:rbml::reader: failed to find block with tag 1
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'explicit panic', /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/librbml/lib.rs:253
stack backtrace:
   1:     0x7fe80c6489f0 - sys::backtrace::write::hce8e882332e546a7JGt
   2:     0x7fe80c669820 - failure::on_fail::h588dafd90e82b74cj7z
   3:     0x7fe80c5d9ff0 - rt::unwind::begin_unwind_inner::h80ab16382fe3341ajLz
   4:     0x7fe8063243e0 - rt::unwind::begin_unwind::h1631746081972254121
   5:     0x7fe806322b60 - reader::get_doc::h2922d64c0e3fa9de0La
   6:     0x7fe80a99e5c0 - metadata::decoder::item_name::h342ac23f34c6fc45aDg
   7:     0x7fe80a9aa970 - metadata::decoder::get_trait_item_name_and_kind::hc85cab121b9bcebaAfh
   8:     0x7fe80a9ca310 - metadata::csearch::get_trait_item_name_and_kind::h5e523f8f26b802252yj
   9:     0x7fe80b84bff0 - Resolver<$u{27}a$GT$::build_reduced_graph_for_external_crate_def::he6103e3a99036d22gTc
  10:     0x7fe80b8517d0 - Resolver<$u{27}a$GT$::populate_external_module::unboxed_closure.13677
  11:     0x7fe80b81c260 - Resolver<$u{27}a$GT$::populate_module_if_necessary::h13429a2c5fef87d3i7c
  12:     0x7fe80b8598e0 - Resolver<$u{27}a$GT$::resolve_single_import::h617f6a0cbefe0c03zzd
  13:     0x7fe80b854d40 - Resolver<$u{27}a$GT$::resolve_imports_for_module::h21760343ab6f5d103ld
  14:     0x7fe80b853f90 - Resolver<$u{27}a$GT$::resolve_imports_for_module_subtree::hcf21ceb4110b82efjjd
  15:     0x7fe80b889db0 - resolve_crate::h5275b8fb523748b5Zxi
  16:     0x7fe80cba6d70 - driver::phase_3_run_analysis_passes::hdab79b3989f72249Jta
  17:     0x7fe80cb890b0 - driver::compile_input::h136bd835ef2474a0wba
  18:     0x7fe80cd55df0 - thunk::F.Invoke<A,$u{20}R$GT$::invoke::h3869597535200102526
  19:     0x7fe80cd54500 - rt::unwind::try::try_fn::h14290739184301814176
  20:     0x7fe80c6ce4e0 - rust_try_inner
  21:     0x7fe80c6ce4d0 - rust_try
  22:     0x7fe80cd54810 - thunk::F.Invoke<A,$u{20}R$GT$::invoke::h14740898037462295535
  23:     0x7fe80c658d40 - sys::thread::thread_start::h208082a168773e0ahFw
  24:     0x7fe806e87250 - start_thread
  25:     0x7fe80c28e589 - clone
  26:                0x0 - <unknown>
Could not compile `pb`.
Caused by:
  Process didn't exit successfully: `rustc /home/kstep/git/rust-pb/src/bin/trans-done-pb.rs --crate-name trans-done-pb --crate-type bin -g --out-dir /home/kste
p/git/rust-pb/target --emit=dep-info,link -L /home/kstep/git/rust-pb/target -L /home/kstep/git/rust-pb/target/deps --extern url=/home/kstep/git/rust-pb/target/
deps/liburl-d8534f0d463d0fed.rlib --extern http=/home/kstep/git/rust-pb/target/deps/libhttp-cdd1854d276fc158.rlib --extern rustc-serialize=/home/kstep/git/rust
-pb/target/deps/librustc-serialize-bd3e38505da47309.rlib --extern pb=/home/kstep/git/rust-pb/target/libpb-6571e72a68dae90d.rlib -L /usr/lib -L /home/kstep/git/
rust-pb/target/build/time-2f77139443a72f65/out` (status=101)

I have the following code in one of my modules:

pub trait PbMsg {
  type Obj;
}

// ....

impl PushMsg for PbMsg {
  type Obj = super::objects::Push;
}
// ...and a lot of very similar definitions

When I comment out this code, my module compiles OK.

If this is another bug, I will post it separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items such as associated types and consts. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants