<p dir="auto">I am getting a compiler failure on the latest rust under linux. The problem seems to be the combination of cross-crate, pub use and an empty struct.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="task 'rustc' failed at 'expected bare rust fn or an intrinsic', /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/librustc/middle/trans/base.rs:1720"><pre class="notranslate"><code class="notranslate">task 'rustc' failed at 'expected bare rust fn or an intrinsic', /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/librustc/middle/trans/base.rs:1720
</code></pre></div>
<p dir="auto">Output with backtrace and code to reproduce:<br>
<a href="https://gist.github.com/rainbow-alex/4f50ce8f4be22dc93a21">https://gist.github.com/rainbow-alex/4f50ce8f4be22dc93a21</a></p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// foo.rs
#[crate_type = &quot;lib&quot;];

pub use foo::{T, foo};

mod foo {
    pub struct T;

    pub fn foo(x: T) { }
}

fn bar(x: T) { }"><pre class="notranslate"><span class="pl-c">// foo.rs</span>
<span class="pl-c1">#<span class="pl-kos">[</span>crate_type = <span class="pl-s">"lib"</span><span class="pl-kos">]</span></span><span class="pl-kos">;</span>

<span class="pl-k">pub</span> <span class="pl-k">use</span> foo<span class="pl-kos">::</span><span class="pl-kos">{</span><span class="pl-v">T</span><span class="pl-kos">,</span> foo<span class="pl-kos">}</span><span class="pl-kos">;</span>

