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

Bug with new operators traits #20592

Closed
rvlander opened this issue Jan 5, 2015 · 4 comments
Closed

Bug with new operators traits #20592

rvlander opened this issue Jan 5, 2015 · 4 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@rvlander
Copy link

rvlander commented Jan 5, 2015

➜  matrix-rs git:(master) ✗ RUST_BACKTRACE=1 cargo build --verbose
       Fresh rustc-serialize v0.2.4
       Fresh num v0.1.5
   Compiling matrix-rs v0.0.1 (file:///home/rvlander/CloudStation/WIP/matrix-rs)
     Running `rustc /home/rvlander/CloudStation/WIP/matrix-rs/src/lib.rs --crate-name matrix-rs --crate-type lib -g -C metadata=911cbf09ca74d9fa -C extra-filename=-911cbf09ca74d9fa --out-dir /home/rvlander/CloudStation/WIP/matrix-rs/target --emit=dep-info,link -L /home/rvlander/CloudStation/WIP/matrix-rs/target -L /home/rvlander/CloudStation/WIP/matrix-rs/target/deps --extern num=/home/rvlander/CloudStation/WIP/matrix-rs/target/deps/libnum-99d6507e3aad728a.rlib`
/home/rvlander/CloudStation/WIP/matrix-rs/src/matrix/dense_matrix.rs:54:1: 58:2 error: internal compiler error: impl `VtableImpl(impl_def_id=DefId { krate: 0, node: 1042 }:matrix::dense_matrix::DenseMatrix<T>.Add, substs=Substs[types=[[_];[];[]], regions=[[];[];[]]], nested=[[Obligation(predicate=Binder(TraitPredicate(TraitRef(T, core::kinds::Sized))),depth=1), Obligation(predicate=Binder(TraitPredicate(TraitRef(T, core::kinds::Copy))),depth=1), Obligation(predicate=Binder(TraitPredicate(TraitRef(T, core::ops::Add))),depth=1)];[];[]])` did not contain projection for `Obligation(predicate=<matrix::dense_matrix::DenseMatrix<T> as TraitRef(matrix::dense_matrix::DenseMatrix<T>, core::ops::Add)>::Output,depth=0)`
/home/rvlander/CloudStation/WIP/matrix-rs/src/matrix/dense_matrix.rs:54 impl <T: Add<T> + Copy> Add for DenseMatrix<T> {
/home/rvlander/CloudStation/WIP/matrix-rs/src/matrix/dense_matrix.rs:55     fn add(self, rhs: DenseMatrix<T>) -> DenseMatrix<T> {
/home/rvlander/CloudStation/WIP/matrix-rs/src/matrix/dense_matrix.rs:56         self.__add(rhs)
/home/rvlander/CloudStation/WIP/matrix-rs/src/matrix/dense_matrix.rs:57     }
/home/rvlander/CloudStation/WIP/matrix-rs/src/matrix/dense_matrix.rs:58 }
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-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:123

stack backtrace:
   1:     0x7f7c86e9b920 - sys::backtrace::write::h36422e877a8b3158yQs
   2:     0x7f7c86ec1650 - failure::on_fail::hde5005d61795902da3y
   3:     0x7f7c86e274a0 - rt::unwind::begin_unwind_inner::ha0668a3a9d73b9a7RHy
   4:     0x7f7c81d00af0 - rt::unwind::begin_unwind::h9147230717703493418
   5:     0x7f7c81d00a80 - diagnostic::SpanHandler::span_bug::hee7de6e88971705bDFF
   6:     0x7f7c851fbc70 - middle::traits::project::project_type::ha3169b6d00cba236CYP
   7:     0x7f7c851f8dd0 - middle::traits::project::opt_normalize_projection_type::h52e80e1c888609adFQP
   8:     0x7f7c851e6890 - middle::traits::project::normalize_projection_type::had1d9d27edaeb68fgPP
   9:     0x7f7c851fa270 - middle::traits::project::AssociatedTypeNormalizer<'a, 'b, 'tcx>.TypeFolder<'tcx>::fold_ty::h8977cf1010cf2ef8RNP
  10:     0x7f7c864b7990 - middle::ty_fold::TypeFolder::fold_trait_ref::h15244371943192340039
  11:     0x7f7c864b85c0 - middle::ty_fold::VecPerParamSpace<T>.TypeFoldable<'tcx>::fold_with::h3029018912722243389
  12:     0x7f7c864d3b40 - check::FnCtxt<'a, 'tcx>::instantiate_bounds::haf69ce16fdf22227Nul
  13:     0x7f7c864ec870 - check::wf::CheckTypeWellFormedVisitor<'ccx, 'tcx>::check_impl::closure.30018
  14:     0x7f7c864e8ce0 - check::wf::CheckTypeWellFormedVisitor<'ccx, 'tcx>::with_fcx::h0df2a1129da2a633Hfi
  15:     0x7f7c864ef760 - check::wf::CheckTypeWellFormedVisitor<'ccx, 'tcx>.Visitor<'v>::visit_item::hc72c9294b1b3f21ftoi
  16:     0x7f7c864f15c0 - visit::walk_mod::h2450081392115226323
  17:     0x7f7c864ef760 - check::wf::CheckTypeWellFormedVisitor<'ccx, 'tcx>.Visitor<'v>::visit_item::hc72c9294b1b3f21ftoi
  18:     0x7f7c864f15c0 - visit::walk_mod::h2450081392115226323
  19:     0x7f7c864ef760 - check::wf::CheckTypeWellFormedVisitor<'ccx, 'tcx>.Visitor<'v>::visit_item::hc72c9294b1b3f21ftoi
  20:     0x7f7c866ddbd0 - check_crate::unboxed_closure.40283
  21:     0x7f7c866d8820 - check_crate::h4ba306a17295b431iux
  22:     0x7f7c873dc600 - driver::phase_3_run_analysis_passes::h56810662503f92d8Sva
  23:     0x7f7c873caaa0 - driver::compile_input::h8d0abf631800220evba
  24:     0x7f7c87496070 - thunk::F.Invoke<A, R>::invoke::h13263903969514368718
  25:     0x7f7c87494e20 - rt::unwind::try::try_fn::h2272437873322108176
  26:     0x7f7c86f258b0 - rust_try_inner
  27:     0x7f7c86f258a0 - rust_try
  28:     0x7f7c87495170 - thunk::F.Invoke<A, R>::invoke::h17236552692728063371
  29:     0x7f7c86ead490 - sys::thread::thread_start::hd19c7749b7af23e8EGv
  30:     0x7f7c81525250 - start_thread
  31:     0x7f7c86ae2219 - clone
  32:                0x0 - <unknown>

Could not compile `matrix-rs`.

Caused by:
  Process didn't exit successfully: `rustc /home/rvlander/CloudStation/WIP/matrix-rs/src/lib.rs --crate-name matrix-rs --crate-type lib -g -C metadata=911cbf09ca74d9fa -C extra-filename=-911cbf09ca74d9fa --out-dir /home/rvlander/CloudStation/WIP/matrix-rs/target --emit=dep-info,link -L /home/rvlander/CloudStation/WIP/matrix-rs/target -L /home/rvlander/CloudStation/WIP/matrix-rs/target/deps --extern num=/home/rvlander/CloudStation/WIP/matrix-rs/target/deps/libnum-99d6507e3aad728a.rlib` (status=101)
@rvlander rvlander changed the title Bug when moving operators' traist to work with new Traits Bug when moving operators' traits to work with new Traits Jan 5, 2015
@rvlander rvlander changed the title Bug when moving operators' traits to work with new Traits Bug with new operators traits Jan 5, 2015
@kmcallister kmcallister added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jan 5, 2015
@japaric
Copy link
Member

japaric commented Jan 5, 2015

Probably a duplicate of #20553 / #20347

From the error message, it looks like you need to add the associated Output type to your Add impl.

impl <T: Add<T> + Copy> Add for DenseMatrix<T> {
    type Output = DenseMatrix<T>;  // <-- Add this

    fn add(self, rhs: DenseMatrix<T>) -> DenseMatrix<T> {
        self.__add(rhs)
    }
}

@rvlander
Copy link
Author

rvlander commented Jan 6, 2015

Why do we need to define such a type now ? It does not seem usefull from a user point of view. Is it to help the compiler in some sort? Plus: what is this syntax ? <Self as Add<RHS>>::Output (cf reference API)

@huonw
Copy link
Member

huonw commented Jan 6, 2015

Why do we need to define such a type now ? ... Is it to help the compiler in some sort?

It is to help you. It defines what the result of the operation is, e.g. one might implement Mul<Vector<T>> for DenseMatrix<T> with Output = Vector<T>, and Mul<DenseMatrix<T>> for DenseMatrix<T> with Output = DenseMatrix<T> to allow multiplying two matrices and a matrix and a vector.

Plus: what is this syntax ? <Self as Add<RHS>>::Output (cf reference API)

It is how one writes the path to one of these associated types. https://github.com/rust-lang/rfcs/blob/master/text/0195-associated-items.md contains (a lot) more details.

Closing as a dupe of #20347; thanks for filing!

@huonw huonw closed this as completed Jan 6, 2015
@rvlander
Copy link
Author

rvlander commented Jan 6, 2015

Thx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

4 participants