<p dir="auto">When I attempt to assign to a variable of type <code class="notranslate">&amp;fn(&amp;B)</code>, other than in the declaration of the variable, I get an unexpected panic in the compiler.</p>
<p dir="auto">I tried this code:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="struct B;

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

fn main() {
    let mut y = &amp;B::func;
    y = &amp;B::func;
}"><pre class="notranslate"><code class="notranslate">struct B;

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

fn main() {
    let mut y = &amp;B::func;
    y = &amp;B::func;
}
</code></pre></div>
<p dir="auto">I expected to see this happen: It should compile.</p>
<p dir="auto">Instead, this happened: I got an internal compiler error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="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"><pre class="notranslate"><code class="notranslate">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
</code></pre></div>
<h2 dir="auto">Meta</h2>
<p dir="auto"><code class="notranslate">rustc --version --verbose</code>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="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"><pre class="notranslate"><code class="notranslate">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
</code></pre></div>
<p dir="auto">Backtrace:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="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&lt;A&gt;::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&lt;A&gt;::call_box::h17316511360530184554
  24:     0x7f5f644479e1 - sys::thread::create::thread_start::h14fabfa97526362frLH
  25:     0x7f5f5edd20a4 - start_thread
  26:     0x7f5f6400dcfc - __clone
  27:                0x0 - &lt;unknown&gt;"><pre class="notranslate"><code class="notranslate">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&lt;A&gt;::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&lt;A&gt;::call_box::h17316511360530184554
  24:     0x7f5f644479e1 - sys::thread::create::thread_start::h14fabfa97526362frLH
  25:     0x7f5f5edd20a4 - start_thread
  26:     0x7f5f6400dcfc - __clone
  27:                0x0 - &lt;unknown&gt;
</code></pre></div>
<p dir="auto">This issue could be related to a similar issue I also discovered: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="67766386" data-permission-text="Title is private" data-url="https://github.com/rust-lang/rust/issues/24322" data-hovercard-type="issue" data-hovercard-url="/rust-lang/rust/issues/24322/hovercard" href="https://github.com/rust-lang/rust/issues/24322">#24322</a></p>
<p dir="auto">I get an internal compiler error on the input detailed below.</p>
<p dir="auto">I tried this code:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="struct B;

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

fn main() {
    let x:&amp;fn(&amp;B) = &amp;B::func;
}"><pre class="notranslate"><code class="notranslate">struct B;

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

fn main() {
    let x:&amp;fn(&amp;B) = &amp;B::func;
}
</code></pre></div>
<p dir="auto">I expected to see this happen: Maybe it should work like <code class="notranslate">let x = &amp;B::func</code>, but I'm guessing that I have some error here. I get an error message when I try a variant of the above;</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="fn main() {
    let y = &amp;B::func;
    let z:&amp;fn(&amp;B) = y;
}"><pre class="notranslate"><code class="notranslate">fn main() {
    let y = &amp;B::func;
    let z:&amp;fn(&amp;B) = y;
}
</code></pre></div>
<p dir="auto">This gives me the compile time error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="bug.rs:10:18: 10:19 error: mismatched types:
 expected `&amp;fn(&amp;B)`,
    found `&amp;fn(&amp;B) {B::func}`
(expected fn pointer,
    found fn item) [E0308]
bug.rs:10       let z:&amp;fn(&amp;B) = y;
                                ^
error: aborting due to previous error"><pre class="notranslate"><code class="notranslate">bug.rs:10:18: 10:19 error: mismatched types:
 expected `&amp;fn(&amp;B)`,
    found `&amp;fn(&amp;B) {B::func}`
(expected fn pointer,
    found fn item) [E0308]
bug.rs:10       let z:&amp;fn(&amp;B) = y;
                                ^
error: aborting due to previous error
</code></pre></div>
<p dir="auto">Instead, this happened:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="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 }', /build/buildd/rust-nightly-201504110408~93f7fe3~utopic/src/librustc/middle/def.rs:80"><pre class="notranslate"><code class="notranslate">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 }', /build/buildd/rust-nightly-201504110408~93f7fe3~utopic/src/librustc/middle/def.rs:80
</code></pre></div>
<h2 dir="auto">Meta</h2>
<p dir="auto"><code class="notranslate">rustc --version --verbose</code>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="rustc 1.0.0-dev (built 2015-04-11)
binary: rustc
commit-hash: unknown
commit-date: unknown
build-date: 2015-04-11
host: x86_64-unknown-linux-gnu
release: 1.0.0-dev"><pre class="notranslate"><code class="notranslate">rustc 1.0.0-dev (built 2015-04-11)
binary: rustc
commit-hash: unknown
commit-date: unknown
build-date: 2015-04-11
host: x86_64-unknown-linux-gnu
release: 1.0.0-dev
</code></pre></div>
<p dir="auto">From the <code class="notranslate">rust-nightly</code> package here: <a href="https://launchpad.net/~hansjorg/+archive/ubuntu/rust" rel="nofollow">https://launchpad.net/~hansjorg/+archive/ubuntu/rust</a></p>
<p dir="auto">Backtrace:</p>
<p dir="auto">Running <code class="notranslate">RUST_BACKTRACE=1 rustc bug.rs</code> gives me only this output:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Illegal instruction"><pre class="notranslate"><code class="notranslate">Illegal instruction
</code></pre></div>