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: FulfillmentError, MismatchedProjectionTypes #33461

Closed
gmorenz opened this issue May 6, 2016 · 2 comments
Closed

ICE: FulfillmentError, MismatchedProjectionTypes #33461

gmorenz opened this issue May 6, 2016 · 2 comments

Comments

@gmorenz
Copy link

gmorenz commented May 6, 2016

Testcase currently relying on the most recent ncollide and nphysics3d from crates.io. When I get some time later today I'll try to reduce it more.

Code:

extern crate ncollide;
extern crate nphysics3d;

use ncollide::shape::Ball;
use nphysics3d::object::RigidBody;

fn main() {
    RigidBody::new_dynamic(Ball::new(1.0f32), 1.0f32, 0.0f32, 1.0f32);
}

Error:

error: internal compiler error: ../src/librustc/infer/mod.rs:564: Encountered errors `[FulfillmentError(Obligation(predicate=Binder(ProjectionPredicate(ProjectionTy { trait_ref: <nalgebra::structs::vector::Vector3<f32> as ncollide::ncollide_math::Vector>, item_name: Scalar(3937) }, <<nalgebra::structs::point::Point3<f32> as ncollide::ncollide_math::Point>::Vect as ncollide::ncollide_math::Vector>::Scalar)),depth=2),MismatchedProjectionTypes(Sorts(ExpectedFound { expected: f32, found: <<nalgebra::structs::point::Point3<f32> as ncollide::ncollide_math::Point>::Vect as ncollide::ncollide_math::Vector>::Scalar })))]` fulfilling 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/errors/mod.rs:537
stack backtrace:
   1:     0x7fcc05a63610 - std::sys::backtrace::tracing::imp::write::h9fb600083204ae7f
   2:     0x7fcc05a70d5b - std::panicking::default_hook::_$u7b$$u7b$closure$u7d$$u7d$::hca543c34f11229ac
   3:     0x7fcc05a708fc - std::panicking::default_hook::hc2c969e7453d080c
   4:     0x7fcc05a3628f - std::sys_common::unwind::begin_unwind_inner::h30e12d15ce2b2e25
   5:     0x7fcc04538ea8 - std::sys_common::unwind::begin_unwind::h24c4c0fa2cfe995a
   6:     0x7fcc04538e4b - syntax::errors::Handler::span_bug::h1878d6587b8bfd95
   7:     0x7fcc0456dac2 - rustc::session::opt_span_bug_fmt::_$u7b$$u7b$closure$u7d$$u7d$::hf0fb5697f8f25f40
   8:     0x7fcc0456d9b2 - rustc::session::span_bug_fmt::h4591bcbadfc38558
   9:     0x7fcc0458204c - rustc_trans::common::fulfill_obligation::hb97500cd4d49823c
  10:     0x7fcc0457aa99 - rustc_trans::callee::Callee::def::ha169529fef0048b5
  11:     0x7fcc0467c11e - _<std..option..Option<T>>::map::h54e7f9a0f99f0360
  12:     0x7fcc0467bf0a - _<std..vec..Vec<T> as std..iter..FromIterator<T>>::from_iter::he173b9fb2f4cc1c2
  13:     0x7fcc0467b7c3 - rustc_trans::meth::get_vtable::_$u7b$$u7b$closure$u7d$$u7d$::hd7ec4b80d346f375
  14:     0x7fcc0467c942 - _<std..iter..FlatMap<I, U, F> as std..iter..Iterator>::next::ha090509351b98638
  15:     0x7fcc0467cb83 - _<std..vec..Vec<T>>::extend_desugared::hfc30acdd7688509c
  16:     0x7fcc0467c609 - core::iter::iterator::Iterator::collect::h42fa202d3651b5e6
  17:     0x7fcc0457c822 - rustc_trans::base::unsized_info::hd31be9e24e239b50
  18:     0x7fcc04641a66 - rustc_trans::expr::coerce_unsized::h6fa5deecc673f1b4
  19:     0x7fcc045eb860 - rustc_trans::expr::trans::h4425e9280a87b757
  20:     0x7fcc045a1faf - rustc_trans::expr::trans_into::he1315719b2222c7c
  21:     0x7fcc045a0d24 - rustc_trans::expr::trans_adt::hde3664923fa8f9ee
  22:     0x7fcc045a043d - rustc_trans::base::trans_named_tuple_constructor::hf968d51ee4f7b842
  23:     0x7fcc04579ab2 - rustc_trans::callee::Callee::call::h54d29fdb586ad3c4
  24:     0x7fcc0463e8b3 - rustc_trans::expr::trans_rvalue_dps_unadjusted::h4d8aac465b9b8fed
  25:     0x7fcc045a267d - rustc_trans::expr::trans_into::he1315719b2222c7c
  26:     0x7fcc0459a1cd - rustc_trans::controlflow::trans_block::h4fad28c271095568
  27:     0x7fcc04598c85 - rustc_trans::base::trans_closure::h83a389352ac0be25
  28:     0x7fcc0459a8f3 - rustc_trans::base::trans_fn::h9423938066432dd9
  29:     0x7fcc045d6fba - rustc_trans::callee::get_fn::h691a55e881985779
  30:     0x7fcc0457ad60 - rustc_trans::callee::Callee::def::ha169529fef0048b5
  31:     0x7fcc0467c11e - _<std..option..Option<T>>::map::h54e7f9a0f99f0360
  32:     0x7fcc0467bf0a - _<std..vec..Vec<T> as std..iter..FromIterator<T>>::from_iter::he173b9fb2f4cc1c2
  33:     0x7fcc0467b7c3 - rustc_trans::meth::get_vtable::_$u7b$$u7b$closure$u7d$$u7d$::hd7ec4b80d346f375
  34:     0x7fcc0467c942 - _<std..iter..FlatMap<I, U, F> as std..iter..Iterator>::next::ha090509351b98638
  35:     0x7fcc0467cb83 - _<std..vec..Vec<T>>::extend_desugared::hfc30acdd7688509c
  36:     0x7fcc0467c609 - core::iter::iterator::Iterator::collect::h42fa202d3651b5e6
  37:     0x7fcc0457c822 - rustc_trans::base::unsized_info::hd31be9e24e239b50
  38:     0x7fcc04641a66 - rustc_trans::expr::coerce_unsized::h6fa5deecc673f1b4
  39:     0x7fcc045eb860 - rustc_trans::expr::trans::h4425e9280a87b757
  40:     0x7fcc04645761 - rustc_trans::expr::trans_imm_cast::hf3533ccfb48f0b29
  41:     0x7fcc0463b828 - rustc_trans::expr::trans_unadjusted::hee333a5a427a7dc8
  42:     0x7fcc045eae31 - rustc_trans::expr::trans::h4425e9280a87b757
  43:     0x7fcc045e9bbe - rustc_trans::callee::trans_args::h9cc59c5a5b26cbc0
  44:     0x7fcc04579ec6 - rustc_trans::callee::Callee::call::h54d29fdb586ad3c4
  45:     0x7fcc0463e8b3 - rustc_trans::expr::trans_rvalue_dps_unadjusted::h4d8aac465b9b8fed
  46:     0x7fcc045a267d - rustc_trans::expr::trans_into::he1315719b2222c7c
  47:     0x7fcc045a0d24 - rustc_trans::expr::trans_adt::hde3664923fa8f9ee
  48:     0x7fcc0463d60a - rustc_trans::expr::trans_rvalue_dps_unadjusted::h4d8aac465b9b8fed
  49:     0x7fcc045a267d - rustc_trans::expr::trans_into::he1315719b2222c7c
  50:     0x7fcc0459a1cd - rustc_trans::controlflow::trans_block::h4fad28c271095568
  51:     0x7fcc04598c85 - rustc_trans::base::trans_closure::h83a389352ac0be25
  52:     0x7fcc0459a8f3 - rustc_trans::base::trans_fn::h9423938066432dd9
  53:     0x7fcc045d6fba - rustc_trans::callee::get_fn::h691a55e881985779
  54:     0x7fcc0457ad60 - rustc_trans::callee::Callee::def::ha169529fef0048b5
  55:     0x7fcc0463e671 - rustc_trans::expr::trans_rvalue_dps_unadjusted::h4d8aac465b9b8fed
  56:     0x7fcc0463b648 - rustc_trans::expr::trans_unadjusted::hee333a5a427a7dc8
  57:     0x7fcc045eae31 - rustc_trans::expr::trans::h4425e9280a87b757
  58:     0x7fcc045e9bbe - rustc_trans::callee::trans_args::h9cc59c5a5b26cbc0
  59:     0x7fcc04579ec6 - rustc_trans::callee::Callee::call::h54d29fdb586ad3c4
  60:     0x7fcc0463e8b3 - rustc_trans::expr::trans_rvalue_dps_unadjusted::h4d8aac465b9b8fed
  61:     0x7fcc045a267d - rustc_trans::expr::trans_into::he1315719b2222c7c
  62:     0x7fcc0459a1cd - rustc_trans::controlflow::trans_block::h4fad28c271095568
  63:     0x7fcc04598c85 - rustc_trans::base::trans_closure::h83a389352ac0be25
  64:     0x7fcc0459a8f3 - rustc_trans::base::trans_fn::h9423938066432dd9
  65:     0x7fcc045d6fba - rustc_trans::callee::get_fn::h691a55e881985779
  66:     0x7fcc0457ad60 - rustc_trans::callee::Callee::def::ha169529fef0048b5
  67:     0x7fcc0463e671 - rustc_trans::expr::trans_rvalue_dps_unadjusted::h4d8aac465b9b8fed
  68:     0x7fcc0463b648 - rustc_trans::expr::trans_unadjusted::hee333a5a427a7dc8
  69:     0x7fcc045eae31 - rustc_trans::expr::trans::h4425e9280a87b757
  70:     0x7fcc0461e166 - rustc_trans::controlflow::trans_stmt_semi::h1cfba097d89a5175
  71:     0x7fcc04599ea0 - rustc_trans::controlflow::trans_block::h4fad28c271095568
  72:     0x7fcc04598c85 - rustc_trans::base::trans_closure::h83a389352ac0be25
  73:     0x7fcc0459a8f3 - rustc_trans::base::trans_fn::h9423938066432dd9
  74:     0x7fcc045a4e91 - rustc_trans::base::trans_item::hdc785ae68a9e6500
  75:     0x7fcc045beecb - _<base..TransItemsWithinModVisitor<'a, 'tcx> as rustc..hir..intravisit..Visitor<'v>>::visit_item::h22c1c36dec64effa
  76:     0x7fcc045ad7cb - rustc_trans::base::trans_crate::h6ed1dbd6e572a8c2
  77:     0x7fcc05fc86ff - rustc_driver::driver::phase_4_translate_to_llvm::hd7579aae98641824
  78:     0x7fcc05fc6d8f - rustc_driver::driver::compile_input::_$u7b$$u7b$closure$u7d$$u7d$::he3c6b6ab9afe28dd
  79:     0x7fcc05fc3630 - rustc_driver::driver::phase_3_run_analysis_passes::_$u7b$$u7b$closure$u7d$$u7d$::h06c776ef4d1c70b6
  80:     0x7fcc05fbcf5e - rustc::ty::context::TyCtxt::create_and_enter::hb0e0e916c7274a64
  81:     0x7fcc05f8f90d - rustc_driver::driver::compile_input::h0629572e6f316b31
  82:     0x7fcc05f7053c - rustc_driver::run_compiler::h8902aebf8b1849a8
  83:     0x7fcc05f6dc41 - std::sys_common::unwind::try::try_fn::h4c74456035d0fcc7
  84:     0x7fcc05a60deb - __rust_try
  85:     0x7fcc05a60d7d - std::sys_common::unwind::inner_try::h47a4d9cd4a369dcd
  86:     0x7fcc05f6e48a - _<F as std..boxed..FnBox<A>>::call_box::h27f542a39f1d61ef
  87:     0x7fcc05a6eef4 - std::sys::thread::Thread::new::thread_start::h6f266e069bf4ec2b
  88:     0x7fcbfd7f6423 - start_thread
  89:     0x7fcc056cdcbc - clone
  90:                0x0 - <unknown>

error: Could not compile `pong`.

To learn more, run the command again with --verbose.
@sebcrozet
Copy link
Contributor

sebcrozet commented May 6, 2016

I investigated this further and ended up with the following test case independent from ncollide/nphysics. It causes an ICE on both beta (rustc 1.9.0-beta.2 (87cb733 2016-05-04)) and nigthly (rustc 1.10.0-nightly (8da2bca 2016-04-28))( and compiles fine on stable. The ICE will appear with and without --release. This might be related to #33096.

I can try to compile this on master but it will take some time before I can download the repo and compile rustc manually.

use std::marker::PhantomData;

struct TheType<T> {
    t: PhantomData<T>
}

pub trait TheTrait {
    type TheAssociatedType;
}

impl TheTrait for () {
    type TheAssociatedType = ();
}

pub trait Shape<P: TheTrait> {
    fn doit(&self) {
    }
}

impl<P: TheTrait> Shape<P> for TheType<P::TheAssociatedType> {
}

fn main() {
    let ball = TheType { t: PhantomData };
    let handle: &Shape<()> = &ball;
}

This will compile fine, without any ICE if we do at least one of the following:

  • Implement the .doit(...) method explicitly on impl<...> Shape<...> for TheType<...>:
impl<P: TheTrait> Shape<P> for TheType<P::TheAssociatedType> {
    fn doit(&self) {
   }
}
  • Remove the associated type in the impl, i.e., replace impl<P: TheTrait> Shape<P> for TheType<P::TheAssociatedType> with impl<P: TheTrait> Shape<P> for TheType<()> (or anything else, including P itself instead of ()).
  • Remove the cast to a &Shape<...> trait-object at the end of the main.

xen0n added a commit to xen0n/rust that referenced this issue May 7, 2016
Manishearth added a commit to Manishearth/rust that referenced this issue May 8, 2016
…=eddyb

trans: callee: normalize trait_ref before use

This fixes rust-lang#33436 and rust-lang#33461. Ran the tests and nothing else seems to be affected.

P.S. How to write the regression test for this fix? Does this qualify as run-pass or run-make, as the test only needs to be successfully compiled to be considered passed? Will add the testcase (the minimal example in rust-lang#33461 seems fit) after clarifying this.
bors added a commit that referenced this issue May 9, 2016
trans: callee: normalize trait_ref before use

This fixes #33436 and #33461. Ran the tests and nothing else seems to be affected.

P.S. How to write the regression test for this fix? Does this qualify as run-pass or run-make, as the test only needs to be successfully compiled to be considered passed? Will add the testcase (the minimal example in #33461 seems fit) after clarifying this.
@sanxiyn
Copy link
Member

sanxiyn commented May 9, 2016

Fixed by #33478.

@sanxiyn sanxiyn closed this as completed May 9, 2016
alexcrichton pushed a commit to alexcrichton/rust that referenced this issue May 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants