<p dir="auto"><code class="notranslate">rustc 1.0.0-dev (3614e1de6 2015-01-14 04:42:01 +0000)</code></p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="pub trait Trait where Self::Out: std::fmt::Show {
    type Out;
}"><pre class="notranslate"><span class="pl-k">pub</span> <span class="pl-k">trait</span> <span class="pl-smi">Trait</span> <span class="pl-k">where</span> <span class="pl-smi">Self</span><span class="pl-kos">::</span><span class="pl-smi">Out</span><span class="pl-kos">:</span> std<span class="pl-kos">::</span>fmt<span class="pl-kos">::</span><span class="pl-smi">Show</span> <span class="pl-kos">{</span>
    <span class="pl-k">type</span> <span class="pl-smi">Out</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="thread 'rustc' panicked at 'no entry found for key', /home/tom/src/rust/rust/src/libcore/option.rs:330

stack backtrace:
   1:     0x7f4c3e42ca80 - sys::backtrace::write::ha0aae27c13f1e1e2wRt
   2:     0x7f4c3e44e460 - failure::on_fail::h6467179db076ae40d5z
   3:     0x7f4c3e3bd510 - rt::unwind::begin_unwind_inner::h60ee3cb21c325c186Jz
   4:     0x7f4c3e3be040 - rt::unwind::begin_unwind_fmt::h374483fb441173d8DIz
   5:     0x7f4c3e44e2c0 - rust_begin_unwind
   6:     0x7f4c3e49fb80 - panicking::panic_fmt::h61e6123d33617eebvym
   7:     0x7f4c3dc60570 - astconv::ast_ty_to_ty::unboxed_closure.29412
   8:     0x7f4c3dc12b10 - astconv::ast_ty_to_ty::h1763fcd7e8e2744azSs
   9:     0x7f4c3dc8c960 - collect::ty_generics::he250f27d9578b0d23Vu
  10:     0x7f4c3dc73ac0 - collect::trait_def_of_item::h6774115495711e070wu
  11:     0x7f4c3dc71690 - collect::CollectTraitDefVisitor&lt;'a, 'tcx&gt;.visit..Visitor&lt;'v&gt;::visit_item::he26bc84d696b35decKt
  12:     0x7f4c3dcbc0b0 - check_crate::unboxed_closure.30645
  13:     0x7f4c3dcba0f0 - check_crate::h022f16fd72b6c09dney
  14:     0x7f4c3e986c70 - driver::phase_3_run_analysis_passes::h0ee4fa5e73acbe9cEEa
  15:     0x7f4c3e974a50 - driver::compile_input::hc689346ac2e9c62fAba
  16:     0x7f4c3ea36310 - run_compiler::he89321e2dd531b37e5b
  17:     0x7f4c3ea34a80 - thunk::F.Invoke&lt;A, R&gt;::invoke::h16839135703482139551
  18:     0x7f4c3ea339e0 - rt::unwind::try::try_fn::h363853857083200694
  19:     0x7f4c3e4be130 - rust_try_inner
  20:     0x7f4c3e4be120 - rust_try
  21:     0x7f4c3ea33c90 - thunk::F.Invoke&lt;A, R&gt;::invoke::h16782837970792084443
  22:     0x7f4c3e43c100 - sys::thread::thread_start::h5480a52fb17d8858jJw
  23:     0x7f4c38b73250 - start_thread
  24:     0x7f4c3e06d219 - clone
  25:                0x0 - &lt;unknown&gt;"><pre class="notranslate"><code class="notranslate">thread 'rustc' panicked at 'no entry found for key', /home/tom/src/rust/rust/src/libcore/option.rs:330

