<p dir="auto">Right now we need to cast to floats in order to print them out.</p>
<p dir="auto">This code I used to compile fine with a version of Rust that was about 9 days old. All the comments in the code have been there before, now the code fails to compile at the lines <code class="notranslate">assert_eq!(Foo::id(), "FOO");</code> and <code class="notranslate">assert_eq!(Bar::id(), "BAR");</code>:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="#[test]
fn type_aliases() {
    struct Foo {
        a: u32,
    };
    impl Foo {
        fn bark(&amp;self) {
            println!(&quot;Wuff {}&quot;, self.a);
        }

        fn id() -&gt; &amp;'static str {
            &quot;FOO&quot;
        }
    }
    assert_eq!(Foo::id(), &quot;FOO&quot;);
    let f = Foo { a: 1 };
    f.bark();

    type Bar = Foo;
    // assert_eq!(!Bar::id(), &quot;FOO&quot;);
    // error: unresolved name `Bar::id`
    // tests/lang.rs:628     assert_eq!(!Bar::id(), &quot;FOO&quot;);
    let b = Bar { a: 2 };
    b.bark(); // this works though

    impl Bar {
        // This would add a similarly named implementation, that is difficult to call
        // due to ambiguity.
        // Interestingly, it also affects Foo, as well as Bar !!
        // fn bark(&amp;self) {
        //     println!(&quot;Grrrr {}&quot;, self.a);
        // }

        fn id() -&gt; &amp;'static str {
            &quot;BAR&quot;
        }   
    }
    // b.bark(); // or f.bark();
    // error: multiple applicable methods in scope [E0034]
    // tests/lang.rs:625     f.bark();
    //                         ^~~~~~
    // tests/lang.rs:615:9: 617:10 note: candidate #1 is defined in an impl for the type `type_aliases::Foo`
    // tests/lang.rs:615         fn bark(&amp;self) {
    // tests/lang.rs:616             println!(&quot;Wuff {}&quot;, self.a);
    // tests/lang.rs:617         }
    // tests/lang.rs:637:9: 639:10 note: candidate #2 is defined in an impl for the type `type_aliases::Foo`
    // tests/lang.rs:637         fn bark(&amp;self) {
    // tests/lang.rs:638             println!(&quot;Grrrr {}&quot;, self.a);
    assert_eq!(Bar::id(), &quot;BAR&quot;);
}"><pre class="notranslate"><span class="pl-c1">#<span class="pl-kos">[</span>test<span class="pl-kos">]</span></span>
<span class="pl-k">fn</span> <span class="pl-en">type_aliases</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">struct</span> <span class="pl-smi">Foo</span> <span class="pl-kos">{</span>
        <span class="pl-c1">a</span><span class="pl-kos">:</span> <span class="pl-smi">u32</span><span class="pl-kos">,</span>
    <span class="pl-kos">}</span><span class="pl-kos">;</span>
    <span class="pl-k">impl</span> <span class="pl-smi">Foo</span> <span class="pl-kos">{</span>
        <span class="pl-k">fn</span> <span class="pl-en">bark</span><span class="pl-kos">(</span><span class="pl-c1">&amp;</span><span class="pl-smi">self</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
            <span class="pl-en">println</span><span class="pl-en">!</span><span class="pl-kos">(</span><span class="pl-s">"Wuff {}"</span>, <span class="pl-smi">self</span>.a<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">id</span><span class="pl-kos">(</span><span class="pl-kos">)</span> -&gt; <span class="pl-c1">&amp;</span><span class="pl-c1">'</span><span class="pl-ent">static</span> <span class="pl-smi">str</span> <span class="pl-kos">{</span>
            <span class="pl-s">"FOO"</span>
        <span class="pl-kos">}</span>
    <span class="pl-kos">}</span>
    <span class="pl-en">assert_eq</span><span class="pl-en">!</span><span class="pl-kos">(</span><span class="pl-v">Foo</span>::id<span class="pl-kos">(</span><span class="pl-kos">)</span>, <span class="pl-s">"FOO"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-k">let</span> f = <span class="pl-smi">Foo</span> <span class="pl-kos">{</span> <span class="pl-c1">a</span><span class="pl-kos">:</span> <span class="pl-c1">1</span> <span class="pl-kos">}</span><span class="pl-kos">;</span>
    f<span class="pl-kos">.</span><span class="pl-en">bark</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-k">type</span> <span class="pl-smi">Bar</span> = <span class="pl-smi">Foo</span><span class="pl-kos">;</span>
    <span class="pl-c">// assert_eq!(!Bar::id(), "FOO");</span>
    <span class="pl-c">// error: unresolved name `Bar::id`</span>
    <span class="pl-c">// tests/lang.rs:628     assert_eq!(!Bar::id(), "FOO");</span>
    <span class="pl-k">let</span> b = <span class="pl-smi">Bar</span> <span class="pl-kos">{</span> <span class="pl-c1">a</span><span class="pl-kos">:</span> <span class="pl-c1">2</span> <span class="pl-kos">}</span><span class="pl-kos">;</span>
    b<span class="pl-kos">.</span><span class="pl-en">bark</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// this works though</span>

    <span class="pl-k">impl</span> <span class="pl-smi">Bar</span> <span class="pl-kos">{</span>
        <span class="pl-c">// This would add a similarly named implementation, that is difficult to call</span>
        <span class="pl-c">// due to ambiguity.</span>
        <span class="pl-c">// Interestingly, it also affects Foo, as well as Bar !!</span>
        <span class="pl-c">// fn bark(&amp;self) {</span>
        <span class="pl-c">//     println!("Grrrr {}", self.a);</span>
        <span class="pl-c">// }</span>

        <span class="pl-k">fn</span> <span class="pl-en">id</span><span class="pl-kos">(</span><span class="pl-kos">)</span> -&gt; <span class="pl-c1">&amp;</span><span class="pl-c1">'</span><span class="pl-ent">static</span> <span class="pl-smi">str</span> <span class="pl-kos">{</span>
            <span class="pl-s">"BAR"</span>
        <span class="pl-kos">}</span>   
    <span class="pl-kos">}</span>
    <span class="pl-c">// b.bark(); // or f.bark();</span>
    <span class="pl-c">// error: multiple applicable methods in scope [E0034]</span>
    <span class="pl-c">// tests/lang.rs:625     f.bark();</span>
    <span class="pl-c">//                         ^~~~~~</span>
    <span class="pl-c">// tests/lang.rs:615:9: 617:10 note: candidate #1 is defined in an impl for the type `type_aliases::Foo`</span>
    <span class="pl-c">// tests/lang.rs:615         fn bark(&amp;self) {</span>
    <span class="pl-c">// tests/lang.rs:616             println!("Wuff {}", self.a);</span>
    <span class="pl-c">// tests/lang.rs:617         }</span>
    <span class="pl-c">// tests/lang.rs:637:9: 639:10 note: candidate #2 is defined in an impl for the type `type_aliases::Foo`</span>
    <span class="pl-c">// tests/lang.rs:637         fn bark(&amp;self) {</span>
    <span class="pl-c">// tests/lang.rs:638             println!("Grrrr {}", self.a);</span>
    <span class="pl-en">assert_eq</span><span class="pl-en">!</span><span class="pl-kos">(</span><span class="pl-v">Bar</span>::id<span class="pl-kos">(</span><span class="pl-kos">)</span>, <span class="pl-s">"BAR"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">When compiling this now, I get this error, which seems wrong as <code class="notranslate">Bar</code> affects <code class="notranslate">Foo</code>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="tests/lang.rs:636:16: 636:23 error: multiple applicable methods in scope [E0034]
tests/lang.rs:636     assert_eq!(Foo::id(), &quot;FOO&quot;);
                                 ^~~~~~~
&lt;std macros&gt;:1:1: 9:39 note: in expansion of assert_eq!
tests/lang.rs:636:5: 636:34 note: expansion site
tests/lang.rs:632:9: 634:10 note: candidate #1 is defined in an impl for the type `type_aliases::Foo`
tests/lang.rs:632         fn id() -&gt; &amp;'static str {
tests/lang.rs:633             &quot;FOO&quot;
tests/lang.rs:634         }
tests/lang.rs:655:9: 657:10 note: candidate #2 is defined in an impl for the type `type_aliases::Foo`
tests/lang.rs:655         fn id() -&gt; &amp;'static str {
tests/lang.rs:656             &quot;BAR&quot;
tests/lang.rs:657         }
&lt;std macros&gt;:5:10: 5:20 error: the type of this value must be known in this context
&lt;std macros&gt;:5 if ! ( ( * left_val == * right_val ) &amp;&amp; ( * right_val == * left_val ) ) {
                        ^~~~~~~~~~
&lt;std macros&gt;:1:1: 9:39 note: in expansion of assert_eq!
tests/lang.rs:636:5: 636:34 note: expansion site
&lt;std macros&gt;:5:24: 5:35 error: the type of this value must be known in this context
&lt;std macros&gt;:5 if ! ( ( * left_val == * right_val ) &amp;&amp; ( * right_val == * left_val ) ) {
                                      ^~~~~~~~~~~
&lt;std macros&gt;:1:1: 9:39 note: in expansion of assert_eq!
tests/lang.rs:636:5: 636:34 note: expansion site
tests/lang.rs:670:16: 670:23 error: multiple applicable methods in scope [E0034]
tests/lang.rs:670     assert_eq!(Bar::id(), &quot;BAR&quot;);
                                 ^~~~~~~
&lt;std macros&gt;:1:1: 9:39 note: in expansion of assert_eq!
tests/lang.rs:670:5: 670:34 note: expansion site
tests/lang.rs:632:9: 634:10 note: candidate #1 is defined in an impl for the type `type_aliases::Foo`
tests/lang.rs:632         fn id() -&gt; &amp;'static str {
tests/lang.rs:633             &quot;FOO&quot;
tests/lang.rs:634         }
tests/lang.rs:655:9: 657:10 note: candidate #2 is defined in an impl for the type `type_aliases::Foo`
tests/lang.rs:655         fn id() -&gt; &amp;'static str {
tests/lang.rs:656             &quot;BAR&quot;
tests/lang.rs:657         }
&lt;std macros&gt;:5:10: 5:20 error: the type of this value must be known in this context
&lt;std macros&gt;:5 if ! ( ( * left_val == * right_val ) &amp;&amp; ( * right_val == * left_val ) ) {
                        ^~~~~~~~~~
&lt;std macros&gt;:1:1: 9:39 note: in expansion of assert_eq!
tests/lang.rs:670:5: 670:34 note: expansion site
&lt;std macros&gt;:5:24: 5:35 error: the type of this value must be known in this context
&lt;std macros&gt;:5 if ! ( ( * left_val == * right_val ) &amp;&amp; ( * right_val == * left_val ) ) {
                                      ^~~~~~~~~~~
&lt;std macros&gt;:1:1: 9:39 note: in expansion of assert_eq!
tests/lang.rs:670:5: 670:34 note: expansion site"><pre class="notranslate"><code class="notranslate">tests/lang.rs:636:16: 636:23 error: multiple applicable methods in scope [E0034]
tests/lang.rs:636     assert_eq!(Foo::id(), "FOO");
                                 ^~~~~~~
&lt;std macros&gt;:1:1: 9:39 note: in expansion of assert_eq!
tests/lang.rs:636:5: 636:34 note: expansion site
tests/lang.rs:632:9: 634:10 note: candidate #1 is defined in an impl for the type `type_aliases::Foo`
tests/lang.rs:632         fn id() -&gt; &amp;'static str {
tests/lang.rs:633             "FOO"
tests/lang.rs:634         }
tests/lang.rs:655:9: 657:10 note: candidate #2 is defined in an impl for the type `type_aliases::Foo`
tests/lang.rs:655         fn id() -&gt; &amp;'static str {
tests/lang.rs:656             "BAR"
tests/lang.rs:657         }
&lt;std macros&gt;:5:10: 5:20 error: the type of this value must be known in this context
&lt;std macros&gt;:5 if ! ( ( * left_val == * right_val ) &amp;&amp; ( * right_val == * left_val ) ) {
                        ^~~~~~~~~~
&lt;std macros&gt;:1:1: 9:39 note: in expansion of assert_eq!
tests/lang.rs:636:5: 636:34 note: expansion site
&lt;std macros&gt;:5:24: 5:35 error: the type of this value must be known in this context
&lt;std macros&gt;:5 if ! ( ( * left_val == * right_val ) &amp;&amp; ( * right_val == * left_val ) ) {
                                      ^~~~~~~~~~~
&lt;std macros&gt;:1:1: 9:39 note: in expansion of assert_eq!
tests/lang.rs:636:5: 636:34 note: expansion site
tests/lang.rs:670:16: 670:23 error: multiple applicable methods in scope [E0034]
tests/lang.rs:670     assert_eq!(Bar::id(), "BAR");
                                 ^~~~~~~
&lt;std macros&gt;:1:1: 9:39 note: in expansion of assert_eq!
tests/lang.rs:670:5: 670:34 note: expansion site
tests/lang.rs:632:9: 634:10 note: candidate #1 is defined in an impl for the type `type_aliases::Foo`
tests/lang.rs:632         fn id() -&gt; &amp;'static str {
tests/lang.rs:633             "FOO"
tests/lang.rs:634         }
tests/lang.rs:655:9: 657:10 note: candidate #2 is defined in an impl for the type `type_aliases::Foo`
tests/lang.rs:655         fn id() -&gt; &amp;'static str {
tests/lang.rs:656             "BAR"
tests/lang.rs:657         }
&lt;std macros&gt;:5:10: 5:20 error: the type of this value must be known in this context
&lt;std macros&gt;:5 if ! ( ( * left_val == * right_val ) &amp;&amp; ( * right_val == * left_val ) ) {
                        ^~~~~~~~~~
&lt;std macros&gt;:1:1: 9:39 note: in expansion of assert_eq!
tests/lang.rs:670:5: 670:34 note: expansion site
&lt;std macros&gt;:5:24: 5:35 error: the type of this value must be known in this context
&lt;std macros&gt;:5 if ! ( ( * left_val == * right_val ) &amp;&amp; ( * right_val == * left_val ) ) {
                                      ^~~~~~~~~~~
&lt;std macros&gt;:1:1: 9:39 note: in expansion of assert_eq!
tests/lang.rs:670:5: 670:34 note: expansion site
</code></pre></div>
<p dir="auto">Even if this is now desired, I think the compiler message could be improved - it looks similar for the two candidates, and if it wasn't for the code shown below it, I would look like it means the same thing.</p>
<h3 dir="auto">Meta</h3>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$ rustc --verbose --version
rustc 1.0.0-nightly (4db0b3246 2015-02-25) (built 2015-02-25)
binary: rustc
commit-hash: 4db0b32467535d718d6474de7ae8d1007d900818
commit-date: 2015-02-25
build-date: 2015-02-25
host: x86_64-apple-darwin
release: 1.0.0-nightly"><pre class="notranslate">$ rustc --verbose --version
rustc 1.0.0-nightly (4db0b3246 2015-02-25) (built 2015-02-25)
binary: rustc
commit-hash: 4db0b32467535d718d6474de7ae8d1007d900818
commit-date: 2015-02-25
build-date: 2015-02-25
host: x86_64-apple-darwin
release: 1.0.0-nightly</pre></div>