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

ICE with type error and impl Fn #36287

Closed
pthariensflame opened this issue Sep 5, 2016 · 1 comment
Closed

ICE with type error and impl Fn #36287

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

Comments

@pthariensflame
Copy link
Contributor

pthariensflame commented Sep 5, 2016

Using the conservative_impl_trait feature with the Fn traits seems to create an ICE when there’s a type error.

The following code (also available on the Playground here):

#![crate_type = "lib"]
#![feature(conservative_impl_trait)]

pub fn partial_apply<A, B, C, F>(f: F, x: A) -> impl FnOnce(B) -> C
    where F: FnOnce(A, B) -> C
{
    &|y| f(x, y)
}

causes the following compiler output:

thread 'rustc' panicked at 'Box<Any>', ../src/librustc_errors/lib.rs:590
note: Run with `RUST_BACKTRACE=1` for a backtrace.

error[E0525]: expected a closure that implements the `Fn` trait, but this closure only implements `FnOnce`
 --> test.rs:7:6
  |
7 |     &|y| f(x, y)
  |      ^^^^^^^^^^^
  |
note: the requirement to implement `Fn` derives from here
 --> test.rs:4:49
  |
4 | pub fn partial_apply<A, B, C, F>(f: F, x: A) -> impl FnOnce(B) -> C
  |                                                 ^^^^^^^^^^^^^^^^^^^

error: internal compiler error: ../src/librustc_typeck/check/writeback.rs:347: invalid region in impl Trait: ReEmpty
 --> test.rs:4:49
  |
4 | pub fn partial_apply<A, B, C, F>(f: F, x: A) -> impl FnOnce(B) -> C
  |                                                 ^^^^^^^^^^^^^^^^^^^

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

Obviously, the error message is correct, if somewhat hard to decipher. The ICE is worrying, however.

Backtrace:

thread 'rustc' panicked at 'Box<Any>', ../src/librustc_errors/lib.rs:590
stack backtrace:
   1:        0x10897757a - std::sys::backtrace::tracing::imp::write::h46f28e67d38b4637
   2:        0x108985c7f - std::panicking::default_hook::{{closure}}::h1d3243f546573ff4
   3:        0x10898431d - std::panicking::default_hook::h96c288d728df3ebf
   4:        0x1089849b6 - std::panicking::rust_panic_with_hook::hb1322e5f2588b4db
   5:        0x10441551b - std::panicking::begin_panic::hb7c71bbc491f561c
   6:        0x104547813 - rustc::session::opt_span_bug_fmt::{{closure}}::h0a2486f2fff54208
   7:        0x10445e1a9 - rustc::session::span_bug_fmt::heb3fdb6acac8d0c7
   8:        0x104546455 - rustc_typeck::check::writeback::WritebackCx::visit_anon_types::{{closure}}::hfd3c46aef9bd9a7d
   9:        0x10542670c - <rustc::ty::fold::RegionFolder<'a, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_region::h331824092188ef10
  10:        0x1044326ce - rustc::ty::fold::TypeFolder::fold_ty::hb7dbb94e06be626a
  11:        0x10448ccb5 - rustc_typeck::check::writeback::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::resolve_type_vars_in_fn::hceb857dfd8fca940
  12:        0x1044e0d3d - rustc_typeck::check::check_bare_fn::haa7199476c92e826
  13:        0x1044e3f55 - rustc_typeck::check::check_item_body::h4df24fa6569eb6cd
  14:        0x1044de6e7 - rustc_typeck::check::check_item_bodies::h2e489dd76c967c43
  15:        0x104544457 - rustc_typeck::check_crate::h279dc52e9bc1b4c2
  16:        0x10431fdfc - rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}::h2b062b0c671cd504
  17:        0x1042f6c14 - rustc_driver::driver::phase_3_run_analysis_passes::h2f1bd27ff2e4d8a0
  18:        0x1042e9836 - rustc_driver::driver::compile_input::h7dacd98cd2fd7d2b
  19:        0x104312778 - rustc_driver::run_compiler::h37c4294ab73436f7
  20:        0x104257170 - std::panicking::try::do_call::h4d040997e2efdaf3
  21:        0x10898c85a - __rust_maybe_catch_panic
  22:        0x104275164 - <F as alloc::boxed::FnBox<A>>::call_box::hefd1c85fab3e6c31
  23:        0x108983194 - std::sys::thread::Thread::new::thread_start::h5b631f48cd23f128
  24:     0x7fffb0456aba - _pthread_body
  25:     0x7fffb0456a06 - _pthread_start

rustc version:

rustc 1.13.0-nightly (91f057de3 2016-09-04)
binary: rustc
commit-hash: 91f057de35066d0a34102bd0673b56684509b93d
commit-date: 2016-09-04
host: x86_64-apple-darwin
release: 1.13.0-nightly
@Aatch Aatch added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Sep 5, 2016
@eddyb
Copy link
Member

eddyb commented Sep 6, 2016

Duplicate of #35668. Easy to ignore if you someone else wants to poke it.

@eddyb eddyb closed this as completed Sep 6, 2016
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