stack backtrace:
   1:     0x7f4c3e42ca80 - sys::backtrace::write::ha0aae27c13f1e1e2wRt
   2:     0x7f4c3e44e460 - failure::on_fail::h6467179db076ae40d5z
   3:     0x7f4c3e3bd510 - rt::unwind::begin_unwind_inner::h60ee3cb21c325c186Jz
   4:     0x7f4c3e3be040 - rt::unwind::begin_unwind_fmt::h374483fb441173d8DIz
   5:     0x7f4c3e44e2c0 - rust_begin_unwind
   6:     0x7f4c3e49fb80 - panicking::panic_fmt::h61e6123d33617eebvym
   7:     0x7f4c3dc60570 - astconv::ast_ty_to_ty::unboxed_closure.29412
   8:     0x7f4c3dc12b10 - astconv::ast_ty_to_ty::h1763fcd7e8e2744azSs
   9:     0x7f4c3dc8c960 - collect::ty_generics::he250f27d9578b0d23Vu
  10:     0x7f4c3dc73ac0 - collect::trait_def_of_item::h6774115495711e070wu
  11:     0x7f4c3dc71690 - collect::CollectTraitDefVisitor&lt;'a, 'tcx&gt;.visit..Visitor&lt;'v&gt;::visit_item::he26bc84d696b35decKt
  12:     0x7f4c3dcbc0b0 - check_crate::unboxed_closure.30645
  13:     0x7f4c3dcba0f0 - check_crate::h022f16fd72b6c09dney
  14:     0x7f4c3e986c70 - driver::phase_3_run_analysis_passes::h0ee4fa5e73acbe9cEEa
  15:     0x7f4c3e974a50 - driver::compile_input::hc689346ac2e9c62fAba
  16:     0x7f4c3ea36310 - run_compiler::he89321e2dd531b37e5b
  17:     0x7f4c3ea34a80 - thunk::F.Invoke&lt;A, R&gt;::invoke::h16839135703482139551
  18:     0x7f4c3ea339e0 - rt::unwind::try::try_fn::h363853857083200694
  19:     0x7f4c3e4be130 - rust_try_inner
  20:     0x7f4c3e4be120 - rust_try
  21:     0x7f4c3ea33c90 - thunk::F.Invoke&lt;A, R&gt;::invoke::h16782837970792084443
  22:     0x7f4c3e43c100 - sys::thread::thread_start::h5480a52fb17d8858jJw
  23:     0x7f4c38b73250 - start_thread
  24:     0x7f4c3e06d219 - clone
  25:                0x0 - &lt;unknown&gt;
</code></pre></div>
<p dir="auto">Thought this might be a dupe of <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="52855926" data-permission-text="Title is private" data-url="https://github.com/rust-lang/rust/issues/20220" data-hovercard-type="issue" data-hovercard-url="/rust-lang/rust/issues/20220/hovercard" href="https://github.com/rust-lang/rust/issues/20220">#20220</a> <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="53803486" data-permission-text="Title is private" data-url="https://github.com/rust-lang/rust/issues/20772" data-hovercard-type="issue" data-hovercard-url="/rust-lang/rust/issues/20772/hovercard" href="https://github.com/rust-lang/rust/issues/20772">#20772</a> but I don't think so.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', ../src/libcore\option.rs:362"><pre class="notranslate"><code class="notranslate">error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', ../src/libcore\option.rs:362
</code></pre></div>
<p dir="auto">I tried this code:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="#![feature(iter_arith)]

fn main() {
    println!(&quot;avg1 = {}&quot;, avg::&lt;isize&gt;( (1..11) ));
    println!(&quot;avg1 = {}&quot;, avg::&lt;isize&gt;( (1..11).filter(|&amp;x| x % 2 == 0) ));
}

fn avg&lt;S, T=T::Item&gt;(x: T) -&gt; f64
    where T: IntoIterator&lt;Item=isize&gt; {

    let it = x.into_iter();
    match it.size_hint() {
        (lower, Some(upper)) if lower == upper =&gt; {
            println!(&quot;exact len&quot;);
            it.sum::&lt;S&gt;() as f64 / lower as f64
        }
        _ =&gt; {
            let mut sum = 0;
            let mut count = 0;

            for i in it {
                sum = sum + i;
                count += 1;
            }

            sum as f64 / count as f64
        }
    }
}"><pre class="notranslate"><code class="notranslate">#![feature(iter_arith)]

