<p dir="auto">This code:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="fn main() {                                                                                                         
    let _test = main as usize;                                                                                      
}                                                                                                                   "><pre class="notranslate"><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> _test = main <span class="pl-k">as</span> <span class="pl-smi">usize</span><span class="pl-kos">;</span>                                                                                      
<span class="pl-kos">}</span>                                                                                                                   </pre></div>
<p dir="auto">yields this compiler warning:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="foo.rs:1:1: 3:2 warning: function cannot return without recurring, #[warn(unconditional_recursion)] on by default   
foo.rs:1 fn main() {                                                                                                
foo.rs:2     let _test = main as usize;                                                                             
foo.rs:3 }                                                                                                          
foo.rs:2:17: 2:21 note: recursive call site                                                                         
foo.rs:2     let _test = main as usize;                                                                             
                         ^~~~                                                                                       
foo.rs:1:1: 3:2 help: a `loop` may express intention better if this is on purpose                                   "><pre class="notranslate"><code class="notranslate">foo.rs:1:1: 3:2 warning: function cannot return without recurring, #[warn(unconditional_recursion)] on by default   
foo.rs:1 fn main() {                                                                                                
foo.rs:2     let _test = main as usize;                                                                             
foo.rs:3 }                                                                                                          
foo.rs:2:17: 2:21 note: recursive call site                                                                         
foo.rs:2     let _test = main as usize;                                                                             
                         ^~~~                                                                                       
foo.rs:1:1: 3:2 help: a `loop` may express intention better if this is on purpose                                   
</code></pre></div>
<p dir="auto">cc <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/huonw/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/huonw">@huonw</a></p>
<p dir="auto">I think the new unconditional_recursion lint has a bug. For example I get a warning for this code:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="#![allow(unstable)]
fn print_type_of&lt;T&gt;(_: &amp;T) -&gt; () {
    let type_name =
        unsafe {
            (*std::intrinsics::get_tydesc::&lt;T&gt;()).name
        };
    println!(&quot;{}&quot;, type_name);
}

fn main() {
    print_type_of(&amp;main);
}"><pre class="notranslate"><span class="pl-c1">#!<span class="pl-kos">[</span>allow<span class="pl-kos">(</span>unstable<span class="pl-kos">)</span><span class="pl-kos">]</span></span>
<span class="pl-k">fn</span> <span class="pl-en">print_type_of</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">&gt;</span><span class="pl-kos">(</span>_<span class="pl-kos">:</span> <span class="pl-c1">&amp;</span><span class="pl-smi">T</span><span class="pl-kos">)</span> -&gt; <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">let</span> type_name =
        <span class="pl-k">unsafe</span> <span class="pl-kos">{</span>
            <span class="pl-kos">(</span><span class="pl-c1">*</span>std<span class="pl-kos">::</span>intrinsics<span class="pl-kos">::</span><span class="pl-en">get_tydesc</span><span class="pl-kos">::</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</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-c1">name</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">"{}"</span>, type_name<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-en">print_type_of</span><span class="pl-kos">(</span><span class="pl-c1">&amp;</span>main<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="&lt;anon&gt;:10:1: 12:2 warning: function cannot return without recurring, #[warn(unconditional_recursion)] on by default
&lt;anon&gt;:10 fn main() {
&lt;anon&gt;:11     print_type_of(&amp;main);
&lt;anon&gt;:12 }
&lt;anon&gt;:11:20: 11:24 note: recursive call site
&lt;anon&gt;:11     print_type_of(&amp;main);
                             ^~~~
&lt;anon&gt;:10:1: 12:2 help: a `loop` may express intention better if this is on purpose
&lt;anon&gt;:10 fn main() {
&lt;anon&gt;:11     print_type_of(&amp;main);
&lt;anon&gt;:12 }"><pre class="notranslate"><code class="notranslate">&lt;anon&gt;:10:1: 12:2 warning: function cannot return without recurring, #[warn(unconditional_recursion)] on by default
&lt;anon&gt;:10 fn main() {
&lt;anon&gt;:11     print_type_of(&amp;main);
&lt;anon&gt;:12 }
&lt;anon&gt;:11:20: 11:24 note: recursive call site
&lt;anon&gt;:11     print_type_of(&amp;main);
                             ^~~~
&lt;anon&gt;:10:1: 12:2 help: a `loop` may express intention better if this is on purpose
&lt;anon&gt;:10 fn main() {
&lt;anon&gt;:11     print_type_of(&amp;main);
&lt;anon&gt;:12 }
</code></pre></div>
<p dir="auto">rustc 1.0.0-nightly (<a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/rust-lang/rust/commit/458a6a2f6e9dfb6ed3d76f14418ff1f2f5e97f86/hovercard" href="https://github.com/rust-lang/rust/commit/458a6a2f6e9dfb6ed3d76f14418ff1f2f5e97f86"><tt>458a6a2</tt></a> 2015-01-25 21:20:37 +0000)</p>