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

ices/83288.rs: fixed with errors #951

Closed
wants to merge 1 commit into from

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Sep 1, 2021

Issue: rust-lang/rust#83288

#![allow(incomplete_features)]
#![feature(const_generics, const_evaluatable_checked)]

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[E0557]: feature has been removed
 --> /home/runner/work/glacier/glacier/ices/83288.rs:2:12
  |
2 | #![feature(const_generics, const_evaluatable_checked)]
  |            ^^^^^^^^^^^^^^ feature has been removed
  |
  = note: removed in favor of `#![feature(adt_const_params]` and `#![feature(generic_const_exprs)]`

error[E0557]: feature has been removed
 --> /home/runner/work/glacier/glacier/ices/83288.rs:2:28
  |
2 | #![feature(const_generics, const_evaluatable_checked)]
  |                            ^^^^^^^^^^^^^^^^^^^^^^^^^ feature has been removed
  |
  = note: renamed to `generic_const_exprs`

error: generic parameters may not be used in const operations
  --> /home/runner/work/glacier/glacier/ices/83288.rs:43:10
   |
43 |     [u8; I::NUM_ELEMS]: Sized,
   |          ^^^^^^^^^^^^ cannot perform const operation using `I`
   |
   = note: type parameters may not be used in const expressions
   = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
  --> /home/runner/work/glacier/glacier/ices/83288.rs:45:20
   |
45 |     pub data: [u8; I::NUM_ELEMS],
   |                    ^^^^^^^^^^^^ cannot perform const operation using `I`
   |
   = note: type parameters may not be used in const expressions
   = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
  --> /home/runner/work/glacier/glacier/ices/83288.rs:53:10
   |
53 |     [u8; I::NUM_ELEMS]: Sized,
   |          ^^^^^^^^^^^^ cannot perform const operation using `I`
   |
   = note: type parameters may not be used in const expressions
   = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
  --> /home/runner/work/glacier/glacier/ices/83288.rs:54:10
   |
54 |     [u8; J::NUM_ELEMS]: Sized,
   |          ^^^^^^^^^^^^ cannot perform const operation using `J`
   |
   = note: type parameters may not be used in const expressions
   = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
  --> /home/runner/work/glacier/glacier/ices/83288.rs:55:11
   |
55 |     [u8; <I as Concat<J>>::Output::NUM_ELEMS]: Sized,
   |           ^ cannot perform const operation using `I`
   |
   = note: type parameters may not be used in const expressions
   = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
  --> /home/runner/work/glacier/glacier/ices/83288.rs:55:23
   |
55 |     [u8; <I as Concat<J>>::Output::NUM_ELEMS]: Sized,
   |                       ^ cannot perform const operation using `J`
   |
   = note: type parameters may not be used in const expressions
   = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions

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(const_generics, const_evaluatable_checked)]
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: constant expression depends on a generic parameter
  --> /home/runner/work/glacier/glacier/ices/83288.rs:61:25
   |
61 |             data: [0u8; <I as Concat<J>>::Output::NUM_ELEMS],
   |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this may fail depending on what value the parameter takes

error: aborting due to 10 previous errors

Some errors have detailed explanations: E0557, E0601.
For more information about an error, try `rustc --explain E0557`.
==============

=== stdout ===
=== stderr ===
error[E0557]: feature has been removed
 --> /home/runner/work/glacier/glacier/ices/83288.rs:2:12
  |
2 | #![feature(const_generics, const_evaluatable_checked)]
  |            ^^^^^^^^^^^^^^ feature has been removed
  |
  = note: removed in favor of `#![feature(adt_const_params]` and `#![feature(generic_const_exprs)]`

error[E0557]: feature has been removed
 --> /home/runner/work/glacier/glacier/ices/83288.rs:2:28
  |
2 | #![feature(const_generics, const_evaluatable_checked)]
  |                            ^^^^^^^^^^^^^^^^^^^^^^^^^ feature has been removed
  |
  = note: renamed to `generic_const_exprs`

error: generic parameters may not be used in const operations
  --> /home/runner/work/glacier/glacier/ices/83288.rs:43:10
   |
43 |     [u8; I::NUM_ELEMS]: Sized,
   |          ^^^^^^^^^^^^ cannot perform const operation using `I`
   |
   = note: type parameters may not be used in const expressions
   = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
  --> /home/runner/work/glacier/glacier/ices/83288.rs:45:20
   |
45 |     pub data: [u8; I::NUM_ELEMS],
   |                    ^^^^^^^^^^^^ cannot perform const operation using `I`
   |
   = note: type parameters may not be used in const expressions
   = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
  --> /home/runner/work/glacier/glacier/ices/83288.rs:53:10
   |
53 |     [u8; I::NUM_ELEMS]: Sized,
   |          ^^^^^^^^^^^^ cannot perform const operation using `I`
   |
   = note: type parameters may not be used in const expressions
   = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
  --> /home/runner/work/glacier/glacier/ices/83288.rs:54:10
   |
54 |     [u8; J::NUM_ELEMS]: Sized,
   |          ^^^^^^^^^^^^ cannot perform const operation using `J`
   |
   = note: type parameters may not be used in const expressions
   = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
  --> /home/runner/work/glacier/glacier/ices/83288.rs:55:11
   |
55 |     [u8; <I as Concat<J>>::Output::NUM_ELEMS]: Sized,
   |           ^ cannot perform const operation using `I`
   |
   = note: type parameters may not be used in const expressions
   = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
  --> /home/runner/work/glacier/glacier/ices/83288.rs:55:23
   |
55 |     [u8; <I as Concat<J>>::Output::NUM_ELEMS]: Sized,
   |                       ^ cannot perform const operation using `J`
   |
   = note: type parameters may not be used in const expressions
   = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions

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(const_generics, const_evaluatable_checked)]
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: constant expression depends on a generic parameter
  --> /home/runner/work/glacier/glacier/ices/83288.rs:61:25
   |
61 |             data: [0u8; <I as Concat<J>>::Output::NUM_ELEMS],
   |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this may fail depending on what value the parameter takes

error: aborting due to 10 previous errors

Some errors have detailed explanations: E0557, E0601.
For more information about an error, try `rustc --explain E0557`.
==============
@Alexendoo Alexendoo closed this Sep 1, 2021
@Alexendoo Alexendoo deleted the autofix/ices/83288.rs branch September 1, 2021 16:26
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