Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: internal compiler error: unexpected panic #26812

Closed
withkittens opened this issue Jul 5, 2015 · 1 comment
Closed

error: internal compiler error: unexpected panic #26812

withkittens opened this issue Jul 5, 2015 · 1 comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@withkittens
Copy link

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

I tried this code:

#![feature(iter_arith)]

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

fn avg<S, T=T::Item>(x: T) -> f64
    where T: IntoIterator<Item=isize> {

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

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

            sum as f64 / count as f64
        }
    }
}

I expected to see this happen: code should compile or the compiler should report an error.

Instead, this happened: the compiler panicked.

Meta

rustc --version --verbose:

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

Backtrace:

   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<'tcx>::type_parameter_def::hda01cc044215acd1rU6
   9:           0xc32659 - check::TupleArgumentsFlag...std..clone..Clone::clone::h1be2a27edcea5bafSDq
  10:           0xbf2459 - check::FnCtxt<'a, 'tcx>::require_type_meets::h64f5de27ee30a606zjp
  11:           0xc714a9 - collect::ast..Generics.GetTypeParameterBounds<'tcx>::get_type_parameter_bounds::h08e9b997e941d802Oxx
  12:           0xc6e276 - collect::ast..Generics.GetTypeParameterBounds<'tcx>::get_type_parameter_bounds::h08e9b997e941d802Oxx
  13:           0xc6519d - collect::ast..Generics.GetTypeParameterBounds<'tcx>::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
@mitaa
Copy link
Contributor

mitaa commented Jul 6, 2015

Reduced test case:

fn avg<T=T::Item>(_: T) {}

@jdm jdm added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jul 6, 2015
arielb1 pushed a commit to arielb1/rust that referenced this issue Jul 6, 2015
astconv is called when converting the type-parameter, which leads to
a crash.

Fixes rust-lang#26812.
bors added a commit that referenced this issue Jul 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

3 participants