<p dir="auto">I was randomly seeing benchmarks report 0 ns/iter and had no idea why until <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/alexcrichton/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/alexcrichton">@alexcrichton</a> clued me in on the 1ms limit per iter. I'd like to add a warning when the initial iteration takes longer than 1ms so the user knows why the benchmark is "failing". Instead of just reporting 0 ns/iter.</p>
<p dir="auto">I've got a question on the intent of part of the code before I continue trying to make this change.</p>
<p dir="auto"><a href="https://github.com/mozilla/rust/blob/master/src/libextra/test.rs#L1060">https://github.com/mozilla/rust/blob/master/src/libextra/test.rs#L1060</a></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="        if self.ns_per_iter() == 0 {
            n = 1_000_000;
        } else {
            n = 1_000_000 / self.ns_per_iter().max(&amp;1);
        }"><pre class="notranslate"><code class="notranslate">        if self.ns_per_iter() == 0 {
            n = 1_000_000;
        } else {
            n = 1_000_000 / self.ns_per_iter().max(&amp;1);
        }
</code></pre></div>
<p dir="auto">The .max(&amp;1) seems needless because self.ns_per_iter can only return positive integers and it was just checked for 0. I'm wondering if the line should actually be:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="n = (1_000_000 / self.ns_per_iter()).max(&amp;1);"><pre class="notranslate"><code class="notranslate">n = (1_000_000 / self.ns_per_iter()).max(&amp;1);
</code></pre></div>
<p dir="auto">To guarantee at least one iteration is run. If zero iterations is fine, then I'd like to add a check for that and print a warning instead.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Compiling hyper v0.1.1 (file:///home/manishearth/Mozilla/Git/hyper)
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'assertion failed: !generic_bounds.has_escaping_regions()', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/librustc_typeck/check/mod.rs:2281"><pre class="notranslate"><code class="notranslate">Compiling hyper v0.1.1 (file:///home/manishearth/Mozilla/Git/hyper)
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'assertion failed: !generic_bounds.has_escaping_regions()', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/librustc_typeck/check/mod.rs:2281
</code></pre></div>
<p dir="auto">I was trying to use unboxed closures in Hyper, and I came across this.</p>
<p dir="auto"><a href="https://github.com/Manishearth/hyper/commit/69d3aeba1f1793aed3a1b42b3180f6fe293e9135">Here</a>'s the commit where it got introduced.</p>
<p dir="auto">The following MWE also causes the ICE:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="#![feature(unboxed_closures)]

pub struct HttpConnector&lt;T = NoSslVerify&gt;(Option&lt;T&gt;);
pub struct NoSslVerify;

impl Fn(&amp;mut u8) -&gt; () for NoSslVerify {
    #[inline(always)]
    fn call(&amp;self, _: (&amp;mut u8)) {}
}"><pre class="notranslate"><code class="notranslate">#![feature(unboxed_closures)]

pub struct HttpConnector&lt;T = NoSslVerify&gt;(Option&lt;T&gt;);
pub struct NoSslVerify;

impl Fn(&amp;mut u8) -&gt; () for NoSslVerify {
    #[inline(always)]
    fn call(&amp;self, _: (&amp;mut u8)) {}
}
</code></pre></div>