fn main() {
    println!("avg1 = {}", avg::&lt;isize&gt;( (1..11) ));
    println!("avg1 = {}", avg::&lt;isize&gt;( (1..11).filter(|&amp;x| x % 2 == 0) ));
}

fn avg&lt;S, T=T::Item&gt;(x: T) -&gt; f64
    where T: IntoIterator&lt;Item=isize&gt; {

    let it = x.into_iter();
    match it.size_hint() {
        (lower, Some(upper)) if lower == upper =&gt; {
            println!("exact len");
            it.sum::&lt;S&gt;() as f64 / lower as f64
        }
        _ =&gt; {
            let mut sum = 0;
            let mut count = 0;

            for i in it {
                sum = sum + i;
                count += 1;
            }

            sum as f64 / count as f64
        }
    }
}
</code></pre></div>
<p dir="auto">I expected to see this happen: code should compile or the compiler should report an error.</p>
<p dir="auto">Instead, this happened: the compiler panicked.</p>
<h2 dir="auto">Meta</h2>
<p dir="auto"><code class="notranslate">rustc --version --verbose</code>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="rustc 1.3.0-nightly (cb7d06215 2015-06-26)
binary: rustc
commit-hash: cb7d0621556fabcdcc36d0da279305ad285ec662
commit-date: 2015-06-26
host: x86_64-pc-windows-gnu
release: 1.3.0-nightly"><pre class="notranslate"><code class="notranslate">rustc 1.3.0-nightly (cb7d06215 2015-06-26)
binary: rustc
commit-hash: cb7d0621556fabcdcc36d0da279305ad285ec662
commit-date: 2015-06-26
host: x86_64-pc-windows-gnu
release: 1.3.0-nightly
</code></pre></div>
<p dir="auto">Backtrace:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="   1:         0x61df90f5 - sys::backtrace::write::h025f886ce4157216LAs
   2:         0x61e0289c - rt::unwind::register::h5ad63c24fb31bf08qfw
   3:         0x61dc561f - rt::unwind::begin_unwind_inner::hfc1332db90d09e50zcw
   4:         0x61dc5f9a - rt::unwind::begin_unwind_fmt::ha3ff9e0dc1fa5705Fbw
   5:         0x61e022b3 - rust_begin_unwind
   6:         0x61e1ead9 - panicking::panic_fmt::h9bd2cfb05a12923fH8B
   7:         0x61e19121 - panicking::panic::hacb4eddea015f0f3e7B
   8:         0x62ded9de - middle::ty::ctxt&lt;'tcx&gt;::type_parameter_def::hda01cc044215acd1rU6
   9:           0xc32659 - check::TupleArgumentsFlag...std..clone..Clone::clone::h1be2a27edcea5bafSDq
  10:           0xbf2459 - check::FnCtxt&lt;'a, 'tcx&gt;::require_type_meets::h64f5de27ee30a606zjp
  11:           0xc714a9 - collect::ast..Generics.GetTypeParameterBounds&lt;'tcx&gt;::get_type_parameter_bounds::h08e9b997e941d802Oxx
  12:           0xc6e276 - collect::ast..Generics.GetTypeParameterBounds&lt;'tcx&gt;::get_type_parameter_bounds::h08e9b997e941d802Oxx
  13:           0xc6519d - collect::ast..Generics.GetTypeParameterBounds&lt;'tcx&gt;::get_type_parameter_bounds::h08e9b997e941d802Oxx
  14:           0xc4d100 - collect::AstConvRequest...std..clone..Clone::clone::hcbd1e5932dbd5c05o7w
  15:           0xc4a0a7 - collect::collect_item_types::h832ec93e81779425R0w
  16:           0xc98b72 - check_crate::hc0757b7883cfbf0b08C
  17:         0x71068b49 - driver::assign_node_ids_and_map::h19857398bfcdab684Da
  18:         0x71066f94 - driver::assign_node_ids_and_map::h19857398bfcdab684Da
  19:         0x71061489 - driver::assign_node_ids_and_map::h19857398bfcdab684Da
  20:         0x71042a66 - driver::compile_input::h4f87ae57d3ecc9bdTba
  21:         0x7112483d - run_compiler::h2ed758d21912ca6fx7b
  22:         0x711224c5 - run::h53e8d74dd390297dd7b
  23:         0x71121e09 - run::h53e8d74dd390297dd7b
  24:         0x61e3d54c - rust_try
  25:         0x61e3d529 - rust_try
  26:         0x61ded4c5 - rt::unwind::try::inner_try::hbdd1fe1d49ddad43s8v
  27:         0x71121fc7 - run::h53e8d74dd390297dd7b
  28:         0x61e003f4 - sys::process::Command::cwd::h4194821e987e71efwUu
  29:     0x7ffa49102ef2 - BaseThreadInitThunk"><pre class="notranslate"><code class="notranslate">   1:         0x61df90f5 - sys::backtrace::write::h025f886ce4157216LAs
   2:         0x61e0289c - rt::unwind::register::h5ad63c24fb31bf08qfw
   3:         0x61dc561f - rt::unwind::begin_unwind_inner::hfc1332db90d09e50zcw
   4:         0x61dc5f9a - rt::unwind::begin_unwind_fmt::ha3ff9e0dc1fa5705Fbw
   5:         0x61e022b3 - rust_begin_unwind
   6:         0x61e1ead9 - panicking::panic_fmt::h9bd2cfb05a12923fH8B
   7:         0x61e19121 - panicking::panic::hacb4eddea015f0f3e7B
   8:         0x62ded9de - middle::ty::ctxt&lt;'tcx&gt;::type_parameter_def::hda01cc044215acd1rU6
   9:           0xc32659 - check::TupleArgumentsFlag...std..clone..Clone::clone::h1be2a27edcea5bafSDq
  10:           0xbf2459 - check::FnCtxt&lt;'a, 'tcx&gt;::require_type_meets::h64f5de27ee30a606zjp
  11:           0xc714a9 - collect::ast..Generics.GetTypeParameterBounds&lt;'tcx&gt;::get_type_parameter_bounds::h08e9b997e941d802Oxx
  12:           0xc6e276 - collect::ast..Generics.GetTypeParameterBounds&lt;'tcx&gt;::get_type_parameter_bounds::h08e9b997e941d802Oxx
  13:           0xc6519d - collect::ast..Generics.GetTypeParameterBounds&lt;'tcx&gt;::get_type_parameter_bounds::h08e9b997e941d802Oxx
  14:           0xc4d100 - collect::AstConvRequest...std..clone..Clone::clone::hcbd1e5932dbd5c05o7w
  15:           0xc4a0a7 - collect::collect_item_types::h832ec93e81779425R0w
  16:           0xc98b72 - check_crate::hc0757b7883cfbf0b08C
  17:         0x71068b49 - driver::assign_node_ids_and_map::h19857398bfcdab684Da
  18:         0x71066f94 - driver::assign_node_ids_and_map::h19857398bfcdab684Da
  19:         0x71061489 - driver::assign_node_ids_and_map::h19857398bfcdab684Da
  20:         0x71042a66 - driver::compile_input::h4f87ae57d3ecc9bdTba
  21:         0x7112483d - run_compiler::h2ed758d21912ca6fx7b
  22:         0x711224c5 - run::h53e8d74dd390297dd7b
  23:         0x71121e09 - run::h53e8d74dd390297dd7b
  24:         0x61e3d54c - rust_try
  25:         0x61e3d529 - rust_try
  26:         0x61ded4c5 - rt::unwind::try::inner_try::hbdd1fe1d49ddad43s8v
  27:         0x71121fc7 - run::h53e8d74dd390297dd7b
  28:         0x61e003f4 - sys::process::Command::cwd::h4194821e987e71efwUu
  29:     0x7ffa49102ef2 - BaseThreadInitThunk
</code></pre></div>