Skip to content

ICE when trying use associated types #19726

Closed
@canndrew

Description

@canndrew

The following code causes an ICE in an up-to-date rustc

#![feature(associated_types)]

trait HKT<Arg> {
  type Res;
}

enum MakePair {}

impl<T> HKT<T> for MakePair {
  type Res = (T, T);
}

fn main() {
}

Here is the full rustc output

aaa.rs:1:1: 1:1 error: internal compiler error: Type parameter `Res/AssocSpace.1` (Res/AssocSpace/1) out of range when substituting (root type=Res) substs=Substs[types=[[T];[MakePair];[(T, T)];[]], regions=[[];[];[];[]]]
aaa.rs:1 #![feature(associated_types)]
         ^
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/acann/src/rust/rust/src/libsyntax/diagnostic.rs:129

stack backtrace:
   1: 0xb73bbbc0 - rt::backtrace::imp::write::h284a095c7aee31ccGOx
   2: 0xb73beb30 - failure::on_fail::h2d0aefabf893c1186fy
   3: 0xb721d460 - unwind::begin_unwind_inner::h4d26c479cdc48a2fCJc
   4: 0xb58c4660 - unwind::begin_unwind::h5309064723466376297
   5: 0xb58c45d0 - diagnostic::SpanHandler::span_bug::h782453507c017400a4E
   6: 0xb6140bf0 - middle::subst::SubstFolder<'a, 'tcx>.TypeFolder<'tcx>::fold_ty::h24e968235489f2b9i92
   7: 0xb6269760 - middle::ty_fold::VecPerParamSpace<T>.TypeFoldable<'tcx>::fold_with::closure.90750
   8: 0xb6159600 - middle::subst::VecPerParamSpace<T>::map_enumerated::h3314737924672344624
   9: 0xb6269420 - middle::ty_fold::TypeFolder::fold_substs::h10596287227473156004
  10: 0xb6299870 - middle::ty_fold::Vec<T>.TypeFoldable<'tcx>::fold_with::closure.93166
  11: 0xb62996d0 - iter::IteratorExt::collect::h12530763557803807858
  12: 0xb6299540 - middle::ty_fold::ty..ParamBounds<'tcx>.TypeFoldable<'tcx>::fold_with::h17172715228212896389
  13: 0xb62898b0 - middle::ty::Generics<'tcx>::to_bounds::h5b7ef3c2a0d468ca1Me
  14: 0xb6b1fd80 - check::wf::CheckTypeWellFormedVisitor<'ccx, 'tcx>::check_impl::closure.29495
  15: 0xb6b1c390 - check::wf::CheckTypeWellFormedVisitor<'ccx, 'tcx>::with_fcx::hea08a92c982ee16bARi
  16: 0xb6b22800 - check::wf::CheckTypeWellFormedVisitor<'ccx, 'tcx>.Visitor<'v>::visit_item::h83cff511db621e2e61i
  17: 0xb6eee9d0 - check_crate::closure.42370
  18: 0xb6eeb0a0 - util::common::time::h18259353318660871853
  19: 0xb6eea2a0 - check_crate::he7c5ea6b87c52b3bSFy
  20: 0xb75e56a0 - driver::phase_3_run_analysis_passes::h5e7f909e754bbebfCta
  21: 0xb75d3f90 - driver::compile_input::he705e5abc840cf58pba
  22: 0xb7672420 - run_compiler::h3736912802393701EYb
  23: 0xb7672300 - run::closure.21407
  24: 0xb7683a90 - task::TaskBuilder::try_future::closure.22861
  25: 0xb7395df0 - task::TaskBuilder::spawn_internal::closure.30624
  26: 0xb721b200 - task::Task::spawn::closure.5731
  27: 0xb721cdf0 - unwind::try::try_fn::h41e9940f84e74506VAc
  28: 0xb72863a0 - rust_try_inner
  29: 0xb7286360 - rust_try
  30: 0xb721b2e0 - unwind::try::h645db934c3e71637Tyc
  31: 0xb721b090 - task::Task::run::h8509a48449169e4efKb
  32: 0xb721ac80 - task::Task::spawn::closure.5707
  33: 0xb721c610 - thread::thread_start::h51b85550e3f54be9w1b
  34: 0xb35def80 - start_thread
  35: 0xb711b082 - __clone
  36:        0x0 - <unknown>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions