Skip to content

ICE trying to port to new ops::Fn with trait-parametrized impl #23827

Closed
@rsaarelm

Description

@rsaarelm

Script to reproduce:

#!/bin/bash

cat > /tmp/fn_ice.rs << EOF
#![feature(core, unboxed_closures)]

pub struct Prototype {
    pub target: u32
}

trait Component {
    fn apply(self, e: u32);
}

impl<C: Component> Fn<(C,)> for Prototype {
    extern "rust-call" fn call(&self, (comp,): (C,)) -> Prototype {
        comp.apply(self.target);
        *self
    }
}

impl<C: Component> FnMut<(C,)> for Prototype {
    extern "rust-call" fn call_mut(&mut self, (comp,): (C,)) -> Prototype {
        Fn::call(*&self, (comp,))
    }
}

impl<C: Component> FnOnce<(C,)> for Prototype {
    extern "rust-call" fn call_once(self, (comp,): (C,)) -> Prototype {
        Fn::call(&self, (comp,))
    }
}

fn main() {}
EOF

RUST_BACKTRACE=1 rustc /tmp/fn_ice.rs
rustc --version

Output:

/tmp/fn_ice.rs:20:9: 20:34 error: internal compiler error: cat_expr Errd
/tmp/fn_ice.rs:20         Fn::call(*&self, (comp,))
                          ^~~~~~~~~~~~~~~~~~~~~~~~~
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>', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:130

stack backtrace:
   1:     0x7fded6be1af9 - sys::backtrace::write::h8fb4e343117fc1c5HyD
   2:     0x7fded6c09718 - panicking::on_panic::h93647013dcbd3994ZOJ
   3:     0x7fded6b3d803 - rt::unwind::begin_unwind_inner::hd1fc6b2d31010710GuJ
   4:     0x7fded3ff706d - rt::unwind::begin_unwind::h8658016321657282922
   5:     0x7fded3ff7013 - diagnostic::SpanHandler::span_bug::had6443bf384adbf3JaB
   6:     0x7fded4879fa3 - session::Session::span_bug::h6a7a032f0a598052BRn
   7:     0x7fded58b3ecf - check::regionck::visit_expr::hdfd865c1888e71cf1Hd
   8:     0x7fded58af2fe - check::regionck::Rcx<'a, 'tcx>::visit_fn_body::haec01bb8e2116544ekd
   9:     0x7fded593c006 - check::check_bare_fn::h661e8d61a11643593nn
  10:     0x7fded5941136 - check::check_method_body::h58ab2862cf5cc872TVn
  11:     0x7fded5938972 - check::check_item::h399c12ee5fd19c10OGn
  12:     0x7fded5a08dd6 - check_crate::closure.35999
  13:     0x7fded5a03c4a - check_crate::h609b704cb69c3426OmC
  14:     0x7fded723dcc8 - driver::phase_3_run_analysis_passes::h93ff07476d50900drGa
  15:     0x7fded7223e3f - driver::compile_input::hbb8012e70cc155f0Rba
  16:     0x7fded72d42e2 - run_compiler::h31d988b263419921s2b
  17:     0x7fded72d20e3 - thunk::F.Invoke<A, R>::invoke::h12881802307748552982
  18:     0x7fded72d1579 - rt::unwind::try::try_fn::h10611962194889117110
  19:     0x7fded6c835b8 - rust_try_inner
  20:     0x7fded6c835a5 - rust_try
  21:     0x7fded72d189c - thunk::F.Invoke<A, R>::invoke::h15479254083495500308
  22:     0x7fded6bf6248 - sys::thread::create::thread_start::h21751a1d907ece81soI
  23:     0x7fded0ae2373 - start_thread
  24:     0x7fded67b327c - __clone
  25:                0x0 - <unknown>

rustc 1.0.0-nightly (199bdcfef 2015-03-26) (built 2015-03-27)

Meta

rustc 1.0.0-nightly (199bdcf 2015-03-26) (built 2015-03-27)
binary: rustc
commit-hash: 199bdcf
commit-date: 2015-03-26
build-date: 2015-03-27
host: x86_64-unknown-linux-gnu
release: 1.0.0-nightly

Metadata

Metadata

Assignees

No one assigned

    Labels

    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