Skip to content
This repository was archived by the owner on May 23, 2024. It is now read-only.

ices/68295.rs: fixed with errors #989

Merged
merged 1 commit into from
Oct 10, 2021
Merged

ices/68295.rs: fixed with errors #989

merged 1 commit into from
Oct 10, 2021

Conversation

github-actions[bot]
Copy link
Contributor

Issue: rust-lang/rust#68295

pub struct Matrix<R, C, S> {
    _phantoms: std::marker::PhantomData<(R, C, S)>,
}

impl<R, C, S> Matrix<R, C, S> {
    pub fn into_owned(self) -> Matrix<R, C, Owned<R, C, ()>>
    where
        (): Allocator<R, C>,
    {
        unimplemented!()
    }
}

impl<D, S> Matrix<D, D, S> {
    pub fn hermitian_part(&self) -> Matrix<D, D, Owned<D, D, ()>>
    where
        (): Allocator<D, D>,
    {
        unimplemented!()
    }
}

pub trait Allocator<R, C> {
    type Buffer;
}

pub trait Trait<R, C, A> {
    type Power;
}

impl<R, C, A: Allocator<R, C>> Trait<R, C, A> for () {
    type Power = A::Buffer;
}

pub type Owned<R, C, G> = <G as Trait<R, C, ()>>::Power;

pub fn crash<R, C>(input: Matrix<R, C, ()>) -> Matrix<R, C, u32>
where
    (): Allocator<R, C>,
{
    input.into_owned()
}

fn main() {}
=== stdout ===
=== stderr ===
error[E0308]: mismatched types
  --> /home/runner/work/glacier/glacier/ices/68295.rs:41:5
   |
37 | pub fn crash<R, C>(input: Matrix<R, C, ()>) -> Matrix<R, C, u32>
   |                                                ----------------- expected `Matrix<R, C, u32>` because of return type
...
41 |     input.into_owned()
   |     ^^^^^^^^^^^^^^^^^^ expected `u32`, found associated type
   |
   = note: expected struct `Matrix<_, _, u32>`
              found struct `Matrix<_, _, <() as Allocator<R, C>>::Buffer>`
   = help: consider constraining the associated type `<() as Allocator<R, C>>::Buffer` to `u32`
   = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
==============

=== stdout ===
=== stderr ===
error[E0308]: mismatched types
  --> /home/runner/work/glacier/glacier/ices/68295.rs:41:5
   |
37 | pub fn crash<R, C>(input: Matrix<R, C, ()>) -> Matrix<R, C, u32>
   |                                                ----------------- expected `Matrix<R, C, u32>` because of return type
...
41 |     input.into_owned()
   |     ^^^^^^^^^^^^^^^^^^ expected `u32`, found associated type
   |
   = note: expected struct `Matrix<_, _, u32>`
              found struct `Matrix<_, _, <() as Allocator<R, C>>::Buffer>`
   = help: consider constraining the associated type `<() as Allocator<R, C>>::Buffer` to `u32`
   = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
==============
@Alexendoo Alexendoo merged commit 25545a3 into master Oct 10, 2021
@Alexendoo Alexendoo deleted the autofix/ices/68295.rs branch October 10, 2021 19:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants