Skip to content

ICE with manual implementation of Fn Trait #20225

Closed
@flo-l

Description

@flo-l

Summary

$ rustc --version
rustc 0.13.0-nightly (96a3c7c6a 2014-12-23 22:21:10 +0000)
$ uname -r
3.7.10-1.45-desktop

The following piece of code produces an ICE.

Code

#![feature(unboxed_closures)]
struct Test;
impl<T> Fn(&T) for Test {
  extern "rust-call" fn call(&self, args: T) {}
}

fn main() {}

Compiler Output

bug.rs:3:1: 5:2 error: internal compiler error: cannot relate bound region: ReLateBound(DebruijnIndex { depth: 1 }, BrAnon(0)) <= ReLateBound(DebruijnIndex { depth: 2 }, BrAnon(0))
bug.rs:3 impl<T> Fn(&T) for Test {
bug.rs:4   extern "rust-call" fn call(&self, args: T) {}
bug.rs:5 }
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>', /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/libsyntax/diagnostic.rs:123

Backtrace

thread 'rustc' panicked at 'Box<Any>', /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/libsyntax/diagnostic.rs:123

stack backtrace:
   1:     0x7fce43261cd0 - sys::backtrace::write::hb17309211a216bb7JGt
   2:     0x7fce43283120 - failure::on_fail::heb25cc4682c759b8j7z
   3:     0x7fce431ef090 - rt::unwind::begin_unwind_inner::h3152ae29e75c429ejLz
   4:     0x7fce3e25a3b0 - rt::unwind::begin_unwind::h6844074129470762541
   5:     0x7fce3e25a330 - diagnostic::SpanHandler::span_bug::h29f82f79f5d56042xXF
   6:     0x7fce4147f240 - middle::infer::region_inference::RegionVarBindings<$u{27}a$C$$u{20}$u{27}tcx$GT$::make_subregion::h8ac58e20ccbbde5acCw
   7:     0x7fce4141a4b0 - middle::infer::region_inference::RegionVarBindings<$u{27}a$C$$u{20}$u{27}tcx$GT$::make_eqregion::h9d47ba08dd8cf5d2ABw
   8:     0x7fce4141a140 - middle::infer::equate::Equate<$u{27}f$C$$u{20}$u{27}tcx$GT$.Combine$LT$$u{27}tcx$GT$::regions::h73e6d56c660a1845Dmr
   9:     0x7fce41412fa0 - middle::infer::equate::Equate<$u{27}f$C$$u{20}$u{27}tcx$GT$.Combine$LT$$u{27}tcx$GT$::tys::h471f5a98c9d6dfcaItr
  10:     0x7fce4142d500 - vec::Vec<T>.FromIterator<T>::from_iter::h5668640528306963737
  11:     0x7fce41412fa0 - middle::infer::equate::Equate<$u{27}f$C$$u{20}$u{27}tcx$GT$.Combine$LT$$u{27}tcx$GT$::tys::h471f5a98c9d6dfcaItr
  12:     0x7fce4142a7d0 - middle::infer::combine::Combine::substs_variances::h1078347395584664297
  13:     0x7fce4142a710 - middle::infer::combine::Combine::substs::h17827783322505970035
  14:     0x7fce4142a3d0 - middle::infer::combine::Combine::trait_refs::h17661170864613379829
  15:     0x7fce4149f120 - middle::infer::InferCtxt<$u{27}a$C$$u{20}$u{27}tcx$GT$::sub_trait_refs::h746edee146c20ac1hAB
  16:     0x7fce41513900 - middle::traits::select::SelectionContext<$u{27}cx$C$$u{20}$u{27}tcx$GT$::match_impl::h611636679202f639yuS
  17:     0x7fce4151ee10 - middle::traits::select::SelectionContext<$u{27}cx$C$$u{20}$u{27}tcx$GT$::assemble_candidates_from_impls::h07907ee2e8ab08c9qpR
  18:     0x7fce41519a40 - middle::traits::select::SelectionContext<$u{27}cx$C$$u{20}$u{27}tcx$GT$::candidate_from_obligation_no_cache::h9717abb1557071bcmUQ
  19:     0x7fce4150a8a0 - middle::traits::select::SelectionContext<$u{27}cx$C$$u{20}$u{27}tcx$GT$::candidate_from_obligation::he45ed325becf3f9dVLQ
  20:     0x7fce415077e0 - middle::traits::select::SelectionContext<$u{27}cx$C$$u{20}$u{27}tcx$GT$::select::h1df2ae4f37ebe11f1qQ
  21:     0x7fce41500d60 - middle::traits::fulfill::FulfillmentContext<$u{27}tcx$GT$::select::ha8f543f2a109b8a81PP
  22:     0x7fce413cf830 - middle::traits::fulfill::FulfillmentContext<$u{27}tcx$GT$::select_all_or_error::h28551a267f49929bMMP
  23:     0x7fce4271b040 - check::vtable::select_all_fcx_obligations_or_error::h5dc16acf92778f762fb
  24:     0x7fce42790270 - check::wf::CheckTypeWellFormedVisitor<$u{27}ccx$C$$u{20}$u{27}tcx$GT$::with_fcx::h702fa687a451d051zYi
  25:     0x7fce42794be0 - check::wf::CheckTypeWellFormedVisitor<$u{27}ccx$C$$u{20}$u{27}tcx$GT$.Visitor$LT$$u{27}v$GT$::visit_item::h6897cdd375616c9cA7i
  26:     0x7fce42a74a30 - check_crate::unboxed_closure.43520
  27:     0x7fce42a6f6c0 - check_crate::h9fa0de23a730bc6051y
  28:     0x7fce437c08e0 - driver::phase_3_run_analysis_passes::hb82a5f356d65399aJta
  29:     0x7fce437a30c0 - driver::compile_input::h3a3ece9a540d8ec3wba
  30:     0x7fce43972450 - thunk::Thunk<(*,$u{20}R$GT$::new::unboxed_closure.30350
  31:     0x7fce43972320 - thunk::F.Invoke<A,$u{20}R$GT$::invoke::h12674338790413327364
  32:     0x7fce439709d0 - rt::unwind::try::try_fn::h12634669535511272181
  33:     0x7fce432e88b0 - rust_try_inner
  34:     0x7fce432e88a0 - rust_try
  35:     0x7fce43970d00 - thunk::F.Invoke<A,$u{20}R$GT$::invoke::h8791273253097928462
  36:     0x7fce43272510 - sys::thread::thread_start::h31ef8e2419d4f09ahFw
  37:     0x7fce3da5bd40 - start_thread
  38:     0x7fce42e9b0a9 - clone
  39:                0x0 - <unknown>

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