Skip to content

ICE: Explicit deref of non-derefable type: _ #20108

Closed
@oderwat

Description

@oderwat

Following Code "suddenly" (TM) gives a compiler panick:

use std::iter::Iterator;

fn map<T, U, I: Iterator<T>>(fun: |T| -> U, mut iter: I) -> Vec<U> {
    let mut acc = vec![];
    for elt in iter {
        acc.push(fun(elt));
    }
    acc
}

fn main() {
    let x = map(|&x| x + 2, vec![1u,2,3].iter());
    println!("{}", x);
}
RUST_BACKTRACE=1 rustc main.rs
main.rs:12:15: 12:17 error: internal compiler error: Explicit deref of non-derefable type: _
main.rs:12  let x = map(|&x| x + 2, vec![1u,2,3].iter());
                         ^~
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 'Box<Any>', /Users/rustbuild/src/rust-buildbot/slave/nightly-mac/build/src/libsyntax/diagnostic.rs:123

stack backtrace:
   1:        0x10748ec68 - sys::backtrace::write::h2d77a7138a20fe1euut
   2:        0x1074af7c3 - failure::on_fail::h2cc73921e1a3525egKz
   3:        0x10741aeaa - rt::unwind::begin_unwind_inner::h532a687405d73115Hrz
   4:        0x10531bd17 - rt::unwind::begin_unwind::h15459044600925994434
   5:        0x10531bcb0 - rt::unwind::begin_unwind::h15459044600925994434
   6:        0x10479129d - session::Session::span_bug::h716f9146fd05af890mn
   7:        0x104212102 - middle::mem_categorization::MemCategorizationContext<$u{27}t$C$$u{20}TYPER$GT$::cat_pattern::h11154186174841680722
   8:        0x1042022eb - check::regionck::link_pattern::h3d88852e6995969cnte
   9:        0x1041f731d - check::regionck::Rcx<$u{27}a$C$$u{20}$u{27}tcx$GT$::visit_fn_body::h3531a5331ab5d017eRc
  10:        0x1041fd2ae - check::regionck::visit_expr::hb02321dca5467066bgd
  11:        0x104201700 - visit::walk_expr::h3328713682639576950
  12:        0x1041fe1b7 - check::regionck::visit_expr::hb02321dca5467066bgd
  13:        0x1041ff87d - check::regionck::visit_local::hb9b4f9d3743633d9cdd
  14:        0x1041ff975 - visit::walk_block::h8586344471945380718
  15:        0x1041f7349 - check::regionck::Rcx<$u{27}a$C$$u{20}$u{27}tcx$GT$::visit_fn_body::h3531a5331ab5d017eRc
  16:        0x10429aa2b - check::check_bare_fn::h0d1902e379bc0448Vck
  17:        0x104292a13 - check::check_item::h8ef5214e6b2fce2clwk
  18:        0x10450c700 - check_crate::unboxed_closure.43369
  19:        0x104507ead - check_crate::h1dd3d2699b8432207Zy
  20:        0x103c0f1de - driver::phase_3_run_analysis_passes::he4e2174c0e224f23Ita
  21:        0x103bf211e - driver::compile_input::h344438f314911396vba
  22:        0x103d6a9d6 - thunk::F.Invoke<A,$u{20}R$GT$::invoke::h2961138960758151848
  23:        0x103d672d9 - rt::unwind::try::try_fn::h13787826984171194494
  24:        0x107515d29 - rust_try_inner
  25:        0x107515d16 - rust_try
  26:        0x103d679d7 - thunk::F.Invoke<A,$u{20}R$GT$::invoke::h9959509829464533531
  27:        0x10749ec84 - sys::thread::thread_start::h772e1e477575f4beXpw
  28:        0x107d8f2fc - _pthread_body
  29:        0x107d8f279 - _pthread_body
rustc --version --verbose
rustc 0.13.0-nightly (cc19e3380 2014-12-20 20:00:36 +0000)
binary: rustc
commit-hash: cc19e3380b4b7c63b6f1f79d1dfc213ea00e16cf
commit-date: 2014-12-20 20:00:36 +0000
host: x86_64-apple-darwin
release: 0.13.0-nightly

(probably a duplicate but the other code did not look similar to the one here in my eyes)

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions