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 OutputTypeParameterMismatch #29997

Closed
frankmcsherry opened this issue Nov 23, 2015 · 10 comments
Closed

ICE OutputTypeParameterMismatch #29997

frankmcsherry opened this issue Nov 23, 2015 · 10 comments
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@frankmcsherry
Copy link
Contributor

The error is very long, and the example is not reduced (I tried, but the simple reduction worked ok, so no dice there). To reproduce, one can pull

frankmcsherry/differential-dataflow@2fa719e

and then cargo build --example cc. I'm on

Echidnatron% rustc --version
rustc 1.6.0-nightly (9303055f3 2015-11-19)

The same project ICEs on stable as well, but for a different reason (issue #29991; EDIT: Sorry, not actually this issue; rather, a different ICE that seems fixed in nightly).

I think the salient points are in the complaint

Sorts(ExpectedFound { 
    expected: differential_dataflow::collection::trace::DifferenceIterator<u32>, 
    found: <&differential_dataflow::collection::trace::Trace<u32, timely::progress::nested::product::Product<timely::progress::nested::product::Product<timely::progress::timestamp::RootTimestamp, u64>, u64>, u32, (collections::vec::Vec<core::option::Option<differential_dataflow::collection::trace::Offset>>, u64)> as differential_dataflow::collection::trace::TraceRef<u32, timely::progress::nested::product::Product<timely::progress::nested::product::Product<timely::progress::timestamp::RootTimestamp, u64>, u64>, u32>>::VIterator 
})

where it seems to be unhappy that it found a weird associated type rather than a DifferenceIterator<u32>. Of course, the associated type is that DifferenceIterator<u32>, which Rust knew at one point but seems to have lost track of, maybe? There is admittedly a bunch of horribleness going on with associated types, specifically faking out HKT for lifetimes through associated types of traits containing a lifetime implemented for references with that lifetime to the type in question. I can explain what it is doing if that helps, but given that it just ICEs differently in each release mode, maybe it's just time to delete it and try another way.

Full backtrace:

Echidnatron% cargo build --example cc
   Compiling differential-dataflow v0.0.1 (file:///Users/mcsherry/Projects/differential-dataflow)
src/operators/group.rs:276:29: 276:60 error: internal compiler error: Encountered error `OutputTypeParameterMismatch(Binder(<[closure@examples/cc.rs:71:27: 71:79] as core::ops::Fn<(&u32, core::iter::Peekable<differential_dataflow::iterators::coalesce::CoalesceIterator<differential_dataflow::iterators::merge::MergeIterator<<&differential_dataflow::collection::trace::Trace<u32, timely::progress::nested::product::Product<timely::progress::nested::product::Product<timely::progress::timestamp::RootTimestamp, u64>, u64>, u32, (collections::vec::Vec<core::option::Option<differential_dataflow::collection::trace::Offset>>, u64)> as differential_dataflow::collection::trace::TraceRef<u32, timely::progress::nested::product::Product<timely::progress::nested::product::Product<timely::progress::timestamp::RootTimestamp, u64>, u64>, u32>>::VIterator>>>, &mut collections::vec::Vec<(u32, i32)>)>>), Binder(<[closure@examples/cc.rs:71:27: 71:79] as core::ops::Fn<(&'static u32, core::iter::Peekable<differential_dataflow::iterators::coalesce::CoalesceIterator<differential_dataflow::iterators::merge::MergeIterator<differential_dataflow::collection::trace::DifferenceIterator<u32>>>>, &'static mut collections::vec::Vec<(u32, i32)>)>>), Sorts(ExpectedFound { expected: differential_dataflow::collection::trace::DifferenceIterator<u32>, found: <&differential_dataflow::collection::trace::Trace<u32, timely::progress::nested::product::Product<timely::progress::nested::product::Product<timely::progress::timestamp::RootTimestamp, u64>, u64>, u32, (collections::vec::Vec<core::option::Option<differential_dataflow::collection::trace::Offset>>, u64)> as differential_dataflow::collection::trace::TraceRef<u32, timely::progress::nested::product::Product<timely::progress::nested::product::Product<timely::progress::timestamp::RootTimestamp, u64>, u64>, u32>>::VIterator }))` selecting `Binder(<[closure@examples/cc.rs:71:27: 71:79] as core::ops::Fn<(&'static u32, core::iter::Peekable<differential_dataflow::iterators::coalesce::CoalesceIterator<differential_dataflow::iterators::merge::MergeIterator<differential_dataflow::collection::trace::DifferenceIterator<u32>>>>, &'static mut collections::vec::Vec<(u32, i32)>)>>)` during trans
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
thread 'rustc' panicked at 'Box<Any>', ../src/libsyntax/diagnostic.rs:175
stack backtrace:
   1:        0x10c6ff2d8 - sys::backtrace::tracing::imp::write::hed3a593bad2e5fa3Hqt
   2:        0x10c7053bf - panicking::log_panic::_<closure>::closure.39899
   3:        0x10c704e85 - panicking::log_panic::hb58e0c0eab041fc722w
   4:        0x10c6cdcb6 - sys_common::unwind::begin_unwind_inner::h04a0f5a988ff29c8fus
   5:        0x109ff092a - sys_common::unwind::begin_unwind::begin_unwind::h5224819670744734501
   6:        0x109ff08f2 - diagnostic::_<impl>::span_bug::hd2f1816c64c905211GB
   7:        0x109404a04 - session::_<impl>::span_bug::h20c03d11f84bf00aa5w
   8:        0x108d4ba6b - trans::common::fulfill_obligation::h47639f98fb7a544b3As
   9:        0x108d3c632 - trans::meth::trans_method_callee::hb7535cb5bac1bdebqGL
  10:        0x108dbcf43 - trans::callee::trans_call_inner::h15376225423506524332
  11:        0x108da643b - trans::expr::trans_rvalue_dps_unadjusted::hc66680a0fe7728dfdLC
  12:        0x108cfc363 - trans::expr::trans_into::hd912cb89d59a5a9a9CB
  13:        0x108d7b231 - trans::controlflow::trans_stmt_semi::h99e627f0ee69235bpmw
  14:        0x108cf85ad - trans::controlflow::trans_block::h5ae6763586afd39alnw
  15:        0x108da6cf4 - trans::expr::trans_rvalue_dps_unadjusted::hc66680a0fe7728dfdLC
  16:        0x108cfc363 - trans::expr::trans_into::hd912cb89d59a5a9a9CB
  17:        0x108d7b231 - trans::controlflow::trans_stmt_semi::h99e627f0ee69235bpmw
  18:        0x108cf85ad - trans::controlflow::trans_block::h5ae6763586afd39alnw
  19:        0x108da57c9 - trans::expr::trans_rvalue_dps_unadjusted::hc66680a0fe7728dfdLC
  20:        0x108cfc363 - trans::expr::trans_into::hd912cb89d59a5a9a9CB
  21:        0x108de2d50 - trans::_match::trans_match_inner::h1cc439eb09421ca59cL
  22:        0x108da5751 - trans::expr::trans_rvalue_dps_unadjusted::hc66680a0fe7728dfdLC
  23:        0x108cfc363 - trans::expr::trans_into::hd912cb89d59a5a9a9CB
  24:        0x108cf88fb - trans::controlflow::trans_block::h5ae6763586afd39alnw
  25:        0x108da9603 - trans::expr::trans_rvalue_stmt_unadjusted::hb6e5ec9373e54768mDC
  26:        0x108cfc4d4 - trans::expr::trans_into::hd912cb89d59a5a9a9CB
  27:        0x108de2d50 - trans::_match::trans_match_inner::h1cc439eb09421ca59cL
  28:        0x108da5751 - trans::expr::trans_rvalue_dps_unadjusted::hc66680a0fe7728dfdLC
  29:        0x108cfc363 - trans::expr::trans_into::hd912cb89d59a5a9a9CB
  30:        0x108de5dca - trans::_match::mk_binding_alloca::h6244938181906574675
  31:        0x108cde11c - trans::base::init_local::h3234403b2a5b16368Th
  32:        0x108cf85d2 - trans::controlflow::trans_block::h5ae6763586afd39alnw
  33:        0x108da57c9 - trans::expr::trans_rvalue_dps_unadjusted::hc66680a0fe7728dfdLC
  34:        0x108cfc363 - trans::expr::trans_into::hd912cb89d59a5a9a9CB
  35:        0x108d7b231 - trans::controlflow::trans_stmt_semi::h99e627f0ee69235bpmw
  36:        0x108cf85ad - trans::controlflow::trans_block::h5ae6763586afd39alnw
  37:        0x108da57c9 - trans::expr::trans_rvalue_dps_unadjusted::hc66680a0fe7728dfdLC
  38:        0x108cfc363 - trans::expr::trans_into::hd912cb89d59a5a9a9CB
  39:        0x108de2d50 - trans::_match::trans_match_inner::h1cc439eb09421ca59cL
  40:        0x108da5751 - trans::expr::trans_rvalue_dps_unadjusted::hc66680a0fe7728dfdLC
  41:        0x108cfc363 - trans::expr::trans_into::hd912cb89d59a5a9a9CB
  42:        0x108cf88fb - trans::controlflow::trans_block::h5ae6763586afd39alnw
  43:        0x108da57c9 - trans::expr::trans_rvalue_dps_unadjusted::hc66680a0fe7728dfdLC
  44:        0x108cfc363 - trans::expr::trans_into::hd912cb89d59a5a9a9CB
  45:        0x108de2d50 - trans::_match::trans_match_inner::h1cc439eb09421ca59cL
  46:        0x108da5751 - trans::expr::trans_rvalue_dps_unadjusted::hc66680a0fe7728dfdLC
  47:        0x108cfc363 - trans::expr::trans_into::hd912cb89d59a5a9a9CB
  48:        0x108cf88fb - trans::controlflow::trans_block::h5ae6763586afd39alnw
  49:        0x108da9603 - trans::expr::trans_rvalue_stmt_unadjusted::hb6e5ec9373e54768mDC
  50:        0x108cfc4d4 - trans::expr::trans_into::hd912cb89d59a5a9a9CB
  51:        0x108cf88fb - trans::controlflow::trans_block::h5ae6763586afd39alnw
  52:        0x108da57c9 - trans::expr::trans_rvalue_dps_unadjusted::hc66680a0fe7728dfdLC
  53:        0x108cfc363 - trans::expr::trans_into::hd912cb89d59a5a9a9CB
  54:        0x108cf88fb - trans::controlflow::trans_block::h5ae6763586afd39alnw
  55:        0x108cf4b49 - trans::base::trans_closure::he7bc15b87b73571czHi
  56:        0x108d44f34 - trans::closure::trans_closure_expr::hd80f3be42fb666449nr
  57:        0x108da78ef - trans::expr::trans_rvalue_dps_unadjusted::hc66680a0fe7728dfdLC
  58:        0x108da3ecd - trans::expr::trans_unadjusted::hd9a0a0a32fb6750c6dC
  59:        0x108cc7759 - trans::expr::trans::h08ef89894788bc6axJB
  60:        0x108d36027 - trans::callee::trans_args::h2fba99c86f0aa735Bdp
  61:        0x108d3ba4c - trans::callee::trans_call_inner::h1502485283949612030
  62:        0x108da4f16 - trans::expr::trans_rvalue_dps_unadjusted::hc66680a0fe7728dfdLC
  63:        0x108cfc363 - trans::expr::trans_into::hd912cb89d59a5a9a9CB
  64:        0x108cf88fb - trans::controlflow::trans_block::h5ae6763586afd39alnw
  65:        0x108cf4b49 - trans::base::trans_closure::he7bc15b87b73571czHi
  66:        0x108cf8f35 - trans::base::trans_fn::h2b637b637f2d5b99lRi
  67:        0x108d28065 - trans::callee::trans_fn_ref_with_substs::h33984ac7df52baf3kCo
  68:        0x108d3cca2 - trans::meth::trans_method_callee::hb7535cb5bac1bdebqGL
  69:        0x108d3a8eb - trans::callee::trans_call_inner::h1502485283949612030
  70:        0x108da4f16 - trans::expr::trans_rvalue_dps_unadjusted::hc66680a0fe7728dfdLC
  71:        0x108cfc363 - trans::expr::trans_into::hd912cb89d59a5a9a9CB
  72:        0x108cf88fb - trans::controlflow::trans_block::h5ae6763586afd39alnw
  73:        0x108cf4b49 - trans::base::trans_closure::he7bc15b87b73571czHi
  74:        0x108cf8f35 - trans::base::trans_fn::h2b637b637f2d5b99lRi
  75:        0x108d28065 - trans::callee::trans_fn_ref_with_substs::h33984ac7df52baf3kCo
  76:        0x108d3cca2 - trans::meth::trans_method_callee::hb7535cb5bac1bdebqGL
  77:        0x108d3a8eb - trans::callee::trans_call_inner::h1502485283949612030
  78:        0x108da4f16 - trans::expr::trans_rvalue_dps_unadjusted::hc66680a0fe7728dfdLC
  79:        0x108cfc363 - trans::expr::trans_into::hd912cb89d59a5a9a9CB
  80:        0x108cf88fb - trans::controlflow::trans_block::h5ae6763586afd39alnw
  81:        0x108da57c9 - trans::expr::trans_rvalue_dps_unadjusted::hc66680a0fe7728dfdLC
  82:        0x108cfc363 - trans::expr::trans_into::hd912cb89d59a5a9a9CB
  83:        0x108cf88fb - trans::controlflow::trans_block::h5ae6763586afd39alnw
  84:        0x108cf4b49 - trans::base::trans_closure::he7bc15b87b73571czHi
  85:        0x108d44f34 - trans::closure::trans_closure_expr::hd80f3be42fb666449nr
  86:        0x108da78ef - trans::expr::trans_rvalue_dps_unadjusted::hc66680a0fe7728dfdLC
  87:        0x108da3ecd - trans::expr::trans_unadjusted::hd9a0a0a32fb6750c6dC
  88:        0x108cc7759 - trans::expr::trans::h08ef89894788bc6axJB
  89:        0x108d36027 - trans::callee::trans_args::h2fba99c86f0aa735Bdp
  90:        0x108d3ba4c - trans::callee::trans_call_inner::h1502485283949612030
  91:        0x108da4f16 - trans::expr::trans_rvalue_dps_unadjusted::hc66680a0fe7728dfdLC
  92:        0x108cfc363 - trans::expr::trans_into::hd912cb89d59a5a9a9CB
  93:        0x108cf88fb - trans::controlflow::trans_block::h5ae6763586afd39alnw
  94:        0x108cf4b49 - trans::base::trans_closure::he7bc15b87b73571czHi
  95:        0x108cf8f35 - trans::base::trans_fn::h2b637b637f2d5b99lRi
  96:        0x108d27e4d - trans::callee::trans_fn_ref_with_substs::h33984ac7df52baf3kCo
  97:        0x108d25e5f - trans::callee::trans_fn_ref::h74554fe71b470393yro
  98:        0x108d209fa - trans::callee::trans::h9f2d9e9e69d424344fo
  99:        0x108d38e60 - trans::callee::trans_call_inner::h2899170165357686685
  100:        0x108da6381 - trans::expr::trans_rvalue_dps_unadjusted::hc66680a0fe7728dfdLC
 ... <frames omitted>

Could not compile `differential-dataflow`.
@huonw huonw added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Nov 23, 2015
@arielb1 arielb1 added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Nov 23, 2015
@arielb1
Copy link
Contributor

arielb1 commented Nov 23, 2015

Minified:

trait Mirror { type Image; }
impl<T> Mirror for T { type Image = T; }

fn test<L,T>(l: L) where L: FnOnce(Option<<&T as Mirror>::Image>),
                         for<'a> &'a T: Mirror
{ l(None); }
fn main() {
    test::<_,u8>(|_| {});
}

@nikomatsakis @eddyb : why is fulfill_obligation taking a PolyTraitRef rather than a regular TraitRef?

@nikomatsakis
Copy link
Contributor

@arielb1

ok, finally getting to some of my older notifications, sorry. An interesting question. Digging through the codebase, I see that there is only one call -- get_vtable -- where the generality of taking a polytraitref is used. But it makes sense there, no? An object type can be something like Box<Fn(&i32)>, after all.

Let me look into your minified example a bit.

@arielb1
Copy link
Contributor

arielb1 commented Jan 22, 2016

I guess we should just erase regions in that case too.

@arielb1
Copy link
Contributor

arielb1 commented Jan 23, 2016

The PolyTraitRef in fulfill_obligation seems to be of no good reason.

The root cause of the problem here is that typeck/trans assume that if for<'a> Ψ['a]: Trait holds then Ψ['s]: Trait holds after normalizing, and this does not work (maybe that is limited only to closures?)

@aidanhs
Copy link
Member

aidanhs commented Mar 3, 2017

I've hit this I think. Other issues with visually similar error messages which I assume are related: #33364 (comment), #39779.

@Rufflewind
Copy link
Contributor

Reposting #39779 here for future reference:


This seems to cause rustc to crash (link shows a slightly more complicated example than the reduced example below):

trait Fun<'a> { type Output; }

impl<'a> Fun<'a> for () { type Output = &'a str; }

fn with<F, G>(x: <F as Fun<'static>>::Output, g: G)
    where F: for<'a> Fun<'a>,
          G: for<'a> FnOnce(<F as Fun<'a>>::Output) {
    g(x)
}

fn main() {
    with::<(), _>("", |_| ());
}

It looks like it forgot to normalize <() as Fun<'a>>::Output to &'a str?

error: internal compiler error:
    src/librustc_trans/common.rs:473:
    Encountered error
        OutputTypeParameterMismatch(
           Binder(<[closure] as FnOnce(<() as Fun<'a>>::Output))>,
           Binder(<[closure] as FnOnce(&str))>,
           Sorts(ExpectedFound {
               expected: &str,
               found: <() as Fun<'_>>::Output
           })
        )
    selecting
        Binder(<[closure] as FnOnce(&str)>)
    during trans
Crash log for 1.15.0-stable (10893a9 2017-01-19)
error: internal compiler error: /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/librustc_trans/common.rs:473: Encountered error `OutputTypeParameterMismatch(Binder(<[closure@/tmp/bug.rs:12:23: 12:29] as std::ops::FnOnce<(<() as Fun<'a>>::Output,)>>), Binder(<[closure@/tmp/bug.rs:12:23: 12:29] as std::ops::FnOnce<(&str,)>>), Sorts(ExpectedFound { expected: &str, found: <() as Fun<'_>>::Output }))` selecting `Binder(<[closure@/tmp/bug.rs:12:23: 12:29] as std::ops::FnOnce<(&str,)>>)` during trans

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>', /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/librustc_errors/lib.rs:376
stack backtrace:
   1:     0x7f867e11e52c - std::sys::imp::backtrace::tracing::imp::write::h1d59ca58eb86a1e2
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:42
   2:     0x7f867e12cb1e - std::panicking::default_hook::{{closure}}::hc8550e2dc230bf9b
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panicking.rs:351
   3:     0x7f867e12c6c3 - std::panicking::default_hook::he85ae9e5c9867198
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panicking.rs:361
   4:     0x7f867e12cfbb - std::panicking::rust_panic_with_hook::h319375f6b98710b0
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panicking.rs:555
   5:     0x7f867ca6fa78 - std::panicking::begin_panic::hcffa9fd2a04ec06f
   6:     0x7f867ca8d595 - rustc::session::opt_span_bug_fmt::{{closure}}::h614c6fe11c4465e9
   7:     0x7f867ca8d3aa - rustc::session::span_bug_fmt::h8b2f72c913194199
   8:     0x7f867cb02fa7 - rustc_trans::common::fulfill_obligation::{{closure}}::{{closure}}::h765609b5f897b16b
   9:     0x7f867caff22c - rustc_trans::common::fulfill_obligation::h5accac95e8a401b5
  10:     0x7f867cafb98b - rustc_trans::collector::do_static_dispatch::hce598ea3ab1ce3a5
  11:     0x7f867cafb00d - <rustc_trans::collector::MirNeighborCollector<'a, 'tcx> as rustc::mir::visit::Visitor<'tcx>>::visit_operand::hd92120f4e6379a7e
  12:     0x7f867cafb58a - <rustc_trans::collector::MirNeighborCollector<'a, 'tcx> as rustc::mir::visit::Visitor<'tcx>>::visit_terminator_kind::hccb2193f3818a450
  13:     0x7f867ca88286 - rustc::mir::visit::Visitor::visit_mir::hfb8959f7b6b5ba95
  14:     0x7f867cafd449 - rustc_trans::collector::collect_neighbours::he1db279e25d9c10d
  15:     0x7f867caf9522 - rustc_trans::collector::collect_items_rec::hbbb361a730e6b0d3
  16:     0x7f867caf9844 - rustc_trans::collector::collect_items_rec::hbbb361a730e6b0d3
  17:     0x7f867cae64d8 - rustc_trans::base::collect_and_partition_translation_items::{{closure}}::h742429e3883a12cb
  18:     0x7f867cae1bc2 - rustc_trans::base::collect_and_partition_translation_items::hac7e8bb398fe3219
  19:     0x7f867cad4e52 - rustc_trans::base::trans_crate::hf153b22edafcd3f0
  20:     0x7f867e4e0e80 - rustc_driver::driver::phase_4_translate_to_llvm::h6ba7de0cd156758c
  21:     0x7f867e4ad282 - rustc_driver::driver::compile_input::{{closure}}::h40e96e4888acf56e
  22:     0x7f867e4df551 - rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}::hfacc2eff9ff79a87
  23:     0x7f867e4bd516 - rustc_driver::driver::phase_3_run_analysis_passes::h40916decd3c5ea98
  24:     0x7f867e4ab220 - rustc_driver::driver::compile_input::hce31fd38e3368b28
  25:     0x7f867e4f5ba4 - rustc_driver::run_compiler::hf9be2d0376d35b2a
  26:     0x7f867e401f1b - std::panicking::try::do_call::h996393a0ecaa9347
  27:     0x7f867e135dfa - __rust_maybe_catch_panic
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libpanic_unwind/lib.rs:98
  28:     0x7f867e42a292 - <F as alloc::boxed::FnBox<A>>::call_box::h70b5304598a75c7d
  29:     0x7f867e12b974 - std::sys::imp::thread::Thread::new::thread_start::hc16926852e47c008
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/liballoc/boxed.rs:623
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/sys_common/thread.rs:21
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/sys/unix/thread.rs:84
  30:     0x7f8675f14453 - start_thread
  31:     0x7f867ddee7de - __GI___clone
  32:                0x0 - <unknown>
Crash log for 1.17.0-nightly (c49d102 2017-02-07)

error: internal compiler error: /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/librustc_trans/common.rs:473: Encountered error `OutputTypeParameterMismatch(Binder(<[closure@/tmp/bug.rs:12:23: 12:29] as std::ops::FnOnce<(<() as Fun<'a>>::Output,)>>), Binder(<[closure@/tmp/bug.rs:12:23: 12:29] as std::ops::FnOnce<(&str,)>>), Sorts(ExpectedFound { expected: &str, found: <() as Fun<'_>>::Output }))` selecting `Binder(<[closure@/tmp/bug.rs:12:23: 12:29] as std::ops::FnOnce<(&str,)>>)` during trans

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>', /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/librustc_errors/lib.rs:376
stack backtrace:
   1:     0x7f867e11e52c - std::sys::imp::backtrace::tracing::imp::write::h1d59ca58eb86a1e2
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:42
   2:     0x7f867e12cb1e - std::panicking::default_hook::{{closure}}::hc8550e2dc230bf9b
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panicking.rs:351
   3:     0x7f867e12c6c3 - std::panicking::default_hook::he85ae9e5c9867198
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panicking.rs:361
   4:     0x7f867e12cfbb - std::panicking::rust_panic_with_hook::h319375f6b98710b0
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panicking.rs:555
   5:     0x7f867ca6fa78 - std::panicking::begin_panic::hcffa9fd2a04ec06f
   6:     0x7f867ca8d595 - rustc::session::opt_span_bug_fmt::{{closure}}::h614c6fe11c4465e9
   7:     0x7f867ca8d3aa - rustc::session::span_bug_fmt::h8b2f72c913194199
   8:     0x7f867cb02fa7 - rustc_trans::common::fulfill_obligation::{{closure}}::{{closure}}::h765609b5f897b16b
   9:     0x7f867caff22c - rustc_trans::common::fulfill_obligation::h5accac95e8a401b5
  10:     0x7f867cafb98b - rustc_trans::collector::do_static_dispatch::hce598ea3ab1ce3a5
  11:     0x7f867cafb00d - <rustc_trans::collector::MirNeighborCollector<'a, 'tcx> as rustc::mir::visit::Visitor<'tcx>>::visit_operand::hd92120f4e6379a7e
  12:     0x7f867cafb58a - <rustc_trans::collector::MirNeighborCollector<'a, 'tcx> as rustc::mir::visit::Visitor<'tcx>>::visit_terminator_kind::hccb2193f3818a450
  13:     0x7f867ca88286 - rustc::mir::visit::Visitor::visit_mir::hfb8959f7b6b5ba95
  14:     0x7f867cafd449 - rustc_trans::collector::collect_neighbours::he1db279e25d9c10d
  15:     0x7f867caf9522 - rustc_trans::collector::collect_items_rec::hbbb361a730e6b0d3
  16:     0x7f867caf9844 - rustc_trans::collector::collect_items_rec::hbbb361a730e6b0d3
  17:     0x7f867cae64d8 - rustc_trans::base::collect_and_partition_translation_items::{{closure}}::h742429e3883a12cb
  18:     0x7f867cae1bc2 - rustc_trans::base::collect_and_partition_translation_items::hac7e8bb398fe3219
  19:     0x7f867cad4e52 - rustc_trans::base::trans_crate::hf153b22edafcd3f0
  20:     0x7f867e4e0e80 - rustc_driver::driver::phase_4_translate_to_llvm::h6ba7de0cd156758c
  21:     0x7f867e4ad282 - rustc_driver::driver::compile_input::{{closure}}::h40e96e4888acf56e
  22:     0x7f867e4df551 - rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}::hfacc2eff9ff79a87
  23:     0x7f867e4bd516 - rustc_driver::driver::phase_3_run_analysis_passes::h40916decd3c5ea98
  24:     0x7f867e4ab220 - rustc_driver::driver::compile_input::hce31fd38e3368b28
  25:     0x7f867e4f5ba4 - rustc_driver::run_compiler::hf9be2d0376d35b2a
  26:     0x7f867e401f1b - std::panicking::try::do_call::h996393a0ecaa9347
  27:     0x7f867e135dfa - __rust_maybe_catch_panic
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libpanic_unwind/lib.rs:98
  28:     0x7f867e42a292 - <F as alloc::boxed::FnBox<A>>::call_box::h70b5304598a75c7d
  29:     0x7f867e12b974 - std::sys::imp::thread::Thread::new::thread_start::hc16926852e47c008
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/liballoc/boxed.rs:623
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/sys_common/thread.rs:21
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/sys/unix/thread.rs:84
  30:     0x7f8675f14453 - start_thread
  31:     0x7f867ddee7de - __GI___clone
  32:                0x0 - <unknown>

@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 22, 2017
@mikeyhew
Copy link
Contributor

While working on a StreamingIterator trait, I got a similar ICE about an OutputTypeParameterMismatch.

pub trait StreamingIterator<'a> {
    type Item: 'a;

    fn next(&'a mut self) -> Option<Self::Item>;
}

pub trait StreamingIteratorExt: for<'a> StreamingIterator<'a> {
    fn for_each<F>(mut self, mut func: F) where
        Self: Sized,
        F: for<'a> FnMut(<Self as StreamingIterator<'a>>::Item)
    {
        while let Some(item) = self.next() {
            func(item)
        }
    }
}

impl<I> StreamingIteratorExt for I where
    I: for<'a>StreamingIterator<'a>
{}

impl<'a, I: Iterator + 'a> StreamingIterator<'a> for I {
    type Item = I::Item;

    fn next(&'a mut self) -> Option<Self::Item> {
        self.next()
    }
}

#[test]
fn test_basic_stuff() {
    let it = vec![1i32,2,3].into_iter();

    StreamingIteratorExt::for_each(it, |x| println!("{}", x));
}

And here's the error on Rust 1.21.0 stable

error: internal compiler error: src/librustc/traits/trans/mod.rs:75: Encountered error 

`OutputTypeParameterMismatch(
    Binder(<[closure@src/lib.rs:34:40: 34:61]
            as std::ops::FnMut<(
                <std::vec::IntoIter<i32> as StreamingIterator<'_>>::Item,
            )>>),
    Binder(<[closure@src/lib.rs:34:40: 34:61]
            as std::ops::FnMut<(i32,)>>),
    Sorts(ExpectedFound {
        expected: i32,
        found: <std::vec::IntoIter<i32> as StreamingIterator<'_>>::Item
    })
)`

selecting `Binder(<[closure@src/lib.rs:34:40: 34:61] as std::ops::FnMut<(i32,)>>)` during trans
Backtrace on Rust 1.21.0 stable
thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:437:8
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
   1: std::panicking::default_hook::{{closure}}
   2: std::panicking::default_hook
   3: std::panicking::rust_panic_with_hook
   4: std::panicking::begin_panic
   5: rustc_errors::Handler::span_bug
   6: rustc::session::opt_span_bug_fmt::{{closure}}
   7: rustc::session::opt_span_bug_fmt
   8: rustc::session::span_bug_fmt
   9: rustc::traits::trans::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'tcx>>::trans_fulfill_obligation::{{closure}}
  10: rustc::traits::trans::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'tcx>>::trans_fulfill_obligation
  11: rustc_trans::monomorphize::resolve
  12: <rustc_trans::collector::MirNeighborCollector<'a, 'tcx> as rustc::mir::visit::Visitor<'tcx>>::visit_terminator_kind
  13: rustc::mir::visit::Visitor::visit_mir
  14: rustc_trans::collector::collect_items_rec
  15: rustc_trans::collector::collect_items_rec
  16: rustc_trans::base::collect_and_partition_translation_items::{{closure}}
  17: rustc_trans::base::trans_crate
  18: rustc_driver::driver::phase_4_translate_to_llvm
  19: rustc_driver::driver::compile_input::{{closure}}
  20: rustc::ty::context::TyCtxt::create_and_enter
  21: rustc_driver::driver::compile_input
  22: rustc_driver::run_compiler

Note that <std::vec::IntoIter<i32> as StreamingIterator<'_>>::Item = i32

@arielb1
Copy link
Contributor

arielb1 commented Oct 4, 2018

Another minimal example (#53420):

trait Lt<'a> {
    type T;
}
impl<'a> Lt<'a> for () {
    type T = ();
}

fn main() {
    let _:fn(<() as Lt<'_>>::T) = |()| {};
}

@eddyb
Copy link
Member

eddyb commented Nov 3, 2018

Is #33364 a duplicate of this?

@pnkfelix
Copy link
Member

closing as duplicate of #62529, which is where I will try to track future instances of this field of ICE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

10 participants