<span class="pl-k">mod</span> foo <span class="pl-kos">{</span>
    <span class="pl-k">pub</span> <span class="pl-k">struct</span> <span class="pl-smi">T</span><span class="pl-kos">;</span>

    <span class="pl-k">pub</span> <span class="pl-k">fn</span> <span class="pl-en">foo</span><span class="pl-kos">(</span><span class="pl-s1">x</span><span class="pl-kos">:</span> <span class="pl-smi">T</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-kos">}</span>
<span class="pl-kos">}</span>

<span class="pl-k">fn</span> <span class="pl-en">bar</span><span class="pl-kos">(</span><span class="pl-s1">x</span><span class="pl-kos">:</span> <span class="pl-smi">T</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-kos">}</span></pre></div>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// bar.rs
extern crate foo;

fn main() {
    let x = foo::T;
    foo::foo(x);
}"><pre class="notranslate"><span class="pl-c">// bar.rs</span>
<span class="pl-k">extern</span> <span class="pl-k">crate</span> foo<span class="pl-kos">;</span>

<span class="pl-k">fn</span> <span class="pl-en">main</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">let</span> x = foo<span class="pl-kos">::</span><span class="pl-v">T</span><span class="pl-kos">;</span>
    foo<span class="pl-kos">::</span><span class="pl-en">foo</span><span class="pl-kos">(</span>x<span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ rustc foo.rs                                        
foo.rs:8:16: 8:17 warning: unused variable: `x`, #[warn(unused_variable)] on by default
foo.rs:8     pub fn foo(x: T) { }
                        ^
foo.rs:11:1: 11:17 warning: code is never used: `bar`, #[warn(dead_code)] on by default
foo.rs:11 fn bar(x: T) { }
          ^~~~~~~~~~~~~~~~
foo.rs:11:8: 11:9 warning: unused variable: `x`, #[warn(unused_variable)] on by default
foo.rs:11 fn bar(x: T) { }
                 ^
$ RUST_BACKTRACE=1 rustc bar.rs -L.                           
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://static.rust-lang.org/doc/master/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' failed at 'expected bare rust fn or an intrinsic', /Users/rustbuild/src/rust-buildbot/slave/nightly-mac/build/src/librustc/middle/trans/base.rs:1680
stack backtrace:
   1:        0x110cef874 - rt::backtrace::imp::write::h582661243a615e40bJa::v0.11.pre
   2:        0x110c53f06 - rt::unwind::begin_unwind_inner::h5002e0468a55cabcFja::v0.11.pre
   3:        0x10de45138 - rt::unwind::begin_unwind::h670fd7da7bbaeb39XSp::v0.11.pre
   4:        0x10df2c042 - middle::trans::base::register_fn::hbb8759275b04cae89Eo::v0.11.pre
   5:        0x10de52e52 - middle::trans::base::get_item_val::h1dad62be08e5991cjSo::v0.11.pre
   6:        0x10dead30f - middle::trans::callee::trans_fn_ref_with_vtables::hd733f6b7fa8eefa3Vgd::v0.11.pre
   7:        0x10dea8a7f - middle::trans::callee::trans_fn_ref::h6a1417fef0060143fad::v0.11.pre
   8:        0x10dec40e3 - middle::trans::expr::trans_def::he35a3c93856d755dJ4e::v0.11.pre
   9:        0x10debcd9a - middle::trans::expr::trans_unadjusted::haae245a7ffe8dcdc8Ke::v0.11.pre
  10:        0x10de83b4d - middle::trans::expr::trans_into::h0e643c2e225a30a12me::v0.11.pre
  11:        0x10df552df - middle::trans::_match::store_local::closure.60265
  12:        0x10df5506d - middle::trans::_match::mk_binding_alloca::h82ee2b7aab9fd4e0Z7s::v0.11.pre
  13:        0x10df1f8ea - middle::trans::_match::store_local::h1c633f23d36a0e6200s::v0.11.pre
  14:        0x10de8403a - middle::trans::base::init_local::hdfee3862f4f3e9b2OJn::v0.11.pre
  15:        0x10de830b6 - middle::trans::controlflow::trans_stmt::h86aa667e8541c7bdgYa::v0.11.pre
  16:        0x10de848d1 - middle::trans::controlflow::trans_block::h8aa8f39fad96fc82k2a::v0.11.pre
  17:        0x10df262c7 - middle::trans::base::trans_closure::h4e08e9cd3360b77aTeo::v0.11.pre
  18:        0x10de566f7 - middle::trans::base::trans_fn::hdf8711108b73013cImo::v0.11.pre
  19:        0x10de519f8 - middle::trans::base::trans_item::h7661c7f317341e64kyo::v0.11.pre
  20:        0x10df2a031 - middle::trans::base::trans_mod::h9eb441b3554b8c85pDo::v0.11.pre
  21:        0x10df33444 - middle::trans::base::trans_crate::hfe2773250e6168b518p::v0.11.pre
  22:        0x10e62090e - driver::driver::phase_4_translate_to_llvm::he8011930693c3fablve::v0.11.pre
  23:        0x10e623c56 - driver::driver::compile_input::hea278442c58ce8f7aLe::v0.11.pre
  24:        0x10e647f58 - run_compiler::he3998ac58048ca23Rcm::v0.11.pre
  25:        0x10e65badd - main_args::closure.91897
  26:        0x10e65a2f2 - monitor::closure.91782
  27:        0x10e655e9b - task::TaskBuilder::try::closure.91557
  28:        0x10de0950c - task::spawn_opts::closure.7941
  29:        0x110ceac98 - rt::task::Task::run::closure.41277
  30:        0x110cf568c - rust_try
  31:        0x110ceab17 - rt::task::Task::run::hdd1e4ef4aaf329acIc8::v0.11.pre
  32:        0x10de0938f - task::spawn_opts::closure.7913
  33:        0x110cee256 - rt::thread::thread_start::h6e64617662b609aepR8::v0.11.pre
  34:     0x7fff92737899 - _pthread_body
  35:     0x7fff9273772a - _pthread_struct_init"><pre class="notranslate"><code class="notranslate">$ rustc foo.rs                                        
foo.rs:8:16: 8:17 warning: unused variable: `x`, #[warn(unused_variable)] on by default
foo.rs:8     pub fn foo(x: T) { }
                        ^
foo.rs:11:1: 11:17 warning: code is never used: `bar`, #[warn(dead_code)] on by default
foo.rs:11 fn bar(x: T) { }
          ^~~~~~~~~~~~~~~~
foo.rs:11:8: 11:9 warning: unused variable: `x`, #[warn(unused_variable)] on by default
foo.rs:11 fn bar(x: T) { }
                 ^
$ RUST_BACKTRACE=1 rustc bar.rs -L.                           
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://static.rust-lang.org/doc/master/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' failed at 'expected bare rust fn or an intrinsic', /Users/rustbuild/src/rust-buildbot/slave/nightly-mac/build/src/librustc/middle/trans/base.rs:1680
stack backtrace:
   1:        0x110cef874 - rt::backtrace::imp::write::h582661243a615e40bJa::v0.11.pre
   2:        0x110c53f06 - rt::unwind::begin_unwind_inner::h5002e0468a55cabcFja::v0.11.pre
   3:        0x10de45138 - rt::unwind::begin_unwind::h670fd7da7bbaeb39XSp::v0.11.pre
   4:        0x10df2c042 - middle::trans::base::register_fn::hbb8759275b04cae89Eo::v0.11.pre
   5:        0x10de52e52 - middle::trans::base::get_item_val::h1dad62be08e5991cjSo::v0.11.pre
   6:        0x10dead30f - middle::trans::callee::trans_fn_ref_with_vtables::hd733f6b7fa8eefa3Vgd::v0.11.pre
   7:        0x10dea8a7f - middle::trans::callee::trans_fn_ref::h6a1417fef0060143fad::v0.11.pre
   8:        0x10dec40e3 - middle::trans::expr::trans_def::he35a3c93856d755dJ4e::v0.11.pre
   9:        0x10debcd9a - middle::trans::expr::trans_unadjusted::haae245a7ffe8dcdc8Ke::v0.11.pre
  10:        0x10de83b4d - middle::trans::expr::trans_into::h0e643c2e225a30a12me::v0.11.pre
  11:        0x10df552df - middle::trans::_match::store_local::closure.60265
  12:        0x10df5506d - middle::trans::_match::mk_binding_alloca::h82ee2b7aab9fd4e0Z7s::v0.11.pre
  13:        0x10df1f8ea - middle::trans::_match::store_local::h1c633f23d36a0e6200s::v0.11.pre
  14:        0x10de8403a - middle::trans::base::init_local::hdfee3862f4f3e9b2OJn::v0.11.pre
  15:        0x10de830b6 - middle::trans::controlflow::trans_stmt::h86aa667e8541c7bdgYa::v0.11.pre
  16:        0x10de848d1 - middle::trans::controlflow::trans_block::h8aa8f39fad96fc82k2a::v0.11.pre
  17:        0x10df262c7 - middle::trans::base::trans_closure::h4e08e9cd3360b77aTeo::v0.11.pre
  18:        0x10de566f7 - middle::trans::base::trans_fn::hdf8711108b73013cImo::v0.11.pre
  19:        0x10de519f8 - middle::trans::base::trans_item::h7661c7f317341e64kyo::v0.11.pre
  20:        0x10df2a031 - middle::trans::base::trans_mod::h9eb441b3554b8c85pDo::v0.11.pre
  21:        0x10df33444 - middle::trans::base::trans_crate::hfe2773250e6168b518p::v0.11.pre
  22:        0x10e62090e - driver::driver::phase_4_translate_to_llvm::he8011930693c3fablve::v0.11.pre
  23:        0x10e623c56 - driver::driver::compile_input::hea278442c58ce8f7aLe::v0.11.pre
  24:        0x10e647f58 - run_compiler::he3998ac58048ca23Rcm::v0.11.pre
  25:        0x10e65badd - main_args::closure.91897
  26:        0x10e65a2f2 - monitor::closure.91782
  27:        0x10e655e9b - task::TaskBuilder::try::closure.91557
  28:        0x10de0950c - task::spawn_opts::closure.7941
  29:        0x110ceac98 - rt::task::Task::run::closure.41277
  30:        0x110cf568c - rust_try
  31:        0x110ceab17 - rt::task::Task::run::hdd1e4ef4aaf329acIc8::v0.11.pre
  32:        0x10de0938f - task::spawn_opts::closure.7913
  33:        0x110cee256 - rt::thread::thread_start::h6e64617662b609aepR8::v0.11.pre
  34:     0x7fff92737899 - _pthread_body
  35:     0x7fff9273772a - _pthread_struct_init
</code></pre></div>