rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.99k stars 12.79k forks source link

Internal compiler error: unexpected failure #15094

Closed tomjakubowski closed 10 years ago

tomjakubowski commented 10 years ago

Code sample:

// ice.rs
#![feature(overloaded_calls)]

use std::ops;

struct Adder<T> {
    x: T
}

impl<A, R, T: Add<A, R>> ops::Fn<(A, ), R> for Adder<T> {
    fn call(&self, args: (A, )) -> R {
        let (y, ) = args;
        self.x + y
    }
}

fn make_adder<T>(x: T) -> Adder<T> {
    Adder {
        x: x
    }
}

pub fn main() {
    let add3 = make_adder(3i);
    let y: int = add3(17);
    println!("{}", y);
}
$ rustc --version
rustc 0.11.0-pre-nightly (0ae4b97 2014-06-21 04:01:25 +0000)
host: x86_64-apple-darwin
$ RUST_LOG="rustc::middle::trans=debug" RUST_BACKTRACE=1 rustc ice.rs

Backtrace and debug log:

DEBUG:rustc::middle::trans::base: new InsnCtxt: text
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_mod
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_item
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_item
DEBUG:rustc::middle::trans::base: new InsnCtxt: meth::trans_impl
DEBUG:rustc::middle::trans::meth: trans_impl(name=Adder<T>.ops::Fn<(A,), R>, id=10u32)
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_item
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_item
DEBUG:rustc::middle::trans::base: get_item_val(id=`64u32`)
DEBUG:rustc::middle::trans::type_of: type_of () middle::ty::t{inner: (0x105fb38c0 as *())}
DEBUG:rustc::middle::trans::type_of: --> mapped t=() middle::ty::t{inner: (0x105fb38c0 as *())} to llty={}
DEBUG:rustc::middle::trans::type_of: type_of int middle::ty::t{inner: (0x105fb3b00 as *())}
DEBUG:rustc::middle::trans::type_of: --> mapped t=int middle::ty::t{inner: (0x105fb3b00 as *())} to llty=i64
DEBUG:rustc::middle::trans::type_of: type_of *u8 middle::ty::t{inner: (0x109172a80 as *())}
DEBUG:rustc::middle::trans::type_of: type_of u8 middle::ty::t{inner: (0x105fb3f80 as *())}
DEBUG:rustc::middle::trans::type_of: --> mapped t=u8 middle::ty::t{inner: (0x105fb3f80 as *())} to llty=i8
DEBUG:rustc::middle::trans::type_of: --> mapped t=*u8 middle::ty::t{inner: (0x109172a80 as *())} to llty=i8*
DEBUG:rustc::middle::trans::type_of: type_of **u8 middle::ty::t{inner: (0x1091729c0 as *())}
DEBUG:rustc::middle::trans::type_of: --> mapped t=**u8 middle::ty::t{inner: (0x1091729c0 as *())} to llty=i8**
DEBUG:rustc::middle::trans::base: trans_fn(param_substs=param_substs(Substs[types=[[];[];[]], regions=erased]))
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_fn
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_closure
DEBUG:rustc::middle::trans::base: trans_closure(..., param_substs=param_substs(Substs[types=[[];[];[]], regions=erased]))
DEBUG:rustc::middle::trans::base: new_fn_ctxt(path=main, id=64, param_substs=param_substs(Substs[types=[[];[];[]], regions=erased]))
DEBUG:rustc::middle::trans::cleanup: push_custom_cleanup_scope(): 0
DEBUG:rustc::middle::trans::base: new InsnCtxt: create_datums_for_fn_args
DEBUG:rustc::middle::trans::base: copy_args_to_allocas
DEBUG:rustc::middle::trans::base: new InsnCtxt: copy_args_to_allocas
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_block
DEBUG:rustc::middle::trans::cleanup: push_ast_cleanup_scope(block {
    let add3 = make_adder(3);
    let y: int = add3(17);
    match (&y,) {
        (__arg0,) => {
            #[allow(dead_code)]
            static __STATIC_FMTSTR: [::std::fmt::rt::Piece<'static>, ..1u] =
                [::std::fmt::rt::Argument(::std::fmt::rt::Argument{position:
                                                                       ::std::fmt::rt::ArgumentNext,
                                                                   format:
                                                                       ::std::fmt::rt::FormatSpec{fill:
                                                                                                      ' ',
                                                                                                  align:
                                                                                                      ::std::fmt::rt::AlignUnknown,
                                                                                                  flags:
                                                                                                      0u,
                                                                                                  precision:
                                                                                                      ::std::fmt::rt::CountImplied,
                                                                                                  width:
                                                                                                      ::std::fmt::rt::CountImplied,},})];
            let __args_vec =
                &[::std::fmt::argument(::std::fmt::secret_show, __arg0)];
            let __args =
                unsafe {
                    ::std::fmt::Arguments::new(__STATIC_FMTSTR, __args_vec)
                };
            ::std::io::stdio::println_args(&__args)
        }
    };
} (id=66))
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_stmt
DEBUG:rustc::middle::trans::controlflow: trans_stmt(stmt(67: let add3 = make_adder(3);))
DEBUG:rustc::middle::trans::cleanup: push_ast_cleanup_scope(stmt let add3 = make_adder(3); (id=67))
DEBUG:rustc::middle::trans::base: init_local(bcx=[block 0x1093c4110], local.id=68u32)
DEBUG:rustc::middle::trans::base: new InsnCtxt: init_local
DEBUG:rustc::middle::trans::base: new InsnCtxt: match::store_local
DEBUG:rustc::middle::trans::cleanup: var_scope(68) = AstScope(66u32)
DEBUG:rustc::middle::trans::base: new InsnCtxt: alloc_ty
DEBUG:rustc::middle::trans::type_of: type_of Adder<int> middle::ty::t{inner: (0x109215c40 as *())}
DEBUG:rustc::middle::trans::type_of: type_of Adder<int> middle::ty::t{inner: (0x109172c00 as *())}
DEBUG:rustc::middle::trans::adt: Representing: Adder<int>
DEBUG:rustc::middle::trans::adt: Represented as: alloc::rc::Rc<middle::trans::adt::Repr>{_ptr: (0x1091ac1d0 as *mut ()), _nosend: core::kinds::marker::NoSend, _noshare: core::kinds::marker::NoShare}
DEBUG:rustc::middle::trans::type_of: --> mapped t=Adder<int> middle::ty::t{inner: (0x109172c00 as *())} to llty=%"struct.Adder<[int]>" = type opaque
DEBUG:rustc::middle::trans::adt: Representing: Adder<int>
DEBUG:rustc::middle::trans::type_of: --> normalized Adder<int> middle::ty::t{inner: (0x109215c40 as *())} to Adder<int> middle::ty::t{inner: (0x109172c00 as *())} llty=%"struct.Adder<[int]>" = type { i64 }
DEBUG:rustc::middle::trans::base: new InsnCtxt: alloca
DEBUG:rustc::middle::trans::expr: trans_into() expr=expr(71: make_adder(3))
DEBUG:rustc::middle::trans::cleanup: push_ast_cleanup_scope(expr make_adder(3) (id=71))
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_rvalue_dps_unadjusted
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_call
DEBUG:rustc::middle::trans::cleanup: push_custom_cleanup_scope(): 4
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_callee
DEBUG:rustc::middle::trans::callee: callee::trans(expr=expr(72: make_adder))
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_fn_ref
DEBUG:rustc::middle::trans::callee: trans_fn_ref(def_id=syntax::ast::DefId{krate: 0u32, node: 51u32}:make_adder, node=ExprId(72u32), substs=Substs[types=[[];[];[int]], regions=[[];[];[]]], vtables=[[];[];[[]]])
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_fn_ref_with_vtables
DEBUG:rustc::middle::trans::callee: trans_fn_ref_with_vtables(bcx=[block 0x1093c4110], def_id=syntax::ast::DefId{krate: 0u32, node: 51u32}:make_adder, node=ExprId(72u32), substs=Substs[types=[[];[];[int]], regions=[[];[];[]]], vtables=[[];[];[[]]])
DEBUG:rustc::middle::trans::monomorphize: monomorphic_fn(fn_id=syntax::ast::DefId{krate: 0u32, node: 51u32}:make_adder, real_substs=Substs[types=[[];[];[int]], regions=[[];[];[]]], vtables=[[];[];[[]]], ref_id=Some(72u32))
DEBUG:rustc::middle::trans::base: new InsnCtxt: monomorphic_fn
DEBUG:rustc::middle::trans::monomorphize: monomorphic_fn(fn_id=syntax::ast::DefId{krate: 0u32, node: 51u32}:make_adder, psubsts=param_substs(Substs[types=[[];[];[int]], regions=[[];[];[]]]), hash_id=middle::trans::monomorphize::MonoId{def: syntax::ast::DefId{krate: 0u32, node: 51u32}, params: middle::subst::VecPerParamSpace<middle::ty::t>{vecs: (collections::vec::Vec<middle::ty::t>{len: 0u, cap: 0u, ptr: (0x0 as *mut ())}, collections::vec::Vec<middle::ty::t>{len: 0u, cap: 0u, ptr: (0x0 as *mut ())}, collections::vec::Vec<middle::ty::t>{len: 1u, cap: 1u, ptr: (0x109166e00 as *mut ())})}})
DEBUG:rustc::middle::trans::monomorphize: monomorphic_fn about to subst into fn(T) -> Adder<T>
DEBUG:rustc::middle::trans::monomorphize: monomorphize_fn mangled to _ZN10make_adder20h49495557206617655004v0.0E
DEBUG:rustc::middle::trans::adt: Representing: Adder<int>
DEBUG:rustc::middle::trans::adt: Represented as: alloc::rc::Rc<middle::trans::adt::Repr>{_ptr: (0x1091ac160 as *mut ()), _nosend: core::kinds::marker::NoSend, _noshare: core::kinds::marker::NoShare}
DEBUG:rustc::middle::trans::base: trans_fn(param_substs=param_substs(Substs[types=[[];[];[int]], regions=[[];[];[]]]))
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_fn
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_closure
DEBUG:rustc::middle::trans::base: trans_closure(..., param_substs=param_substs(Substs[types=[[];[];[int]], regions=[[];[];[]]]))
DEBUG:rustc::middle::trans::base: new_fn_ctxt(path=make_adder, id=51, param_substs=param_substs(Substs[types=[[];[];[int]], regions=[[];[];[]]]))
DEBUG:rustc::middle::trans::cleanup: push_custom_cleanup_scope(): 0
DEBUG:rustc::middle::trans::base: new InsnCtxt: create_datums_for_fn_args
DEBUG:rustc::middle::trans::base: copy_args_to_allocas
DEBUG:rustc::middle::trans::base: new InsnCtxt: copy_args_to_allocas
DEBUG:rustc::middle::trans::base: new InsnCtxt: match::store_arg
DEBUG:rustc::middle::trans::base: new InsnCtxt: alloc_ty
DEBUG:rustc::middle::trans::base: new InsnCtxt: alloca
DEBUG:rustc::middle::trans::base: new InsnCtxt: copy_to_no_check
DEBUG:rustc::middle::trans::builder: Store (i64:i64 %0) -> (i64*:  %x = alloca i64)
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_block
DEBUG:rustc::middle::trans::cleanup: push_ast_cleanup_scope(block { Adder{x: x,} } (id=61))
DEBUG:rustc::middle::trans::expr: trans_into() expr=expr(62: Adder{x: x,})
DEBUG:rustc::middle::trans::cleanup: push_ast_cleanup_scope(expr Adder{x: x,} (id=62))
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_rvalue_dps_unadjusted
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_rec
DEBUG:rustc::middle::trans::adt: Representing: Adder<int>
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_adt
DEBUG:rustc::middle::trans::cleanup: push_custom_cleanup_scope(): 3
DEBUG:rustc::middle::trans::expr: trans_into() expr=expr(63: x)
DEBUG:rustc::middle::trans::cleanup: push_ast_cleanup_scope(expr x (id=63))
DEBUG:rustc::middle::trans::expr: trans_unadjusted(expr=expr(63: x))
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_datum_unadjusted
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_def_lvalue
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_local_var
DEBUG:rustc::middle::trans::expr: take_local(nid=55u32, v=(i64*:  %x = alloca i64), ty=int)
DEBUG:rustc::middle::trans::base: new InsnCtxt: copy_to_no_check
DEBUG:rustc::middle::trans::base: new InsnCtxt: memcpy_ty
DEBUG:rustc::middle::trans::builder: Store (i64:  %3 = load i64* %x) -> (i64*:  %2 = getelementptr inbounds %"struct.Adder<[int]>"* %__make_return_pointer, i32 0, i32 0)
DEBUG:rustc::middle::trans::cleanup: pop_and_trans_ast_cleanup_scope(expr x (id=63))
DEBUG:rustc::middle::trans::cleanup: popping cleanup scope _ast_63_, 4 scopes remaining
DEBUG:rustc::middle::trans::cleanup: pop_custom_cleanup_scope(3)
DEBUG:rustc::middle::trans::cleanup: popping cleanup scope _custom_, 3 scopes remaining
DEBUG:rustc::middle::trans::cleanup: pop_and_trans_ast_cleanup_scope(expr Adder{x: x,} (id=62))
DEBUG:rustc::middle::trans::cleanup: popping cleanup scope _ast_62_, 2 scopes remaining
DEBUG:rustc::middle::trans::cleanup: pop_and_trans_ast_cleanup_scope(block { Adder{x: x,} } (id=61))
DEBUG:rustc::middle::trans::cleanup: popping cleanup scope _ast_61_, 1 scopes remaining
DEBUG:rustc::middle::trans::cleanup: pop_and_trans_custom_cleanup_scope(middle::trans::cleanup::CustomScopeIndex{index: 0u})
DEBUG:rustc::middle::trans::cleanup: popping cleanup scope _custom_, 0 scopes remaining
DEBUG:rustc::middle::trans::base: new InsnCtxt: finish_fn
DEBUG:rustc::middle::trans::build: terminate([block 0x1093c4250])
DEBUG:rustc::middle::trans::monomorphize: leaving monomorphic fn make_adder
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_args
DEBUG:rustc::middle::trans::expr: trans(expr=expr(73: 3))
DEBUG:rustc::middle::trans::cleanup: push_ast_cleanup_scope(expr 3 (id=73))
DEBUG:rustc::middle::trans::expr: trans_unadjusted(expr=expr(73: 3))
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_datum_unadjusted
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_immediate_lit
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_lit
DEBUG:rustc::middle::trans::cleanup: pop_and_trans_ast_cleanup_scope(expr 3 (id=73))
DEBUG:rustc::middle::trans::cleanup: popping cleanup scope _ast_73_, 5 scopes remaining
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_arg_datum
DEBUG:rustc::middle::trans::callee: trans_arg_datum(int)
DEBUG:rustc::middle::trans::callee:    arg datum: Datum((i64:i64 3), int, RvalueExpr(middle::trans::datum::Rvalue{mode: ByValue}))
DEBUG:rustc::middle::trans::callee: --- trans_arg_datum passing (i64:i64 3)
DEBUG:rustc::middle::trans::cleanup: pop_custom_cleanup_scope(4)
DEBUG:rustc::middle::trans::cleanup: popping cleanup scope _custom_, 4 scopes remaining
DEBUG:rustc::middle::trans::base: new InsnCtxt: invoke_
DEBUG:rustc::middle::trans::base: invoke at ???
DEBUG:rustc::middle::trans::base: calling 0x7fceb3700000 at 0x7fceb35037d0
DEBUG:rustc::middle::trans::base: arg: 0x7fceb37003a0
DEBUG:rustc::middle::trans::builder: Call (%"struct.Adder<[int]>" (i64)*:
; Function Attrs: uwtable
define internal %"struct.Adder<[int]>" @_ZN10make_adder20h49495557206617655004v0.0E(i64) unnamed_addr #0 {
entry-block:
  %__make_return_pointer = alloca %"struct.Adder<[int]>"
  %x = alloca i64
  store i64 %0, i64* %x
  %1 = getelementptr inbounds %"struct.Adder<[int]>"* %__make_return_pointer, i32 0, i32 0
  %2 = load i64* %x
  store i64 %2, i64* %1
  %3 = load %"struct.Adder<[int]>"* %__make_return_pointer
  ret %"struct.Adder<[int]>" %3
}
) with args ((i64:i64 3))
DEBUG:rustc::middle::trans::builder: Store (%"struct.Adder<[int]>" = type { i64 }:  %1 = call %"struct.Adder<[int]>" @_ZN10make_adder20h49495557206617655004v0.0E(i64 3)) -> (%"struct.Adder<[int]>"*:  %add3 = alloca %"struct.Adder<[int]>")
DEBUG:rustc::middle::trans::cleanup: pop_and_trans_ast_cleanup_scope(expr make_adder(3) (id=71))
DEBUG:rustc::middle::trans::cleanup: popping cleanup scope _ast_71_, 3 scopes remaining
DEBUG:rustc::middle::trans::cleanup: pop_and_trans_ast_cleanup_scope(stmt let add3 = make_adder(3); (id=67))
DEBUG:rustc::middle::trans::cleanup: popping cleanup scope _ast_67_, 2 scopes remaining
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_stmt
DEBUG:rustc::middle::trans::controlflow: trans_stmt(stmt(74: let y: int = add3(17);))
DEBUG:rustc::middle::trans::cleanup: push_ast_cleanup_scope(stmt let y: int = add3(17); (id=74))
DEBUG:rustc::middle::trans::base: init_local(bcx=[block 0x1093c4110], local.id=75u32)
DEBUG:rustc::middle::trans::base: new InsnCtxt: init_local
DEBUG:rustc::middle::trans::base: new InsnCtxt: match::store_local
DEBUG:rustc::middle::trans::cleanup: var_scope(75) = AstScope(66u32)
DEBUG:rustc::middle::trans::base: new InsnCtxt: alloc_ty
DEBUG:rustc::middle::trans::base: new InsnCtxt: alloca
DEBUG:rustc::middle::trans::expr: trans_into() expr=expr(79: add3(17))
DEBUG:rustc::middle::trans::cleanup: push_ast_cleanup_scope(expr add3(17) (id=79))
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_rvalue_dps_unadjusted
DEBUG:rustc::middle::trans::expr: trans(expr=expr(80: add3))
DEBUG:rustc::middle::trans::cleanup: push_ast_cleanup_scope(expr add3 (id=80))
DEBUG:rustc::middle::trans::expr: trans_unadjusted(expr=expr(80: add3))
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_datum_unadjusted
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_def_lvalue
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_local_var
DEBUG:rustc::middle::trans::expr: take_local(nid=70u32, v=(%"struct.Adder<[int]>"*:  %add3 = alloca %"struct.Adder<[int]>"), ty=Adder<int>)
DEBUG:rustc::middle::trans::expr: unadjusted datum for expr 80: Datum((%"struct.Adder<[int]>"*:  %add3 = alloca %"struct.Adder<[int]>"), Adder<int>, LvalueExpr)
DEBUG:rustc::middle::trans::expr: after adjustments, datum=Datum((%"struct.Adder<[int]>"*:  %add3 = alloca %"struct.Adder<[int]>"), &'static Adder<int>, RvalueExpr(middle::trans::datum::Rvalue{mode: ByValue}))
DEBUG:rustc::middle::trans::cleanup: pop_and_trans_ast_cleanup_scope(expr add3 (id=80))
DEBUG:rustc::middle::trans::cleanup: popping cleanup scope _ast_80_, 4 scopes remaining
DEBUG:rustc::middle::trans::adt: Representing: (int)
DEBUG:rustc::middle::trans::adt: Represented as: alloc::rc::Rc<middle::trans::adt::Repr>{_ptr: (0x1091ac6a0 as *mut ()), _nosend: core::kinds::marker::NoSend, _noshare: core::kinds::marker::NoShare}
DEBUG:rustc::middle::trans::cleanup: push_custom_cleanup_scope(): 4
DEBUG:rustc::middle::trans::type_of: type_of (int) middle::ty::t{inner: (0x10cdecf40 as *())}
DEBUG:rustc::middle::trans::adt: Representing: (int)
DEBUG:rustc::middle::trans::type_of: --> mapped t=(int) middle::ty::t{inner: (0x10cdecf40 as *())} to llty={ i64 }
DEBUG:rustc::middle::trans::base: new InsnCtxt: alloca
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_adt
DEBUG:rustc::middle::trans::cleanup: push_custom_cleanup_scope(): 5
DEBUG:rustc::middle::trans::expr: trans_into() expr=expr(81: 17)
DEBUG:rustc::middle::trans::cleanup: push_ast_cleanup_scope(expr 17 (id=81))
DEBUG:rustc::middle::trans::expr: trans_unadjusted(expr=expr(81: 17))
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_datum_unadjusted
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_immediate_lit
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_lit
DEBUG:rustc::middle::trans::base: new InsnCtxt: copy_to_no_check
DEBUG:rustc::middle::trans::builder: Store (i64:i64 17) -> (i64*:  %2 = getelementptr inbounds { i64 }* %tupled_arguments, i32 0, i32 0)
DEBUG:rustc::middle::trans::cleanup: pop_and_trans_ast_cleanup_scope(expr 17 (id=81))
DEBUG:rustc::middle::trans::cleanup: popping cleanup scope _ast_81_, 6 scopes remaining
DEBUG:rustc::middle::trans::cleanup: pop_custom_cleanup_scope(5)
DEBUG:rustc::middle::trans::cleanup: popping cleanup scope _custom_, 5 scopes remaining
DEBUG:rustc::middle::trans::adt: Representing: (int)
DEBUG:rustc::middle::trans::cleanup: push_custom_cleanup_scope(): 5
DEBUG:rustc::middle::trans::base: new InsnCtxt: meth::trans_method_callee
DEBUG:rustc::middle::trans::meth: trans_method_callee(middle::typeck::MethodCall{expr_id: 79u32, adjustment: NoAdjustment}, method=MethodCallee {origin: MethodStatic(syntax::ast::DefId{krate: 0u32, node: 29u32}:Adder<T>.ops::Fn<(A,), R>::call), ty: fn(&Adder<int>, (int)) -> int, Substs[types=[[int, int, int];[];[]], regions=[[];[];[]]]})
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_fn_ref
DEBUG:rustc::middle::trans::callee: trans_fn_ref(def_id=syntax::ast::DefId{krate: 0u32, node: 29u32}:Adder<T>.ops::Fn<(A,), R>::call, node=MethodCall(middle::typeck::MethodCall{expr_id: 79u32, adjustment: NoAdjustment}), substs=Substs[types=[[int, int, int];[];[]], regions=[[];[];[]]], vtables=[[];[];[]])
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_fn_ref_with_vtables
DEBUG:rustc::middle::trans::callee: trans_fn_ref_with_vtables(bcx=[block 0x1093c4110], def_id=syntax::ast::DefId{krate: 0u32, node: 29u32}:Adder<T>.ops::Fn<(A,), R>::call, node=MethodCall(middle::typeck::MethodCall{expr_id: 79u32, adjustment: NoAdjustment}), substs=Substs[types=[[int, int, int];[];[]], regions=[[];[];[]]], vtables=[[];[];[]])
DEBUG:rustc::middle::trans::monomorphize: monomorphic_fn(fn_id=syntax::ast::DefId{krate: 0u32, node: 29u32}:Adder<T>.ops::Fn<(A,), R>::call, real_substs=Substs[types=[[int, int, int];[];[]], regions=[[];[];[]]], vtables=[[];[];[]], ref_id=None)
DEBUG:rustc::middle::trans::base: new InsnCtxt: monomorphic_fn
DEBUG:rustc::middle::trans::monomorphize: monomorphic_fn(fn_id=syntax::ast::DefId{krate: 0u32, node: 29u32}:Adder<T>.ops::Fn<(A,), R>::call, psubsts=param_substs(Substs[types=[[int, int, int];[];[]], regions=[[];[];[]]]), hash_id=middle::trans::monomorphize::MonoId{def: syntax::ast::DefId{krate: 0u32, node: 29u32}, params: middle::subst::VecPerParamSpace<middle::ty::t>{vecs: (collections::vec::Vec<middle::ty::t>{len: 3u, cap: 3u, ptr: (0x10cded560 as *mut ())}, collections::vec::Vec<middle::ty::t>{len: 0u, cap: 0u, ptr: (0x0 as *mut ())}, collections::vec::Vec<middle::ty::t>{len: 0u, cap: 0u, ptr: (0x0 as *mut ())})}})
DEBUG:rustc::middle::trans::monomorphize: monomorphic_fn about to subst into fn(&Adder<T>, (A)) -> R
DEBUG:rustc::middle::trans::monomorphize: monomorphize_fn mangled to _ZN50Adder$LT$T$GT$.ops..Fn$LT$$LP$A$C$$RP$$C$$x20R$GT$4call21h104788750146579328244v0.0E
DEBUG:rustc::middle::trans::type_of: type_of &Adder<int> middle::ty::t{inner: (0x109172f00 as *())}
DEBUG:rustc::middle::trans::type_of: type_of &'static Adder<int> middle::ty::t{inner: (0x109173080 as *())}
DEBUG:rustc::middle::trans::type_of: --> mapped t=&'static Adder<int> middle::ty::t{inner: (0x109173080 as *())} to llty=%"struct.Adder<[int]>"*
DEBUG:rustc::middle::trans::type_of: --> normalized &Adder<int> middle::ty::t{inner: (0x109172f00 as *())} to &'static Adder<int> middle::ty::t{inner: (0x109173080 as *())} llty=%"struct.Adder<[int]>"*
DEBUG:rustc::middle::trans::base: trans_fn(param_substs=param_substs(Substs[types=[[int, int, int];[];[]], regions=[[];[];[]]]))
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_fn
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_closure
DEBUG:rustc::middle::trans::base: trans_closure(..., param_substs=param_substs(Substs[types=[[int, int, int];[];[]], regions=[[];[];[]]]))
DEBUG:rustc::middle::trans::base: new_fn_ctxt(path=Adder<T>.ops::Fn<(A,), R>::call, id=29, param_substs=param_substs(Substs[types=[[int, int, int];[];[]], regions=[[];[];[]]]))
DEBUG:rustc::middle::trans::cleanup: push_custom_cleanup_scope(): 0
DEBUG:rustc::middle::trans::base: new InsnCtxt: create_datums_for_fn_args
DEBUG:rustc::middle::trans::base: copy_args_to_allocas
DEBUG:rustc::middle::trans::base: new InsnCtxt: copy_args_to_allocas
DEBUG:rustc::middle::trans::base: new InsnCtxt: match::store_arg
DEBUG:rustc::middle::trans::base: new InsnCtxt: alloc_ty
DEBUG:rustc::middle::trans::type_of: type_of &Adder<int> middle::ty::t{inner: (0x109173140 as *())}
DEBUG:rustc::middle::trans::type_of: --> normalized &Adder<int> middle::ty::t{inner: (0x109173140 as *())} to &'static Adder<int> middle::ty::t{inner: (0x109173080 as *())} llty=%"struct.Adder<[int]>"*
DEBUG:rustc::middle::trans::base: new InsnCtxt: alloca
DEBUG:rustc::middle::trans::base: new InsnCtxt: copy_to_no_check
DEBUG:rustc::middle::trans::builder: Store (%"struct.Adder<[int]>"*:%"struct.Adder<[int]>"* %0) -> (%"struct.Adder<[int]>"**:  %self = alloca %"struct.Adder<[int]>"*)
DEBUG:rustc::middle::trans::base: new InsnCtxt: match::store_arg
DEBUG:rustc::middle::trans::base: new InsnCtxt: alloc_ty
DEBUG:rustc::middle::trans::base: new InsnCtxt: alloca
DEBUG:rustc::middle::trans::base: new InsnCtxt: copy_to_no_check
DEBUG:rustc::middle::trans::builder: Store ({ i64 }:{ i64 } %1) -> ({ i64 }*:  %args = alloca { i64 })
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_block
DEBUG:rustc::middle::trans::cleanup: push_ast_cleanup_scope(block { let (y,) = args; self.x + y } (id=40))
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_stmt
DEBUG:rustc::middle::trans::controlflow: trans_stmt(stmt(41: let (y,) = args;))
DEBUG:rustc::middle::trans::cleanup: push_ast_cleanup_scope(stmt let (y,) = args; (id=41))
DEBUG:rustc::middle::trans::base: init_local(bcx=[block 0x1093c4250], local.id=42u32)
DEBUG:rustc::middle::trans::base: new InsnCtxt: init_local
DEBUG:rustc::middle::trans::base: new InsnCtxt: match::store_local
DEBUG:rustc::middle::trans::expr: trans(expr=expr(46: args))
DEBUG:rustc::middle::trans::cleanup: push_ast_cleanup_scope(expr args (id=46))
DEBUG:rustc::middle::trans::expr: trans_unadjusted(expr=expr(46: args))
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_datum_unadjusted
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_def_lvalue
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_local_var
DEBUG:rustc::middle::trans::expr: take_local(nid=37u32, v=({ i64 }*:  %args = alloca { i64 }), ty=(int))
DEBUG:rustc::middle::trans::cleanup: pop_and_trans_ast_cleanup_scope(expr args (id=46))
DEBUG:rustc::middle::trans::cleanup: popping cleanup scope _ast_46_, 3 scopes remaining
DEBUG:rustc::middle::trans::cleanup: var_scope(42) = AstScope(40u32)
DEBUG:rustc::middle::trans::_match: bind_irrefutable_pat(bcx=[block 0x1093c4250], pat=pat(44: (y,)), binding_mode=BindLocal)
DEBUG:rustc::middle::trans::base: new InsnCtxt: match::bind_irrefutable_pat
DEBUG:rustc::middle::trans::adt: Representing: (int)
DEBUG:rustc::middle::trans::_match: bind_irrefutable_pat(bcx=[block 0x1093c4250], pat=pat(45: y), binding_mode=BindLocal)
DEBUG:rustc::middle::trans::base: new InsnCtxt: match::bind_irrefutable_pat
DEBUG:rustc::middle::trans::base: new InsnCtxt: alloc_ty
DEBUG:rustc::middle::trans::base: new InsnCtxt: alloca
DEBUG:rustc::middle::trans::base: new InsnCtxt: copy_to_no_check
DEBUG:rustc::middle::trans::base: new InsnCtxt: memcpy_ty
DEBUG:rustc::middle::trans::builder: Store (i64:  %4 = load i64* %3) -> (i64*:  %y = alloca i64)
DEBUG:rustc::middle::trans::cleanup: pop_and_trans_ast_cleanup_scope(stmt let (y,) = args; (id=41))
DEBUG:rustc::middle::trans::cleanup: popping cleanup scope _ast_41_, 2 scopes remaining
DEBUG:rustc::middle::trans::expr: trans_into() expr=expr(47: self.x + y)
DEBUG:rustc::middle::trans::cleanup: push_ast_cleanup_scope(expr self.x + y (id=47))
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_rvalue_dps_unadjusted
DEBUG:rustc::middle::trans::expr: trans(expr=expr(48: self.x))
DEBUG:rustc::middle::trans::cleanup: push_ast_cleanup_scope(expr self.x (id=48))
DEBUG:rustc::middle::trans::expr: trans_unadjusted(expr=expr(48: self.x))
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_datum_unadjusted
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_rec_field
DEBUG:rustc::middle::trans::expr: trans(expr=expr(49: self))
DEBUG:rustc::middle::trans::cleanup: push_ast_cleanup_scope(expr self (id=49))
DEBUG:rustc::middle::trans::expr: trans_unadjusted(expr=expr(49: self))
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_datum_unadjusted
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_def_lvalue
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_local_var
DEBUG:rustc::middle::trans::expr: take_local(nid=32u32, v=(%"struct.Adder<[int]>"**:  %self = alloca %"struct.Adder<[int]>"*), ty=&Adder<int>)
DEBUG:rustc::middle::trans::expr: unadjusted datum for expr 49: Datum((%"struct.Adder<[int]>"**:  %self = alloca %"struct.Adder<[int]>"*), &Adder<int>, LvalueExpr)
DEBUG:rustc::middle::trans::expr: deref_once(expr=expr(49: self), datum=Datum((%"struct.Adder<[int]>"**:  %self = alloca %"struct.Adder<[int]>"*), &Adder<int>, LvalueExpr), method_call=MethodCall { expr_id: 49, adjustment: AutoDeref(1) })
DEBUG:rustc::middle::trans::expr: deref_once(expr=49, method_call=MethodCall { expr_id: 49, adjustment: AutoDeref(1) }, result=Datum((%"struct.Adder<[int]>"*:  %5 = load %"struct.Adder<[int]>"** %self), Adder<int>, LvalueExpr))
DEBUG:rustc::middle::trans::expr: after adjustments, datum=Datum((%"struct.Adder<[int]>"*:  %5 = load %"struct.Adder<[int]>"** %self), Adder<int>, LvalueExpr)
DEBUG:rustc::middle::trans::cleanup: pop_and_trans_ast_cleanup_scope(expr self (id=49))
DEBUG:rustc::middle::trans::cleanup: popping cleanup scope _ast_49_, 4 scopes remaining
DEBUG:rustc::middle::trans::adt: Representing: Adder<int>
DEBUG:rustc::middle::trans::expr: unadjusted datum for expr 48: Datum((i64*:  %6 = getelementptr inbounds %"struct.Adder<[int]>"* %5, i32 0, i32 0), int, LvalueExpr)
DEBUG:rustc::middle::trans::expr: after adjustments, datum=Datum((i64*:  %6 = getelementptr inbounds %"struct.Adder<[int]>"* %5, i32 0, i32 0), &'static int, RvalueExpr(middle::trans::datum::Rvalue{mode: ByValue}))
DEBUG:rustc::middle::trans::cleanup: pop_and_trans_ast_cleanup_scope(expr self.x (id=48))
DEBUG:rustc::middle::trans::cleanup: popping cleanup scope _ast_48_, 3 scopes remaining
DEBUG:rustc::middle::trans::expr: trans(expr=expr(50: y))
DEBUG:rustc::middle::trans::cleanup: push_ast_cleanup_scope(expr y (id=50))
DEBUG:rustc::middle::trans::expr: trans_unadjusted(expr=expr(50: y))
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_datum_unadjusted
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_def_lvalue
DEBUG:rustc::middle::trans::base: new InsnCtxt: trans_local_var
DEBUG:rustc::middle::trans::expr: take_local(nid=45u32, v=(i64*:  %y = alloca i64), ty=int)
DEBUG:rustc::middle::trans::cleanup: pop_and_trans_ast_cleanup_scope(expr y (id=50))
DEBUG:rustc::middle::trans::cleanup: popping cleanup scope _ast_50_, 3 scopes remaining
DEBUG:rustc::middle::trans::cleanup: push_custom_cleanup_scope(): 3
DEBUG:rustc::middle::trans::base: new InsnCtxt: meth::trans_method_callee
DEBUG:rustc::middle::trans::meth: trans_method_callee(middle::typeck::MethodCall{expr_id: 47u32, adjustment: NoAdjustment}, method=MethodCallee {origin: MethodParam(syntax::ast::DefId{krate: 3u32, node: 22557u32},0u,middle::typeck::param_index{space: TypeSpace, index: 2u},0u), ty: fn(&T, &'<empty> A) -> R, Substs[types=[[A, R];[T];[]], regions=[[];[];[]]]})
DEBUG:rustc::middle::trans::common: find_vtable(n_param=middle::typeck::param_index{space: TypeSpace, index: 2u}, n_bound=0, ps=param_substs(Substs[types=[[int, int, int];[];[]], regions=[[];[];[]]]))
error: internal compiler error: unexpected failure
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 'index out of bounds: the len is 0 but the index is 2', /Users/rustbuild/src/rust-buildbot/slave/nightly-mac/build/src/librustc/lib.rs:1

stack backtrace:
   1:        0x1078ace12 - rt::backtrace::imp::write::hc71db530d81ba88cjPp::v0.11.0.pre
   2:        0x1078b40ca - failure::on_fail::hd6c1af5f720fca32y5p::v0.11.0.pre
   3:        0x107b53af9 - unwind::begin_unwind_inner::h286b2f4ed1398256mOd::v0.11.0.pre
   4:        0x107b5367d - unwind::begin_unwind_fmt::h603531494f35438dPLd::v0.11.0.pre
   5:        0x107b53411 - rust_begin_unwind
   6:        0x107b9fb9e - failure::begin_unwind::he293a9fe299d225ek2v::v0.11.0.pre
   7:        0x107ba4129 - failure::fail_bounds_check::h089aa01b4681538aw0v::v0.11.0.pre
   8:        0x10494121a - middle::trans::common::find_vtable::h4d605e7345505589R7i::v0.11.0.pre
   9:        0x10490fe78 - middle::trans::meth::trans_method_callee::h662a479634f04ec1etw::v0.11.0.pre
  10:        0x104936de0 - middle::trans::expr::trans_overloaded_op::closure.62665
  11:        0x10490de6c - middle::trans::callee::trans_call_inner::h907040cebca6696cWTe::v0.11.0.pre
  12:        0x1049301dd - middle::trans::expr::trans_overloaded_op::h102098778dc8ef33gxh::v0.11.0.pre
  13:        0x10491b368 - middle::trans::expr::trans_rvalue_dps_unadjusted::hbbe7c381b0e47e74Tmg::v0.11.0.pre
  14:        0x1048d85fe - middle::trans::expr::trans_into::hd229cd0dfbbd8f2aNvf::v0.11.0.pre
  15:        0x1048d89fa - middle::trans::controlflow::trans_block::hdedc32b7bf7fa1372ic::v0.11.0.pre
  16:        0x104997510 - middle::trans::base::trans_closure::h42f1e550969b1d96Bkq::v0.11.0.pre
  17:        0x1048a8216 - middle::trans::base::trans_fn::h1dd32f046b02cf70Csq::v0.11.0.pre
  18:        0x1048aa713 - middle::trans::monomorphize::monomorphic_fn::ha897c5b64d376ef3kGb::v0.11.0.pre
  19:        0x1049055ed - middle::trans::callee::trans_fn_ref_with_vtables::hfc97aebf8788bbb22ve::v0.11.0.pre
  20:        0x1048fe8ce - middle::trans::callee::trans_fn_ref::h384edb566efe6a09pqe::v0.11.0.pre
  21:        0x10490fdd3 - middle::trans::meth::trans_method_callee::h662a479634f04ec1etw::v0.11.0.pre
  22:        0x104936f20 - middle::trans::expr::trans_overloaded_call::closure.62679
  23:        0x10490de6c - middle::trans::callee::trans_call_inner::h907040cebca6696cWTe::v0.11.0.pre
  24:        0x10491aa4a - middle::trans::expr::trans_rvalue_dps_unadjusted::hbbe7c381b0e47e74Tmg::v0.11.0.pre
  25:        0x1048d85fe - middle::trans::expr::trans_into::hd229cd0dfbbd8f2aNvf::v0.11.0.pre
  26:        0x1049d5d7f - middle::trans::_match::store_local::closure.66786
  27:        0x1049d5b45 - middle::trans::_match::mk_binding_alloca::h16748125297078762169::v0.11.0.pre
  28:        0x104991153 - middle::trans::_match::store_local::he9d66b9949fe8459Yuu::v0.11.0.pre
  29:        0x1048d7aa0 - middle::trans::base::init_local::hcea1187c9399ac52hQp::v0.11.0.pre
  30:        0x1048d7005 - middle::trans::controlflow::trans_stmt::h63dbf64a94bb04e8Mdc::v0.11.0.pre
  31:        0x1048d8901 - middle::trans::controlflow::trans_block::hdedc32b7bf7fa1372ic::v0.11.0.pre
  32:        0x104997510 - middle::trans::base::trans_closure::h42f1e550969b1d96Bkq::v0.11.0.pre
  33:        0x1048a8216 - middle::trans::base::trans_fn::h1dd32f046b02cf70Csq::v0.11.0.pre
  34:        0x1048a1508 - middle::trans::base::trans_item::h0dddb0f19bb31f8e1Iq::v0.11.0.pre
  35:        0x1049a7ce1 - middle::trans::base::trans_crate::h5c9a3859b066cdbayCr::v0.11.0.pre
  36:        0x1051ad43a - driver::driver::phase_4_translate_to_llvm::h3273903afe96e6bbDbw::v0.11.0.pre
  37:        0x1051a29e8 - driver::driver::compile_input::h54f1907fcb89ba5foQv::v0.11.0.pre
  38:        0x105268064 - driver::run_compiler::h01f3e862283e5113jAy::v0.11.0.pre
  39:        0x105265ac6 - driver::main_args::closure.99073
  40:        0x10527a59b - task::TaskBuilder<S>::try_future::closure.100203
  41:        0x10527a434 - task::TaskBuilder<S>::spawn_internal::closure.100180
  42:        0x10483b3ec - task::spawn_opts::closure.7318
  43:        0x107b506a8 - task::Task::run::closure.5182
  44:        0x107bb942c - rust_try
  45:        0x107b52fda - unwind::try::hb6705ce8e0cb20d2LCd::v0.11.0.pre
  46:        0x107b50575 - task::Task::run::hf9d6a095707c904bXSc::v0.11.0.pre
  47:        0x10483b25b - task::spawn_opts::closure.7282
  48:        0x107b52619 - thread::thread_start::h5cc2d360755bec3amad::v0.11.0.pre
  49:     0x7fff8f413899 - _pthread_body
  50:     0x7fff8f41372a - _pthread_struct_init
tomjakubowski commented 10 years ago

Similar code without the overloaded_calls feature does not cause a compiler error:

struct Adder<T> {
    x: T
}

impl<A, R, T: Add<A, R>> Adder<T> {
    fn call(&self, args: (A, )) -> R {
        let (y, ) = args;
        self.x + y
    }
}

fn make_adder<T>(x: T) -> Adder<T> {
    Adder {
        x: x
    }
}

pub fn main() {
    let add3 = make_adder(3i);
    let y: int = add3.call((17, ));
    println!("{}", y);
}
tomjakubowski commented 10 years ago

A smaller test case:

#![feature(overloaded_calls)]

use std::{fmt, ops};

struct Shower<T> {
    x: T
}

impl<T: fmt::Show> ops::Fn<(), ()> for Shower<T> {
    fn call(&self, _args: ()) {
        println!("{}", self.x);
    }
}

fn make_shower<T>(x: T) -> Shower<T> {
    Shower { x: x }
}

pub fn main() {
    let show3 = make_shower(3i);
    show3();
}
jfager commented 10 years ago

Neither of the test cases are ICEing for me today, I'm seeing the following:

scratch$ rustc -v
rustc 0.12.0-pre-nightly (a4553453a 2014-07-25 00:36:11 +0000)

scratch$ rustc r15094.rs 
r15094.rs:33:5: 36:6 error: method `call` has an incompatible type for trait: expected "rust-call" fn but found "Rust" fn [E0053]
r15094.rs:33     fn call(&self, args: (A, )) -> R {
r15094.rs:34         let (y, ) = args;
r15094.rs:35         self.x + y
r15094.rs:36     }
error: aborting due to previous error

scratch$ rustc r15094.rs 
r15094.rs:10:5: 12:6 error: method `call` has an incompatible type for trait: expected "rust-call" fn but found "Rust" fn [E0053]
r15094.rs:10     fn call(&self, _args: ()) {
r15094.rs:11         println!("{}", self.x);
r15094.rs:12     }
error: aborting due to previous error
alexcrichton commented 10 years ago

Flagging as needstest