Skip to content

Impl trait crash: invalid region in impl Trait: ReEmpty #35668

Closed
@SirVer

Description

@SirVer

This is on MacOS X with rustc 1.12.0-nightly (1deb02ea6 2016-08-12).

This program:

#![feature(conservative_impl_trait)]

fn func<'a, T>(a: &'a [T]) -> impl Iterator<Item=&'a T> {
    a.iter().map(|a| a*a)
}

fn main() {
    let a = (0..30).collect::<Vec<_>>();

    for k in func(&a) {
        println!("{}", k);
    }
}

crashes with

Compiling blub v0.1.0 (file:///private/tmp/blub)
error[E0369]: binary operation `*` cannot be applied to type `&T`
 --> src/main.rs:4:22
  |
4 |     a.iter().map(|a| a*a)
  |                      ^
  |
note: an implementation of `std::ops::Mul` might be missing for `&T`
 --> src/main.rs:4:22
  |
4 |     a.iter().map(|a| a*a)
  |                      ^

error: internal compiler error: ../src/librustc_typeck/check/writeback.rs:343: invalid region in impl Trait: ReEmpty
 --> src/main.rs:3:31
  |
3 | fn func<'a, T>(a: &'a [T]) -> impl Iterator<Item=&'a T> {
  |                               ^^^^^^^^^^^^^^^^^^^^^^^^^

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 'Box<Any>', ../src/librustc_errors/lib.rs:580
stack backtrace:
   1:        0x10b78343e - std::sys::backtrace::tracing::imp::write::h29f5fdb9fc0a7395
   2:        0x10b79258f - std::panicking::default_hook::_{{closure}}::h17d8437f66223ab1
   3:        0x10b790a1d - std::panicking::default_hook::hbbe7fa36a995aca0
   4:        0x10b791136 - std::panicking::rust_panic_with_hook::h105c3d42fcd2fb5e
   5:        0x106dc932b - std::panicking::begin_panic::hccc513334ab977d2
   6:        0x106f24c7d - rustc::session::opt_span_bug_fmt::_{{closure}}::h62b0957667555cfe
   7:        0x106df9959 - rustc::session::span_bug_fmt::hcdfbe9cf944f6fc3
   8:        0x106f1f9f9 - rustc_typeck::check::writeback::WritebackCx::visit_anon_types::_{{closure}}::hc59c3ae4d9a65396
   9:        0x107f3a55d - _<rustc..ty..fold..RegionFolder<'a, 'gcx, 'tcx> as rustc..ty..fold..TypeFolder<'gcx, 'tcx>>::fold_region::hf546bdf998324773
  10:        0x106de1948 - rustc::ty::fold::TypeFolder::fold_substs::h55fbad8fa7647f08
  11:        0x106de2922 - rustc::ty::fold::TypeFolder::fold_ty::hb0362f5378b07a40
  12:        0x106de1b99 - rustc::ty::fold::TypeFolder::fold_substs::h55fbad8fa7647f08
  13:        0x106de2922 - rustc::ty::fold::TypeFolder::fold_ty::hb0362f5378b07a40
  14:        0x106e26e95 - rustc_typeck::check::writeback::_<impl rustc_typeck..check..FnCtxt<'a, 'gcx, 'tcx>>::resolve_type_vars_in_fn::h2c631aecefe427eb
  15:        0x106e8e2b8 - rustc_typeck::check::check_bare_fn::h705fb24e3f39423b
  16:        0x106e92232 - rustc_typeck::check::check_item_body::h26c5d995a8cf2591
  17:        0x106e8af75 - rustc_typeck::check::check_item_bodies::h879e0600ff9f7c52
  18:        0x106f09998 - rustc_typeck::check_crate::h3586447e34ddb139
  19:        0x106bfb53a - rustc_driver::driver::phase_3_run_analysis_passes::_{{closure}}::h7f2cec505064b4bf
  20:        0x106b62372 - rustc::ty::context::TyCtxt::create_and_enter::he5dca3f2a7a0810a
  21:        0x106bc426f - rustc_driver::driver::compile_input::hb4cc34cf85dc1edf
  22:        0x106bec440 - rustc_driver::run_compiler::h50f95674bd902ab5
  23:        0x106b3794e - std::panicking::try::call::h31fc30b58c55d6c3
  24:        0x10b79940a - __rust_maybe_catch_panic
  25:        0x106b51033 - _<F as alloc..boxed..FnBox<A>>::call_box::h24f3eb0b42327962
  26:        0x10b78f7d5 - std::sys::thread::Thread::new::thread_start::h8f3bd45211e9f5ea
  27:     0x7fff82f2599c - _pthread_body
  28:     0x7fff82f25919 - _pthread_start

error: Could not compile `blub`.

To learn more, run the command again with --verbose.

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.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