Skip to content

rustc panicked at assertion failed !ty::type_needs_infer #18919

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

Closed
pavelonline opened this issue Nov 13, 2014 · 1 comment
Closed

rustc panicked at assertion failed !ty::type_needs_infer #18919

pavelonline opened this issue Nov 13, 2014 · 1 comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@pavelonline
Copy link

I've found compiler problem with this code:
(test1.rs)

type FuncType<'f> = |&int|: 'f -> int;

fn ho_func(f: &mut Option<FuncType>) {
    match f {
        &Some(ref mut f) => {(*f)(&1);},
        &None => {}
    }
}

fn caller() {
    ho_func(&Some(|x| { 1 }));
}

Here is error:

env RUST_BACKTRACE=1 rustc --crate-type=lib test1.rs 
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
task 'rustc' panicked at 'assertion failed: !ty::type_needs_infer(ty)', /build/buildd/rust-nightly-201411130408~5745e41~trusty/src/librustc/middle/typeck/mod.rs:287

stack backtrace:
   1:     0x7f577775f180 - rt::backtrace::imp::write::h81d5702c49ce4aebmft
   2:     0x7f5777762200 - <unknown>
   3:     0x7f5777f1cb20 - unwind::begin_unwind_inner::hb1c8c16ad8e7226bE9c
   4:     0x7f57782e93c0 - <unknown>
   5:     0x7f57787bd2f0 - middle::typeck::write_ty_to_tcx::hefe138265214f77327o
   6:     0x7f57787b9920 - <unknown>
   7:     0x7f57787b7e50 - middle::typeck::check::writeback::WritebackCx<'cx, 'tcx>.Visitor<'v>::visit_expr::h87248c770d7445b37zO
   8:     0x7f57787b7e50 - middle::typeck::check::writeback::WritebackCx<'cx, 'tcx>.Visitor<'v>::visit_expr::h87248c770d7445b37zO
   9:     0x7f57787bc880 - <unknown>
  10:     0x7f57787b9690 - middle::typeck::check::writeback::resolve_type_vars_in_fn::h4486f5367281e52cdvO
  11:     0x7f577880f7c0 - <unknown>
  12:     0x7f577880b8d0 - middle::typeck::check::check_item::hf54795e833d56931FoW
  13:     0x7f577880f580 - middle::typeck::check::check_item_types::h8d2de38462aae35fG3V
  14:     0x7f5778305570 - <unknown>
  15:     0x7f5778b331c0 - middle::typeck::check_crate::hebc5712fc1ce4f98yqp
  16:     0x7f5778b9b920 - driver::driver::phase_3_run_analysis_passes::h2cf4a6b5389ca85dH9B
  17:     0x7f5778b967b0 - driver::driver::compile_input::ha5985a7132f80281sQB
  18:     0x7f5778c1dc80 - <unknown>
  19:     0x7f5778c1db70 - <unknown>
  20:     0x7f577831ed50 - <unknown>
  21:     0x7f577831eb40 - <unknown>
  22:     0x7f5779476a50 - <unknown>
  23:     0x7f5777f71aa0 - <unknown>
  24:     0x7f5777f71a90 - rust_try
  25:     0x7f5777f1a4a0 - unwind::try::hc67b053bd2fd85bdmYc
  26:     0x7f5777f1a330 - task::Task::run::hc35eeb0af3f2ee13u4b
  27:     0x7f5779476790 - <unknown>
  28:     0x7f5777f1bb40 - <unknown>
  29:     0x7f5773096fe0 - start_thread
  30:     0x7f5777bedc99 - __clone
  31:                0x0 - <unknown>

Version:

rustc --version=verbose
rustc 0.13.0-dev
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 0.13.0-dev
@huonw huonw added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Nov 13, 2014
@ghost ghost mentioned this issue Nov 18, 2014
@ghost ghost added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Mar 12, 2015
@ghost
Copy link

ghost commented Mar 12, 2015

type FuncType<'f> = Fn(&isize) -> isize + 'f;

fn ho_func(f: &mut Option<FuncType>) {
    match f {
        &Some(ref mut f) => {(*f)(&1);},
        &None => {}
    }
}

fn caller() {
    ho_func(&Some(|x| { 1 }));
}

fn main() {}
test.rs:3:1: 8:2 error: the trait `core::marker::Sized` is not implemented for the type `for<'r> core::ops::Fn(&'r isize) -> isize` [E0277]
test.rs:3 fn ho_func(f: &mut Option<FuncType>) {
test.rs:4     match f {
test.rs:5         &Some(ref mut f) => {(*f)(&1);},
test.rs:6         &None => {}
test.rs:7     }
test.rs:8 }
test.rs:3:1: 8:2 note: `for<'r> core::ops::Fn(&'r isize) -> isize` does not have a constant size known at compile-time
test.rs:3 fn ho_func(f: &mut Option<FuncType>) {
test.rs:4     match f {
test.rs:5         &Some(ref mut f) => {(*f)(&1);},
test.rs:6         &None => {}
test.rs:7     }
test.rs:8 }

@bors bors closed this as completed in b9f5711 Mar 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

2 participants