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 implementing trait with a generic parameter and an associated output type #19129

Closed
japaric opened this issue Nov 20, 2014 · 1 comment · Fixed by #19857
Closed
Labels
A-associated-items Area: Associated items (types, constants & functions) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@japaric
Copy link
Member

japaric commented Nov 20, 2014

STR

#![feature(associated_types)]

// This was an ICE (#17388), which got fixed by #18868
trait Trait<T> {
    type Output;

    fn fun() -> <Self as Trait<T>>::Output;
}

// The new ICE gets triggered by this `impl`
impl<T> Trait<T> for () {
    type Output = ();

    fn fun() {}
}

fn main() {}

Output

ice.rs:1:1: 1:1 error: internal compiler error: Type parameter `Output/AssocSpace.1` (Output/AssocSpace/1) out of range when substituting (root type=Output) substs=Substs[types=[[T];[()];[()];[]], regions=[[];[];[];[]]]
ice.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>', /var/tmp/paludis/build/dev-lang-rust-scm/work/rust-scm/src/libsyntax/diagnostic.rs:121

stack backtrace:
   1:     0x7f72dcabfae0 - rt::backtrace::imp::write::hdd602ae028f48d0dvVs
   2:     0x7f72dcac2b70 - <unknown>
   3:     0x7f72dd263310 - unwind::begin_unwind_inner::hbce8e4e8263dca1ePad
   4:     0x7f72da970ac0 - <unknown>
   5:     0x7f72da970a40 - diagnostic::SpanHandler::span_bug::hbe9748378cce230fGYF
   6:     0x7f72dba52970 - middle::subst::SubstFolder<'a, 'tcx>.TypeFolder<'tcx>::fold_ty::h3e05f8a78cf2b146RLP
   7:     0x7f72dbaf3800 - <unknown>
   8:     0x7f72dbaf33b0 - <unknown>
   9:     0x7f72dbaf2af0 - <unknown>
  10:     0x7f72dbb2c5b0 - <unknown>
  11:     0x7f72dbb2c410 - <unknown>
  12:     0x7f72dbb2bf50 - <unknown>
  13:     0x7f72dbb19410 - middle::ty::Generics<'tcx>::to_bounds::h3795ba6b160f5212yd1
  14:     0x7f72dbbe66b0 - middle::typeck::check::wf::BoundsChecker<'cx, 'tcx>::check_trait_ref::ha7aa8a645e91eafdZ9g
  15:     0x7f72dbbe48c0 - <unknown>
  16:     0x7f72dbbe1ae0 - <unknown>
  17:     0x7f72dbbe6c70 - middle::typeck::check::wf::CheckTypeWellFormedVisitor<'ccx, 'tcx>.Visitor<'v>::visit_item::ha3e9d13b541ef7c6k8g
  18:     0x7f72dbc3bb50 - middle::typeck::check::check_item_types::h754a0f7a04b7367639h
  19:     0x7f72dbfdf590 - <unknown>
  20:     0x7f72dbfde7a0 - middle::typeck::check_crate::h03aa0a74283c33108PL
  21:     0x7f72dd75bcc0 - driver::driver::phase_3_run_analysis_passes::h13d5815dc0529392D5R
  22:     0x7f72dd750ae0 - driver::driver::compile_input::hce9f8a5af8c23ae8nMR
  23:     0x7f72dd7d51d0 - <unknown>
  24:     0x7f72dd7d50c0 - <unknown>
  25:     0x7f72dd5e2d50 - <unknown>
  26:     0x7f72dd5e2b40 - <unknown>
  27:     0x7f72ddaf4ba0 - <unknown>
  28:     0x7f72dd2b2670 - <unknown>
  29:     0x7f72dd2b2660 - rust_try
  30:     0x7f72dd260c70 - unwind::try::hc967dd74749deb3arZc
  31:     0x7f72dd260b00 - task::Task::run::h236da885853fa0e4h5b
  32:     0x7f72ddaf48e0 - <unknown>
  33:     0x7f72dd262320 - <unknown>
  34:     0x7f72d7d451d0 - start_thread
  35:     0x7f72dcf391b9 - clone
  36:                0x0 - <unknown>

Version

#19113 + #18868 on top of bfaa7bc

cc @nikomatsakis

@tomjakubowski
Copy link
Contributor

On version b825b34 I get this ICE just with (edited with a smaller example):

#![feature(associated_types)]
#![crate_type="lib"]

pub trait Foo<A> {
    type B;

    fn foo(&self) -> bool { false }
}
foo.rs:1:1: 1:1 error: internal compiler error: Type parameter `B/AssocSpace.1` (B/AssocSpace/1) out of range when substituting (root type=B) substs=Substs[types=[[A];[Self];[B];[]], regions=[[];[];[];[]]]
foo.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/tom/src/rust/rust/src/libsyntax/diagnostic.rs:121

