<p dir="auto">This compiled as of yesterday, but no longer does:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="fn main() {
    let mut foo = ~[];
    'foo: for i in [1, 2, 3].iter() {
        foo.push(i);
    }
}"><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> <span class="pl-k">mut</span> foo = ~<span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
    <span class="pl-c1">'</span>foo<span class="pl-kos">:</span> <span class="pl-k">for</span> i <span class="pl-k">in</span> <span class="pl-kos">[</span><span class="pl-c1">1</span><span class="pl-kos">,</span> <span class="pl-c1">2</span><span class="pl-kos">,</span> <span class="pl-c1">3</span><span class="pl-kos">]</span><span class="pl-kos">.</span><span class="pl-en">iter</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
        foo<span class="pl-kos">.</span><span class="pl-en">push</span><span class="pl-kos">(</span>i<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="test.rs:4:9: 4:12 error: unresolved name `foo`.
test.rs:4         foo.push(i);
                  ^~~
error: aborting due to previous error"><pre class="notranslate"><code class="notranslate">test.rs:4:9: 4:12 error: unresolved name `foo`.
test.rs:4         foo.push(i);
                  ^~~
error: aborting due to previous error
</code></pre></div>
<p dir="auto">Renaming either the label or the variable fixes the error.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="rustc 0.10-pre (329fcd4 2014-02-23 15:37:05 -0800)
host: x86_64-unknown-linux-gnu]"><pre class="notranslate"><code class="notranslate">rustc 0.10-pre (329fcd4 2014-02-23 15:37:05 -0800)
host: x86_64-unknown-linux-gnu]
</code></pre></div>
<p dir="auto">cc <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/edwardw/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/edwardw">@edwardw</a></p>
<p dir="auto">After <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="66251624" data-permission-text="Title is private" data-url="https://github.com/rust-lang/rust/issues/24034" data-hovercard-type="pull_request" data-hovercard-url="/rust-lang/rust/pull/24034/hovercard" href="https://github.com/rust-lang/rust/pull/24034">#24034</a> lands we will be setting <code class="notranslate">CLOEXEC</code> on all file descriptors on unix in the standard library. Currently we do so in a nonatomic fashion, however, so it's possible to continue to leak file descriptors into children if a thread is concurrently forking.</p>
<p dir="auto">Many platforms have methods of creating <code class="notranslate">CLOEXEC</code> file descriptors atomically, but many of the APIs are quite new and they need to be properly detected at runtime. For example, the current instances of <code class="notranslate">fd.set_cloexec()</code> that need to be migrated are listed below. A reminder of our minimum platform requirements are linux 2.6.18 and OSX 10.7.</p>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> <code class="notranslate">File::open</code> - this should specify the <code class="notranslate">O_CLOEXEC</code> flag. This flag was added in linux 2.6.23 and appears to exist on OSX 10.7. <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="102674575" data-permission-text="Title is private" data-url="https://github.com/rust-lang/rust/issues/27971" data-hovercard-type="pull_request" data-hovercard-url="/rust-lang/rust/pull/27971/hovercard" href="https://github.com/rust-lang/rust/pull/27971">#27971</a></li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> <code class="notranslate">Socket::new</code> - this should be specify the <code class="notranslate">SOCK_CLOEXEC</code> flag in the <code class="notranslate">type</code> argument (second). This flag was only added in linux 2.6.27 and does not exist on OSX. <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="131506389" data-permission-text="Title is private" data-url="https://github.com/rust-lang/rust/issues/31417" data-hovercard-type="pull_request" data-hovercard-url="/rust-lang/rust/pull/31417/hovercard" href="https://github.com/rust-lang/rust/pull/31417">#31417</a></li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> <code class="notranslate">Socket::accept</code> - this should be replaced with a call to <code class="notranslate">accept4</code>. This system call was only added in linux 2.6.28 and does not exist on OSX. <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="131506389" data-permission-text="Title is private" data-url="https://github.com/rust-lang/rust/issues/31417" data-hovercard-type="pull_request" data-hovercard-url="/rust-lang/rust/pull/31417/hovercard" href="https://github.com/rust-lang/rust/pull/31417">#31417</a></li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> <code class="notranslate">Socket::duplicate</code> - this should be replaced with <code class="notranslate">dup3</code> (linux 2.6.27, not on OSX) or <code class="notranslate">F_DUPFD_CLOEXEC</code> (linux 2.6.24, appears to exist on OSX 10.7). <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="102874701" data-permission-text="Title is private" data-url="https://github.com/rust-lang/rust/issues/27980" data-hovercard-type="pull_request" data-hovercard-url="/rust-lang/rust/pull/27980/hovercard" href="https://github.com/rust-lang/rust/pull/27980">#27980</a></li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> <code class="notranslate">anon_pipe</code> - this could be replaced with <code class="notranslate">pipe2</code> on linux 2.6.27 and perhaps <code class="notranslate">socketpair</code> on OSX (not confirmed). <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="131506389" data-permission-text="Title is private" data-url="https://github.com/rust-lang/rust/issues/31417" data-hovercard-type="pull_request" data-hovercard-url="/rust-lang/rust/pull/31417/hovercard" href="https://github.com/rust-lang/rust/pull/31417">#31417</a></li>
</ul>
<p dir="auto">The hard part about this bug is figuring out if it's possible to avoid compile-time detection of these functions (and instead rely on runtime detection).</p>