rust-lang / rust

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

ICE when assigning to member function pointer variable #24327

Closed maghoff closed 9 years ago

maghoff commented 9 years ago

When I attempt to assign to a variable of type &fn(&B), other than in the declaration of the variable, I get an unexpected panic in the compiler.

I tried this code:

struct B;

impl B {
    fn func(&self) { }
}

fn main() {
    let mut y = &B::func;
    y = &B::func;
}

I expected to see this happen: It should compile.

Instead, this happened: I got an internal compiler error:

error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'path not fully resolved: PathResolution { base_def: DefTy(DefId { krate: 0, node: 4 }, false), last_private: LastMod(AllPublic), depth: 1 }', /home/mag/prog/rust/src/librustc/middle/def.rs:80

Meta

rustc --version --verbose:

rustc 1.0.0-dev (3a8275397 2015-04-11) (built 2015-04-11)
binary: rustc
commit-hash: 3a8275397a156b17331e16393e5e1ba89ab4de3f
commit-date: 2015-04-11
build-date: 2015-04-11
host: x86_64-unknown-linux-gnu
release: 1.0.0-dev

Backtrace:

stack backtrace:
   1:     0x7f5f64435779 - sys::backtrace::write::h1fb912b6242676e13JC
   2:     0x7f5f6445a067 - panicking::on_panic::h49b58f19dee2b6499aJ
   3:     0x7f5f643a3fb2 - rt::unwind::begin_unwind_inner::h954a8c2d8b458b8ehQI
   4:     0x7f5f643a427f - rt::unwind::begin_unwind_fmt::h8142be88e287f416VOI
   5:     0x7f5f623b1fe0 - middle::ty::resolve_expr::h468519011c7f5a2dsB6
   6:     0x7f5f625032b1 - middle::ty::expr_kind::h13d00213be0997d6yD6
   7:     0x7f5f6250307a - middle::ty::expr_is_lval::he8576d1b1ffb6fb6vC6
   8:     0x7f5f6323ac60 - check::check_expr_with_unifier::h1234167007494092036
   9:     0x7f5f63252f71 - check::check_expr_with_unifier::h13727019484792908569
  10:     0x7f5f63207604 - check::check_block_with_expected::h8460ca5f594c8570Nps
  11:     0x7f5f631eb196 - check::check_fn::hd5196d54a6852698Abo
  12:     0x7f5f63202f97 - check::check_bare_fn::h0073eb2d0e87712990n
  13:     0x7f5f631fcb58 - check::check_item::hef34ffea35346370Ujo
  14:     0x7f5f632c3fb6 - check_crate::closure.36498
  15:     0x7f5f632bf3f0 - check_crate::h679eb3dc01c34e66zxC
  16:     0x7f5f64aad938 - driver::phase_3_run_analysis_passes::h7b112f16caf4f0fcpGa
  17:     0x7f5f64a8ea05 - driver::compile_input::hb07383d8b05653e9Qba
  18:     0x7f5f64b4d6e1 - run_compiler::hd11be756ecff4a4dL4b
  19:     0x7f5f64b4b332 - boxed::F.FnBox<A>::call_box::h9743051768958258733
  20:     0x7f5f64b4a869 - rt::unwind::try::try_fn::h3770862294174962809
  21:     0x7f5f644da5f8 - rust_try_inner
  22:     0x7f5f644da5e5 - rust_try
  23:     0x7f5f64b4ab18 - boxed::F.FnBox<A>::call_box::h17316511360530184554
  24:     0x7f5f644479e1 - sys::thread::create::thread_start::h14fabfa97526362frLH
  25:     0x7f5f5edd20a4 - start_thread
  26:     0x7f5f6400dcfc - __clone
  27:                0x0 - <unknown>

This issue could be related to a similar issue I also discovered: https://github.com/rust-lang/rust/issues/24322

arielb1 commented 9 years ago

duplicate of #24322