stack backtrace:
   1:     0x7f42b15e5750 - rt::backtrace::imp::write::hd4dc9c5b7adc70deB9s
   2:     0x7f42b15e88f0 - failure::on_fail::h601ae62da37820fduwt
   3:     0x7f42b1d8b5b0 - unwind::begin_unwind_inner::hd5e2a13fc766a9ednbd
   4:     0x7f42af488b30 - unwind::begin_unwind::h1840779095798302194
   5:     0x7f42af488ab0 - diagnostic::SpanHandler::span_bug::haca8008c8efcaccdl7F
   6:     0x7f42b05766a0 - middle::subst::SubstFolder<'a, 'tcx>.TypeFolder<'tcx>::fold_ty::h6dfb50fd9b2a318dKTP
   7:     0x7f42b0617f80 - middle::ty_fold::VecPerParamSpace<T>.TypeFoldable<'tcx>::fold_with::closure.96163
   8:     0x7f42b0617b30 - middle::subst::VecPerParamSpace<T>::map_enumerated::h1858619917310266163
   9:     0x7f42b0617270 - middle::ty_fold::TypeFolder::fold_substs::h10218276810570421665
  10:     0x7f42b0650d50 - middle::ty_fold::Vec<T>.TypeFoldable<'tcx>::fold_with::closure.98606
  11:     0x7f42b0650bb0 - vec::Vec<T>.FromIterator<T>::from_iter::h15054265504360828229
  12:     0x7f42b06506f0 - middle::ty_fold::ty..ParamBounds<'tcx>.TypeFoldable<'tcx>::fold_with::h5912314470836935956
  13:     0x7f42b063db90 - middle::ty::Generics<'tcx>::to_bounds::hbca748b7f43f8696vo1
  14:     0x7f42b0652470 - middle::ty::construct_parameter_environment::he8cb628e2da26785Gy6
  15:     0x7f42b0651dd0 - middle::ty::ParameterEnvironment<'tcx>::for_item::haae90d8e2fdf61c2ju1
  16:     0x7f42b071ef30 - middle::typeck::check::check_method_body::he4cebab5fe2fb8f8nwi
  17:     0x7f42b07134a0 - middle::typeck::check::check_item::h2db4e12f763145a7vli
  18:     0x7f42b0717350 - middle::typeck::check::check_item_types::h6c8b3f561b623f38x0h
  19:     0x7f42b0b03fa0 - util::common::time::h16216271059762254987
  20:     0x7f42b0b031b0 - middle::typeck::check_crate::hd1db30e85ca4d877jVL
  21:     0x7f42b2298aa0 - driver::driver::phase_3_run_analysis_passes::h27f0c337e17ae602bfS
  22:     0x7f42b228d8c0 - driver::driver::compile_input::h144d59d4a02adda6VVR
  23:     0x7f42b2312840 - driver::run_compiler::h0f9dd69b80cf00c4pUT
  24:     0x7f42b2312730 - driver::run::closure.59734
  25:     0x7f42b211ef60 - task::TaskBuilder<S>::try_future::closure.39040
  26:     0x7f42b211ed50 - task::TaskBuilder<S>::spawn_internal::closure.39011
  27:     0x7f42b2632a40 - task::NativeSpawner.Spawner::spawn::closure.2471
  28:     0x7f42b1dedc60 - rust_try_inner
  29:     0x7f42b1dedc50 - rust_try
  30:     0x7f42b1d88f10 - unwind::try::hbf9691835cc163a4IZc
  31:     0x7f42b1d88da0 - task::Task::run::h309f69a6701379ady5b
  32:     0x7f42b2632780 - task::NativeSpawner.Spawner::spawn::closure.2397
  33:     0x7f42b1d8a5c0 - thread::thread_start::h721d15c10ff33d0aEqc
  34:     0x7f42ac7f9250 - start_thread
  35:     0x7f42b1a613b9 - clone
  36:                0x0 - <unknown>

@huonw huonw added A-associated-items Area: Associated items (types, constants & functions) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Nov 25, 2014
japaric pushed a commit to japaric/rust that referenced this issue Dec 15, 2014
bors referenced this issue Dec 16, 2014
This creates an enormous amount of spew.
bors added a commit that referenced this issue Dec 16, 2014
Add test for #19129

Reviewed-by: alexcrichton
bors referenced this issue Dec 16, 2014
Using a type alias for iterator implementations is fragile since this
exposes the implementation to users of the iterator, and any changes
could break existing code.

This commit changes the iterators of `VecMap` to use
proper new types, rather than type aliases.  However, since it is
fair-game to treat a type-alias as the aliased type, this is a:

[breaking-change].
bors added a commit that referenced this issue Dec 16, 2014
Add test for #19129

Reviewed-by: alexcrichton
brson added a commit that referenced this issue Dec 16, 2014
bors added a commit that referenced this issue Dec 17, 2014
Add test for #19129

Reviewed-by: alexcrichton
alexcrichton added a commit to alexcrichton/rust that referenced this issue Dec 17, 2014
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 (types, constants & functions) 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