Skip to content

ICE when assigning a method to a variable #18412

Closed
@murarth

Description

@murarth

I was curious whether it would be possible to treat a method like a function, so I gave it a try.

struct A;

impl A {
    fn foo(&self) { }
}

fn main() {
    let f = A::foo;
    f(&A);
}

This is the version of rustc:

$ rustc -v
rustc 0.13.0-nightly (bd7138dd6 2014-10-27 23:02:55 +0000)

And this is the error:

x.rs:8:13: 8:19 error: internal compiler error: uncategorized def for expr 26: DefMethod(DefId { krate: 0, node: 8 }, None, FromImpl(DefId { krate: 0, node: 7 }))
x.rs:8     let f = A::foo;
                   ^~~~~~
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>', /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/libsyntax/diagnostic.rs:116

stack backtrace:
   1:     0x7ffe6856e070 - rt::backtrace::imp::write::h5a0997daa091452aAdq
   2:     0x7ffe68571160 - failure::on_fail::hc2bbfb16552a42a7Xyq
   3:     0x7ffe6caae180 - unwind::begin_unwind_inner::hba0c3c1372f5cb73PRd
   4:     0x7ffe692c39b0 - unwind::begin_unwind::h2734907025152909083
   5:     0x7ffe692c3930 - diagnostic::SpanHandler::span_bug::h963265597453565ah6F
   6:     0x7ffe6d4a4b10 - middle::ty::expr_kind::hdf6435478ca3d03fa9I
   7:     0x7ffe6d46cb30 - middle::trans::expr::trans_into::h59e7bbcc4d5362a6dG4
   8:     0x7ffe6d536370 - middle::trans::_match::store_local::closure.126275
   9:     0x7ffe6d536160 - middle::trans::_match::mk_binding_alloca::h7586589838283757987
  10:     0x7ffe6d505760 - middle::trans::_match::store_local::haee979a4ae164c29qwk
  11:     0x7ffe6d46c180 - middle::trans::base::init_local::h14997c0412bcab7fybg
  12:     0x7ffe6d46b540 - middle::trans::controlflow::trans_stmt::h0b313766085d2deenR0
  13:     0x7ffe6d46cf50 - middle::trans::controlflow::trans_block::he2d4b6f33ad56bdctW0
  14:     0x7ffe6d50c730 - middle::trans::base::trans_closure::hf302583eb5981ca2Y2g
  15:     0x7ffe6d460250 - middle::trans::base::trans_fn::h2698897672e52421meh
  16:     0x7ffe6d45d990 - middle::trans::base::trans_item::h108ceed97013196fFxh
  17:     0x7ffe6d516d10 - middle::trans::base::trans_crate::h2959ddec9d0661d4wvi
  18:     0x7ffe6d934da0 - driver::driver::phase_4_translate_to_llvm::h871e70ba7828df26FnA
  19:     0x7ffe6d92b610 - driver::driver::compile_input::hc2f03680b6cd2d08zUz
  20:     0x7ffe6d9ae5c0 - driver::run_compiler::h7d611b9a41d83191KHD
  21:     0x7ffe6d9ae4b0 - driver::run::closure.144980
  22:     0x7ffe6d12bfd0 - task::TaskBuilder<S>::try_future::closure.103244
  23:     0x7ffe6d12bdc0 - task::TaskBuilder<S>::spawn_internal::closure.103215
  24:     0x7ffe6cdf8a80 - task::NativeSpawner.Spawner::spawn::closure.8444
  25:     0x7ffe6cb07650 - rust_try_inner
  26:     0x7ffe6cb07640 - rust_try
  27:     0x7ffe6caab920 - unwind::try::hc0b42c9b6f96abb8xGd
  28:     0x7ffe6caab7b0 - task::Task::run::h1c3d2c1e07305f00nMc
  29:     0x7ffe6cdf87c0 - task::NativeSpawner.Spawner::spawn::closure.8382
  30:     0x7ffe6caad050 - thread::thread_start::h962311e4e7f76acfC7c
  31:     0x7ffe6791b0c0 - start_thread
  32:     0x7ffe6c775f89 - __clone
  33:                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