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

ices/83288.rs: fixed with errors #1038

Merged
merged 1 commit into from
Dec 6, 2021
Merged

ices/83288.rs: fixed with errors #1038

merged 1 commit into from
Dec 6, 2021

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Dec 6, 2021

Issue: rust-lang/rust#83288

#![allow(incomplete_features)]
#![feature(generic_const_exprs)]

use std::{marker::PhantomData, ops::Mul};

pub enum Nil {}
pub struct Cons<T, L> {
    _phantom: PhantomData<(T, L)>,
}

pub trait Indices<const N: usize> {
    const RANK: usize;
    const NUM_ELEMS: usize;
}

impl<const N: usize> Indices<N> for Nil {
    const RANK: usize = 0;
    const NUM_ELEMS: usize = 1;
}

impl<T, I: Indices<N>, const N: usize> Indices<N> for Cons<T, I> {
    const RANK: usize = I::RANK + 1;
    const NUM_ELEMS: usize = I::NUM_ELEMS * N;
}

pub trait Concat<J> {
    type Output;
}

impl<J> Concat<J> for Nil {
    type Output = J;
}

impl<T, I, J> Concat<J> for Cons<T, I>
where
    I: Concat<J>,
{
    type Output = Cons<T, <I as Concat<J>>::Output>;
}

pub struct Tensor<I: Indices<N>, const N: usize>
where
    [u8; I::NUM_ELEMS]: Sized,
{
    pub data: [u8; I::NUM_ELEMS],
    _phantom: PhantomData<I>,
}

impl<I: Indices<N>, J: Indices<N>, const N: usize> Mul<Tensor<J, N>> for Tensor<I, N>
where
    I: Concat<J>,
    <I as Concat<J>>::Output: Indices<N>,
    [u8; I::NUM_ELEMS]: Sized,
    [u8; J::NUM_ELEMS]: Sized,
    [u8; <I as Concat<J>>::Output::NUM_ELEMS]: Sized,
{
    type Output = Tensor<<I as Concat<J>>::Output, N>;

    fn mul(self, rhs: Tensor<J, N>) -> Self::Output {
        Tensor {
            data: [0u8; <I as Concat<J>>::Output::NUM_ELEMS],
            _phantom: PhantomData,
        }
    }
}
=== stdout ===
=== stderr ===
error[E0601]: `main` function not found in crate `83288`
  --> /home/runner/work/glacier/glacier/ices/83288.rs:1:1
   |
1  | / #![allow(incomplete_features)]
2  | | #![feature(generic_const_exprs)]
3  | |
4  | | use std::{marker::PhantomData, ops::Mul};
...  |
64 | |     }
65 | | }
   | |_^ consider adding a `main` function to `/home/runner/work/glacier/glacier/ices/83288.rs`

error: aborting due to previous error

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

=== stdout ===
=== stderr ===
error[E0601]: `main` function not found in crate `83288`
  --> /home/runner/work/glacier/glacier/ices/83288.rs:1:1
   |
1  | / #![allow(incomplete_features)]
2  | | #![feature(generic_const_exprs)]
3  | |
4  | | use std::{marker::PhantomData, ops::Mul};
...  |
64 | |     }
65 | | }
   | |_^ consider adding a `main` function to `/home/runner/work/glacier/glacier/ices/83288.rs`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0601`.
==============
@Alexendoo Alexendoo merged commit ac8fefe into master Dec 6, 2021
@Alexendoo Alexendoo deleted the autofix/ices/83288.rs branch December 6, 2021 13:42
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