<p dir="auto">Let's say I have 3 modules <code class="notranslate">main.rs</code>, <code class="notranslate">a.rs</code> and <code class="notranslate">b.rs</code>, and two external libraries <code class="notranslate">libfoo.a</code> and <code class="notranslate">libbar.a</code>, and that <code class="notranslate">libbar</code> depends on symbols defined in <code class="notranslate">libfoo</code>.</p>
<p dir="auto"><strong>main.rs</strong></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="mod a;
mod b;
fn main() {}"><pre class="notranslate"><code class="notranslate">mod a;
mod b;
fn main() {}
</code></pre></div>
<p dir="auto"><strong>a.rs</strong></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="#[link(name = &quot;foo&quot;)]
extern {}"><pre class="notranslate"><code class="notranslate">#[link(name = "foo")]
extern {}
</code></pre></div>
<p dir="auto"><strong>b.rs</strong></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="#[link(name = &quot;bar&quot;)]
#[link(name = &quot;foo&quot;)]
extern {}"><pre class="notranslate"><code class="notranslate">#[link(name = "bar")]
#[link(name = "foo")]
extern {}
</code></pre></div>
<p dir="auto">Because rustc de-dupes the list of external libraries, it will pass to linker only  <code class="notranslate">-lfoo -lbar</code>.   However gnu linker does not look for unresolved symbols in libraries it had already processed, so it will fail to resolve libbar's references to libfoo.  The correct command line would have been <code class="notranslate">-lfoo -lbar -lfoo</code>.</p>
<p dir="auto">Rustc should not de-duplicate the list of libraries.  Furthermore, I think it should guarantee that libs will appear in the same order on the linker command line as they did in the source file.</p>
<p dir="auto"><a href="http://is.gd/zCNViG" rel="nofollow">http://is.gd/zCNViG</a></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="const VV: Vec&lt;&amp;'static str&gt; =
    vec!(&quot;A&quot; , &quot;B&quot;).drain().map(|s| s).collect::&lt;Vec&lt;&amp;'static str&gt;&gt;();"><pre class="notranslate"><code class="notranslate">const VV: Vec&lt;&amp;'static str&gt; =
    vec!("A" , "B").drain().map(|s| s).collect::&lt;Vec&lt;&amp;'static str&gt;&gt;();
</code></pre></div>
<p dir="auto">Obviously it is intended that this code produce a compiler error, but it also causes the compiler to panic with this message:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="thread 'rustc' panicked at 'assertion failed: self.mode == Mode::Var',
/home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/librustc/middle/check_const.rs:232"><pre class="notranslate"><code class="notranslate">thread 'rustc' panicked at 'assertion failed: self.mode == Mode::Var',
/home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/librustc/middle/check_const.rs:232
</code></pre></div>