<p dir="auto">I think the impl is just necessary to get Rust to try to instantiate it (otherwise it assumes it's unused).  This may be a duplicate of issue <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="9721437" data-permission-text="Title is private" data-url="https://github.com/rust-lang/rust/issues/4363" data-hovercard-type="issue" data-hovercard-url="/rust-lang/rust/issues/4363/hovercard" href="https://github.com/rust-lang/rust/issues/4363">#4363</a>.</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="use std::sync::Mutex;

struct Foo {
    foo: Mutex&lt;Option&lt;Foo&gt;&gt;,
}

impl Foo {
    fn bar(self) {}
}

fn main() {}"><pre class="notranslate"><span class="pl-k">use</span> std<span class="pl-kos">::</span>sync<span class="pl-kos">::</span><span class="pl-v">Mutex</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">foo</span><span class="pl-kos">:</span> <span class="pl-smi">Mutex</span><span class="pl-kos">&lt;</span><span class="pl-smi">Option</span><span class="pl-kos">&lt;</span><span class="pl-smi">Foo</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-k">impl</span> <span class="pl-smi">Foo</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-smi">self</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>
<hr>
<div class="highlight highlight-text-shell-session notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="task 'rustc' has overflowed its stack"><pre class="notranslate"><span class="pl-c1">task 'rustc' has overflowed its stack</span></pre></div>
<p dir="auto">A struct inside an enum generates a type identifier (as it does outside when used outside an enum).</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="enum S { C {a:int, b:int}};  
enum C {};

t.rs:10:4: 10:13 error: duplicate definition of type `C`
t.rs:10     enum C {};
        ^~~~~~~~~
t.rs:9:13: 9:29 note: first definition of type `C` here
t.rs:9     enum S { C {a:int, b:int}};  
                ^~~~~~~~~~~~~~~~"><pre class="notranslate"><code class="notranslate">enum S { C {a:int, b:int}};  
enum C {};

t.rs:10:4: 10:13 error: duplicate definition of type `C`
t.rs:10     enum C {};
        ^~~~~~~~~
t.rs:9:13: 9:29 note: first definition of type `C` here
t.rs:9     enum S { C {a:int, b:int}};  
                ^~~~~~~~~~~~~~~~
</code></pre></div>
<p dir="auto">In particular the following declaration doesn't typecheck.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="enum S { S {a:int, b:int}}; 

t.rs:6:13: 6:29 error: duplicate definition of type `S`
t.rs:6     enum S { S {a:int, b:int}};  
                    ^~~~~~~~~~~~~~~~
t.rs:6:4: 6:30 note: first definition of type `S` here
t.rs:6     enum S { S {a:int, b:int}};  "><pre class="notranslate"><code class="notranslate">enum S { S {a:int, b:int}}; 

t.rs:6:13: 6:29 error: duplicate definition of type `S`
t.rs:6     enum S { S {a:int, b:int}};  
                    ^~~~~~~~~~~~~~~~
t.rs:6:4: 6:30 note: first definition of type `S` here
t.rs:6     enum S { S {a:int, b:int}};  
</code></pre></div>
<p dir="auto">This is inconsistent with the general case in which such is allowed. E.g., both declarations below type check, despite type and value constructors having the same identifier:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="enum S { S(int, int) }
struct S {a:int, b:int};"><pre class="notranslate"><code class="notranslate">enum S { S(int, int) }
struct S {a:int, b:int};
</code></pre></div>
<p dir="auto">As a sidenote, we can't create values of these generated types even if wished to do so for some reason, since the value constructor associated with the struct field is set to create values of the enum type.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="enum S { C {a:int, b:int} };  
let k : C = C{a:0, b:0};

t.rs:10:12: 10:13 error: found value name used as a type: DefVariant(syntax::ast::DefId{crate: 0, node: 7}, syntax::ast::DefId{crate: 0, node: 14}, true)
t.rs:10     let k : C = C{a:0, b:0};"><pre class="notranslate"><code class="notranslate">enum S { C {a:int, b:int} };  
let k : C = C{a:0, b:0};

t.rs:10:12: 10:13 error: found value name used as a type: DefVariant(syntax::ast::DefId{crate: 0, node: 7}, syntax::ast::DefId{crate: 0, node: 14}, true)
t.rs:10     let k : C = C{a:0, b:0};
</code></pre></div>
<h2 dir="auto"></h2>
<p dir="auto">My tests were performed on v0.8, but the bug was confirmed to be present in 0.9pre. Using Linux, OpenSUSE 13.1</p>