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 with associated types: unbound path #17388

Closed
tomaka opened this issue Sep 19, 2014 · 5 comments · Fixed by #18868
Closed

ICE with associated types: unbound path #17388

tomaka opened this issue Sep 19, 2014 · 5 comments · Fixed by #18868
Assignees
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@tomaka
Copy link
Contributor

tomaka commented Sep 19, 2014

The version is rustc 0.12.0-nightly (9508faa22 2014-09-17 23:45:36 +0000)

Code:

trait Foo<T> {
    type Bar;
    fn get_bar() -> <Self as Foo<T>>::Bar;
}

Error:

C:\Users\Tomaka17\Projets\test\src\main.rs:5:34: 5:35 error: internal compiler e
rror: unbound path path(T)
C:\Users\Tomaka17\Projets\test\src\main.rs:5     fn get_bar() -> <Self as Foo<T>
>::Bar;
                                                                              ^
note: the compiler hit an unexpected failure path. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugr
eport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' failed at 'Box<Any>', C:\bot\slave\nightly-win32\build\src\libsynta
x\ast_util.rs:751

(because of some issues with my shell I can't print a backtrace for now)

@tomaka tomaka changed the title ICE with associated types ICE with associated types: unbound path Sep 19, 2014
@japaric
Copy link
Member

japaric commented Sep 19, 2014

Backtrace:

ice.rs:5:34: 5:35 error: internal compiler error: unbound path path(T)
ice.rs:5     fn get_bar() -> <Self as Foo<T>>::Bar;
                                          ^
note: the compiler hit an unexpected failure path. 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' failed at 'Box<Any>', /var/tmp/paludis/build/dev-lang-rust-scm/work/rust-scm/src/libsyntax/ast_util.rs:751

stack backtrace:
   1:     0x7f2c448aebd0 - rt::backtrace::imp::write::hc0f5116acb0fa00fiHq
   2:     0x7f2c448b1d90 - <unknown>
   3:     0x7f2c4506dd30 - unwind::begin_unwind_inner::hf187fcd15f4370d8MTd
   4:     0x7f2c43337e90 - <unknown>
   5:     0x7f2c43337de0 - diagnostic::SpanHandler::span_bug::hca7ebac09aed6025CPE
   6:     0x7f2c456210a0 - driver::session::Session::span_bug::h9bbd70985dcc1a1cYVx
   7:     0x7f2c456f77e0 - middle::typeck::astconv::ast_ty_to_prim_ty::h5f832d51acb46f2dMY0
   8:     0x7f2c45b87670 - <unknown>
   9:     0x7f2c45a29c90 - <unknown>
  10:     0x7f2c45b8bf30 - <unknown>
  11:     0x7f2c45b8be20 - <unknown>
  12:     0x7f2c45b8e980 - <unknown>
  13:     0x7f2c45b87670 - <unknown>
  14:     0x7f2c45b766a0 - <unknown>
  15:     0x7f2c45b58090 - <unknown>
  16:     0x7f2c45b31330 - middle::typeck::collect::convert::hde892ddbd942c261z3f
  17:     0x7f2c45b2a110 - middle::typeck::collect::collect_item_types::h34839250c10cab43q4e
  18:     0x7f2c45460220 - <unknown>
  19:     0x7f2c45cfa650 - middle::typeck::check_crate::h0dbc94139bb624b2WIk
  20:     0x7f2c45d674a0 - driver::driver::phase_3_run_analysis_passes::h777eed77d7f01cb9Ucx
  21:     0x7f2c45d62910 - driver::driver::compile_input::h1e1f68cd3c0db39eRTw
  22:     0x7f2c45de7990 - <unknown>
  23:     0x7f2c45de7870 - <unknown>
  24:     0x7f2c45479a10 - <unknown>
  25:     0x7f2c45479800 - <unknown>
  26:     0x7f2c467495b0 - <unknown>
  27:     0x7f2c450bcb00 - <unknown>
  28:     0x7f2c450bcaf0 - rust_try
  29:     0x7f2c4506b330 - unwind::try::h3fd431c8ae9db728uId
  30:     0x7f2c4506b190 - task::Task::run::h8df699a6a6fb1c6ecYc
  31:     0x7f2c46749320 - <unknown>
  32:     0x7f2c4506cd80 - <unknown>
  33:     0x7f2c44371fb0 - start_thread
  34:     0x7f2c44d3bf99 - clone
  35:                0x0 - <unknown>

Version:

rustc 0.12.0-pre (49dd8e8c3 2014-09-18 08:25:38 +0000)

According to -Z time-passes, the ICE occurs during the "type collecting" phase.

cc @pcwalton

@steveklabnik steveklabnik added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Sep 22, 2014
@carllerche
Copy link
Member

I think this may be the primary issue that I am hitting trying to use associated types at the moment.

@emberian
Copy link
Member

emberian commented Nov 8, 2014

Me too:

#![feature(associated_types)]
pub trait Transfer<S> {
    type R;
    fn transfer(&mut self) -> <Self as Transfer<S>>::R;
}

fn main(){}

gives:

foo.rs:4:49: 4:50 error: internal compiler error: unbound path path(S)
foo.rs:4     fn transfer(&mut self) -> <Self as Transfer<S>>::R;
                                                         ^
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 'Box<Any>', /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/libsyntax/diagnostic.rs:116

stack backtrace:
   1:     0x7f41fc192820 - rt::backtrace::imp::write::h8a05a2225574bd5ascq
   2:     0x7f41fc1958a0 - failure::on_fail::h3903c5b5788bc95c3xq
   3:     0x7f42006dea00 - unwind::begin_unwind_inner::h0919efe752d6fd357Rd
   4:     0x7f41fccdde40 - unwind::begin_unwind::h12448235468951990776
   5:     0x7f41fccdddc0 - diagnostic::SpanHandler::span_bug::h05cbb84cec88209aH6F
   6:     0x7f4200f96310 - middle::typeck::astconv::ast_ty_to_prim_ty::h9f95d12e1d973d81rR4
   7:     0x7f42013a38d0 - middle::typeck::astconv::ast_ty_to_ty::h12861914180600525724
   8:     0x7f4201068d60 - iter::Iterator::collect::h13337330953596778502
   9:     0x7f42013a6610 - middle::typeck::astconv::ast_path_substs::h13947801815788576546
  10:     0x7f42013a88c0 - middle::typeck::astconv::ast_path_to_trait_ref::h17933483232567598950
  11:     0x7f42013a9380 - middle::typeck::astconv::associated_ty_to_ty::h8004787093255996260
  12:     0x7f42013a38d0 - middle::typeck::astconv::ast_ty_to_ty::h12861914180600525724
  13:     0x7f420139b470 - middle::typeck::astconv::ty_of_method_or_bare_fn::h17568311308738250480
  14:     0x7f420137b230 - middle::typeck::collect::collect_trait_methods::ty_method_of_trait_method::hf39311a07abed50b7dk
  15:     0x7f4201357dd0 - middle::typeck::collect::convert::hde1a9421fe94c3ef0Uk
  16:     0x7f4201351640 - middle::typeck::collect::collect_item_types::h2377a8e9bb3d5ad9GUj
  17:     0x7f4200d3fbc0 - util::common::time::h6545073167695776246
  18:     0x7f42015378d0 - middle::typeck::check_crate::h0f9c9a0fae05a0bfJEp
  19:     0x7f42015a0940 - driver::driver::phase_3_run_analysis_passes::h46245b66b26614aeJoC
  20:     0x7f420159b7a0 - driver::driver::compile_input::he3b1257e173b8860u5B
  21:     0x7f420161e900 - driver::run_compiler::hd836d04808dd8d5eLVF
  22:     0x7f420161e7f0 - driver::run::closure.146540
  23:     0x7f4200d58b00 - task::TaskBuilder<S>::try_future::closure.104852
  24:     0x7f4200d588f0 - task::TaskBuilder<S>::spawn_internal::closure.104823
  25:     0x7f4200a25630 - task::NativeSpawner.Spawner::spawn::closure.8456
  26:     0x7f42007338c0 - rust_try_inner
  27:     0x7f42007338b0 - rust_try
  28:     0x7f42006dc380 - unwind::try::h32143614f9ac9c88PGd
  29:     0x7f42006dc210 - task::Task::run::h8c90cb04437a131dFMc
  30:     0x7f4200a25370 - task::NativeSpawner.Spawner::spawn::closure.8394
  31:     0x7f42006dda20 - thread::thread_start::h7bbfc46247c32113U7c
  32:     0x7f41fb544250 - start_thread
  33:     0x7f42003b83b9 - clone
  34:                0x0 - <unknown>

@nikomatsakis nikomatsakis self-assigned this Nov 8, 2014
@nikomatsakis
Copy link
Contributor

I have a fix for this issue but it requires PR #18743. I'll open the PR once that lands.

@nikomatsakis
Copy link
Contributor

bors added a commit that referenced this issue Nov 19, 2014
…oc-type, r=pcwalton

This fixes #17388. 

Note that we don't check type parameters in trait-references and so on, so we accept some nonsense (I opened #18865). (It may be easier to just add support for `T::Foo` and deprecate the qpath code until we can implement it more robustly using the trait lookup infrastructure, not sure.)
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) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants