<p dir="auto">Test case:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="trait T&lt;X&gt; { }

fn foo&lt;I:T&lt;&amp;'self int&gt;&gt;() { }

fn main() { }"><pre class="notranslate"><span class="pl-k">trait</span> <span class="pl-smi">T</span><span class="pl-kos">&lt;</span><span class="pl-smi">X</span><span class="pl-kos">&gt;</span> <span class="pl-kos">{</span> <span class="pl-kos">}</span>

<span class="pl-k">fn</span> <span class="pl-en">foo</span><span class="pl-kos">&lt;</span><span class="pl-smi">I</span><span class="pl-kos">:</span><span class="pl-smi">T</span><span class="pl-kos">&lt;</span><span class="pl-c1">&amp;</span><span class="pl-c1">'</span><span class="pl-ent">self</span> <span class="pl-smi">int</span><span class="pl-kos">&gt;</span><span class="pl-kos">&gt;</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">main</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-kos">}</span></pre></div>
<p dir="auto">Transcript:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="% RUST_LOG=rustc=1 rustc --version
/Users/pnkfelix/opt/rust-dbg/bin/rustc 0.8-pre (dd5c737 2013-09-08 12:05:55 -0700)
host: x86_64-apple-darwin
% RUST_LOG=rustc=1 rustc /tmp/baz.rs
task &lt;unnamed&gt; failed at 'assertion failed: rp.is_none()', /Users/pnkfelix/Dev/Mozilla/rust.git/src/librustc/middle/typeck/collect.rs:1108
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug
note: try running with RUST_LOG=rustc=1 to get further details and report the results to github.com/mozilla/rust/issues
task &lt;unnamed&gt; failed at 'explicit failure', /Users/pnkfelix/Dev/Mozilla/rust.git/src/librustc/rustc.rs:376"><pre class="notranslate"><code class="notranslate">% RUST_LOG=rustc=1 rustc --version
/Users/pnkfelix/opt/rust-dbg/bin/rustc 0.8-pre (dd5c737 2013-09-08 12:05:55 -0700)
host: x86_64-apple-darwin
% RUST_LOG=rustc=1 rustc /tmp/baz.rs
task &lt;unnamed&gt; failed at 'assertion failed: rp.is_none()', /Users/pnkfelix/Dev/Mozilla/rust.git/src/librustc/middle/typeck/collect.rs:1108
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug
note: try running with RUST_LOG=rustc=1 to get further details and report the results to github.com/mozilla/rust/issues
task &lt;unnamed&gt; failed at 'explicit failure', /Users/pnkfelix/Dev/Mozilla/rust.git/src/librustc/rustc.rs:376
</code></pre></div>
<p dir="auto">Compile:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// Example #1
mod mod_a {
    mod sub_a {
        pub struct InnerA;
    }
    pub type A = sub_a::InnerA;
}

use mod_a::A;

fn main() {
    let a=A;
}"><pre class="notranslate"><span class="pl-c">// Example #1</span>
<span class="pl-k">mod</span> mod_a <span class="pl-kos">{</span>
    <span class="pl-k">mod</span> sub_a <span class="pl-kos">{</span>
        <span class="pl-k">pub</span> <span class="pl-k">struct</span> <span class="pl-smi">InnerA</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span>
    <span class="pl-k">pub</span> <span class="pl-k">type</span> <span class="pl-smi">A</span> = sub_a<span class="pl-kos">::</span><span class="pl-smi">InnerA</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">use</span> mod_a<span class="pl-kos">::</span><span class="pl-v">A</span><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> a=<span class="pl-v">A</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="error[E0425]: unresolved name `A`
  --&gt; test.rs:12:11
   |
12 |     let a=A;
   |           ^ unresolved name"><pre class="notranslate"><code class="notranslate">error[E0425]: unresolved name `A`
  --&gt; test.rs:12:11
   |
12 |     let a=A;
   |           ^ unresolved name
</code></pre></div>
<p dir="auto">Yet A is quite obviously imported. The same error appears in a different place when compiling:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// Example #2
mod mod_a {
    mod sub_a {
        pub struct InnerA;
    }
    pub type A = sub_a::InnerA;

    pub fn make_a() -&gt; A {
        A
    }
}

use mod_a::{A,make_a};

fn main() {
    let a: A=make_a();
}"><pre class="notranslate"><span class="pl-c">// Example #2</span>
<span class="pl-k">mod</span> mod_a <span class="pl-kos">{</span>
    <span class="pl-k">mod</span> sub_a <span class="pl-kos">{</span>
        <span class="pl-k">pub</span> <span class="pl-k">struct</span> <span class="pl-smi">InnerA</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span>
    <span class="pl-k">pub</span> <span class="pl-k">type</span> <span class="pl-smi">A</span> = sub_a<span class="pl-kos">::</span><span class="pl-smi">InnerA</span><span class="pl-kos">;</span>

    <span class="pl-k">pub</span> <span class="pl-k">fn</span> <span class="pl-en">make_a</span><span class="pl-kos">(</span><span class="pl-kos">)</span> -&gt; <span class="pl-smi">A</span> <span class="pl-kos">{</span>
        <span class="pl-v">A</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span>

<span class="pl-k">use</span> mod_a<span class="pl-kos">::</span><span class="pl-kos">{</span><span class="pl-v">A</span><span class="pl-kos">,</span>make_a<span class="pl-kos">}</span><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> a<span class="pl-kos">:</span> <span class="pl-smi">A</span>=<span class="pl-en">make_a</span><span class="pl-kos">(</span><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="error[E0425]: unresolved name `A`
 --&gt; test.rs:9:9
  |
9 |         A
  |         ^ unresolved name"><pre class="notranslate"><code class="notranslate">error[E0425]: unresolved name `A`
 --&gt; test.rs:9:9
  |
9 |         A
  |         ^ unresolved name
</code></pre></div>
<p dir="auto">This compiles:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// Example #3
mod mod_a {
    mod sub_a {
        pub struct InnerA;
    }
    pub type A = sub_a::InnerA;

    pub fn make_a() -&gt; A {
        sub_a::InnerA
    }
}

use mod_a::{A,make_a};

fn main() {
    let a: A=make_a();
}"><pre class="notranslate"><span class="pl-c">// Example #3</span>
<span class="pl-k">mod</span> mod_a <span class="pl-kos">{</span>
    <span class="pl-k">mod</span> sub_a <span class="pl-kos">{</span>
        <span class="pl-k">pub</span> <span class="pl-k">struct</span> <span class="pl-smi">InnerA</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span>
    <span class="pl-k">pub</span> <span class="pl-k">type</span> <span class="pl-smi">A</span> = sub_a<span class="pl-kos">::</span><span class="pl-smi">InnerA</span><span class="pl-kos">;</span>

    <span class="pl-k">pub</span> <span class="pl-k">fn</span> <span class="pl-en">make_a</span><span class="pl-kos">(</span><span class="pl-kos">)</span> -&gt; <span class="pl-smi">A</span> <span class="pl-kos">{</span>
        sub_a<span class="pl-kos">::</span><span class="pl-v">InnerA</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span>

<span class="pl-k">use</span> mod_a<span class="pl-kos">::</span><span class="pl-kos">{</span><span class="pl-v">A</span><span class="pl-kos">,</span>make_a<span class="pl-kos">}</span><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> a<span class="pl-kos">:</span> <span class="pl-smi">A</span>=<span class="pl-en">make_a</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">But wait, I thought in example no. 1, we couldn't resolve <code class="notranslate">A</code> from <code class="notranslate">main()</code>?</p>
<p dir="auto">Using <code class="notranslate">pub use</code> instead makes example no. 1 work:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// Example #4
mod mod_a {
    mod sub_a {
        pub struct InnerA;
    }
    pub use self::sub_a::InnerA as A;
}

use mod_a::A;

fn main() {
    let a=A;
}"><pre class="notranslate"><span class="pl-c">// Example #4</span>
<span class="pl-k">mod</span> mod_a <span class="pl-kos">{</span>
    <span class="pl-k">mod</span> sub_a <span class="pl-kos">{</span>
        <span class="pl-k">pub</span> <span class="pl-k">struct</span> <span class="pl-smi">InnerA</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span>
    <span class="pl-k">pub</span> <span class="pl-k">use</span> <span class="pl-k">self</span><span class="pl-kos">::</span>sub_a<span class="pl-kos">::</span><span class="pl-v">InnerA</span> <span class="pl-k">as</span> <span class="pl-v">A</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">use</span> mod_a<span class="pl-kos">::</span><span class="pl-v">A</span><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> a=<span class="pl-v">A</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">For completeness, here is the tuple-struct version:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// Example #5
mod mod_a {
    mod sub_a {
        pub struct InnerA(pub u8);
    }
    pub type A = sub_a::InnerA;
}

use mod_a::A;

fn main() {
    let a=A(0);
}"><pre class="notranslate"><span class="pl-c">// Example #5</span>
<span class="pl-k">mod</span> mod_a <span class="pl-kos">{</span>
    <span class="pl-k">mod</span> sub_a <span class="pl-kos">{</span>
        <span class="pl-k">pub</span> <span class="pl-k">struct</span> <span class="pl-smi">InnerA</span><span class="pl-kos">(</span><span class="pl-k">pub</span> <span class="pl-smi">u8</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span>
    <span class="pl-k">pub</span> <span class="pl-k">type</span> <span class="pl-smi">A</span> = sub_a<span class="pl-kos">::</span><span class="pl-smi">InnerA</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">use</span> mod_a<span class="pl-kos">::</span><span class="pl-v">A</span><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> a=<span class="pl-v">A</span><span class="pl-kos">(</span><span class="pl-c1">0</span><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="error[E0425]: unresolved name `A`
  --&gt; test.rs:12:11
   |
12 |     let a=A(0);
   |           ^ unresolved name"><pre class="notranslate"><code class="notranslate">error[E0425]: unresolved name `A`
  --&gt; test.rs:12:11
   |
12 |     let a=A(0);
   |           ^ unresolved name
</code></pre></div>
<p dir="auto">And the regular struct version (compiles without errors):</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// Example #6
mod mod_a {
    mod sub_a {
        pub struct InnerA {pub i:u8}
    }
    pub type A = sub_a::InnerA;
}

use mod_a::A;

fn main() {
    let a=A{i:0};
}"><pre class="notranslate"><span class="pl-c">// Example #6</span>
<span class="pl-k">mod</span> mod_a <span class="pl-kos">{</span>
    <span class="pl-k">mod</span> sub_a <span class="pl-kos">{</span>
        <span class="pl-k">pub</span> <span class="pl-k">struct</span> <span class="pl-smi">InnerA</span> <span class="pl-kos">{</span><span class="pl-k">pub</span> <span class="pl-c1">i</span><span class="pl-kos">:</span><span class="pl-smi">u8</span><span class="pl-kos">}</span>
    <span class="pl-kos">}</span>
    <span class="pl-k">pub</span> <span class="pl-k">type</span> <span class="pl-smi">A</span> = sub_a<span class="pl-kos">::</span><span class="pl-smi">InnerA</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">use</span> mod_a<span class="pl-kos">::</span><span class="pl-v">A</span><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> a=<span class="pl-smi">A</span><span class="pl-kos">{</span><span class="pl-c1">i</span><span class="pl-kos">:</span><span class="pl-c1">0</span><span class="pl-kos">}</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">It seems like structure <del>expressions</del>constructors are handled differently from other uses of types with regards to aliases. Also, the phrase <code class="notranslate">pub type</code> does not appear in the Rust Book or the Rust Reference.</p>
<p dir="auto">I propose the following:</p>
<ul dir="auto">
<li>Improve the error message in cases 1, 2 and 5 above</li>
<li>Improve documentation on public type aliases</li>
<li>Improve documentation on structure <del>expressions</del>constructors involving type aliases</li>
</ul>