Skip to content

ICE: Type parameter out of range #21135

@Munksgaard

Description

@Munksgaard

The following code

// File: type-param-out-of-range.rs
#![feature(unsafe_destructor)]
#![allow(dead_code)]

struct Foo<T>;

struct Bar<T,U>;

#[unsafe_destructor]
impl <T,U> Drop for Foo<Bar<T,U>> {
    fn drop(&mut self) {
    }
}

fn main() {
    let x: Foo<Bar<u8,u8>>;
}

results in an ICE:

$ RUST_BACKTRACE=1 rustc type-param-out-of-range.rs                        
type-param-out-of-range.rs:16:9: 16:10 warning: unused variable: `x`, #[warn(unused_variables)] on by default
type-param-out-of-range.rs:16     let x: Foo<Bar<u8,u8>>;
                                      ^
type-param-out-of-range.rs:1:1: 1:1 error: internal compiler error: Type parameter `U/TypeSpace.1` (U/TypeSpace/1) out
 of range when substituting (root type=fn(&mut Foo<Bar<T, U>>) {Foo<Bar<T, U>>.Drop::drop}) substs=Substs[types=[[Bar<
u8, u8>];[];[]], regions=erased]                                                                                     
type-param-out-of-range.rs:1 // File: type-param-out-of-range.rs
                             ^
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 'Box<Any>', /home/munksgaard/src/rust/src/libsyntax/diagnostic.rs:123

stack backtrace:
   1:     0x7f6e7bb22dc0 - sys::backtrace::write::h06d560aae85815f88Rt
   2:     0x7f6e7bb44450 - failure::on_fail::h081ff97f16aa03b7S5z
   3:     0x7f6e7bab3410 - rt::unwind::begin_unwind_inner::h7f78d408022a5df7KKz
   4:     0x7f6e76ba98a0 - rt::unwind::begin_unwind::h8007830422440589374
   5:     0x7f6e76ba9830 - diagnostic::SpanHandler::span_bug::h042195ec97d5a9d4nQF
   6:     0x7f6e79ef7660 - middle::subst::SubstFolder<'a, 'tcx>.TypeFolder<'tcx>::fold_ty::hc46e2988fbeb8302vsO
   7:     0x7f6e79fce4c0 - vec::Vec<T>.FromIterator<T>::from_iter::h15269037237882667877
   8:     0x7f6e79fce390 - middle::subst::VecPerParamSpace<T>::map_enumerated::h1266298987987312387
   9:     0x7f6e79fcdea0 - middle::ty_fold::super_fold_substs::h2760487547895373381
  10:     0x7f6e79ef7660 - middle::subst::SubstFolder<'a, 'tcx>.TypeFolder<'tcx>::fold_ty::hc46e2988fbeb8302vsO
  11:     0x7f6e79fce4c0 - vec::Vec<T>.FromIterator<T>::from_iter::h15269037237882667877
  12:     0x7f6e79fce390 - middle::subst::VecPerParamSpace<T>::map_enumerated::h1266298987987312387
  13:     0x7f6e79fcdea0 - middle::ty_fold::super_fold_substs::h2760487547895373381
  14:     0x7f6e79ef7660 - middle::subst::SubstFolder<'a, 'tcx>.TypeFolder<'tcx>::fold_ty::hc46e2988fbeb8302vsO
  15:     0x7f6e79ef7660 - middle::subst::SubstFolder<'a, 'tcx>.TypeFolder<'tcx>::fold_ty::hc46e2988fbeb8302vsO
  16:     0x7f6e79fceb80 - vec::Vec<T>.FromIterator<T>::from_iter::h2115351605665496837
  17:     0x7f6e79fced30 - middle::ty_fold::TypeFolder::fold_fn_sig::h6160972233341453595
  18:     0x7f6e79ef7660 - middle::subst::SubstFolder<'a, 'tcx>.TypeFolder<'tcx>::fold_ty::hc46e2988fbeb8302vsO
  19:     0x7f6e7aaebbb0 - trans::monomorphize::monomorphic_fn::hefe231842b247daaFpd
  20:     0x7f6e7ab2a470 - trans::glue::trans_struct_drop::h99483df44919e3cbePe
  21:     0x7f6e7ab28ee0 - trans::glue::trans_struct_drop_flag::h1288477ec70a8eb8eNe
  22:     0x7f6e7ab22330 - trans::glue::get_drop_glue::h774edcaa48812ebd3He
  23:     0x7f6e7ab18830 - trans::glue::drop_ty::hb63ce4f58916398cZDe
  24:     0x7f6e7ac3ccb0 - trans::cleanup::DropValue<'tcx>.Cleanup<'tcx>::trans::ha4857007879709f0vQL
  25:     0x7f6e7aaff570 - trans::cleanup::FunctionContext<'blk, 'tcx>.CleanupMethods<'blk, 'tcx>::pop_and_trans_ast_c
leanup_scope::h854d941dc6fed8f3xLK                                                                                   
  26:     0x7f6e7ab00000 - trans::controlflow::trans_block::ha858a2eb08fe53cdB3d
  27:     0x7f6e7abcb660 - trans::base::trans_closure::hb19e49f2512af57dE0t
  28:     0x7f6e7aaeb610 - trans::base::trans_fn::h7f363780c9eeb93ajbu
  29:     0x7f6e7aae69f0 - trans::base::trans_item::h084c10fba04653b1Eyu
  30:     0x7f6e7abd2900 - trans::base::trans_crate::h40e9a36c663bc864luv
  31:     0x7f6e7c086d10 - driver::phase_4_translate_to_llvm::h0dd291bc44f3611aYMa
  32:     0x7f6e7c061b20 - driver::compile_input::h377632a667ea3f1cAba
  33:     0x7f6e7c12d610 - run_compiler::h52ab82d32dc68d12e5b
  34:     0x7f6e7c12bd80 - thunk::F.Invoke<A, R>::invoke::h9645197335179936595
  35:     0x7f6e7c12ace0 - rt::unwind::try::try_fn::h2284045992135876824
  36:     0x7f6e7bbaadf0 - rust_try_inner
  37:     0x7f6e7bbaade0 - rust_try
  38:     0x7f6e7c12af90 - thunk::F.Invoke<A, R>::invoke::h16054117873991906113
  39:     0x7f6e7bb327b0 - sys::thread::thread_start::h73064f9b3cafd4d5VJw
  40:     0x7f6e763cc160 - <unknown>
  41:     0x7f6e7b76cc69 - __clone
  42:                0x0 - <unknown>

with the rust version

$ rustc --version
rustc 1.0.0-dev (4fc9b4123 2015-01-13 05:01:34 +0000)

@Aatch told me that unsafe_destructors are going away soon, but I figured I'd create the issue for completeness.

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions