<p dir="auto">This issue formalizes <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/pcwalton/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/pcwalton">@pcwalton</a>'s <a href="https://mail.mozilla.org/pipermail/rust-dev/2013-April/003866.html" rel="nofollow">RFC on the mailing list</a>. This was also discussed in the <a href="https://github.com/mozilla/rust/wiki/Meeting-weekly-2013-05-14#generic-paths">2013-05-14 meeting</a> and in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="13714900" data-permission-text="Title is private" data-url="https://github.com/rust-lang/rust/issues/6087" data-hovercard-type="pull_request" data-hovercard-url="/rust-lang/rust/pull/6087/hovercard" href="https://github.com/rust-lang/rust/pull/6087">#6087</a>. Steps towards this have already been made in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="14289366" data-permission-text="Title is private" data-url="https://github.com/rust-lang/rust/issues/6462" data-hovercard-type="pull_request" data-hovercard-url="/rust-lang/rust/pull/6462/hovercard" href="https://github.com/rust-lang/rust/pull/6462">#6462</a>.</p>
<p dir="auto">Whilst this is not a high priority change at the moment (understandably there are far bigger fish to fry), this is a semi-common question on the IRC and I think it's good if we have some place to redirect questions to.</p>
<p dir="auto">Instead of the current:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="Real::pi::&lt;float&gt;()"><pre class="notranslate"><span class="pl-smi">Real</span><span class="pl-kos">::</span><span class="pl-en">pi</span><span class="pl-kos">::</span><span class="pl-kos">&lt;</span><span class="pl-smi">float</span><span class="pl-kos">&gt;</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos"></span></pre></div>
<p dir="auto">this change would allow you to do:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="float::pi()"><pre class="notranslate">float<span class="pl-kos">::</span><span class="pl-en">pi</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos"></span></pre></div>
<p dir="auto">or</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="type T = float;
T::pi()"><pre class="notranslate"><span class="pl-k">type</span> <span class="pl-smi">T</span> = <span class="pl-smi">float</span><span class="pl-kos">;</span>
<span class="pl-smi">T</span><span class="pl-kos">::</span><span class="pl-en">pi</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos"></span></pre></div>
<p dir="auto">This could also allow for neat things like a generic <code class="notranslate">SizeOf</code> trait: <code class="notranslate">T::size_of()</code>, which is far nicer than the current <code class="notranslate">size_of::&lt;T&gt;()</code>. Or maybe there could be an <code class="notranslate">Init</code> trait for default initializers: <code class="notranslate">T::init()</code>.</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>