Support as casts in abstract consts
This commit is contained in:
parent
dda4a881e0
commit
8e7299dfcd
7 changed files with 66 additions and 14 deletions
|
|
@ -0,0 +1,13 @@
|
|||
#![feature(const_evaluatable_checked, const_generics)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
trait Evaluatable<const N: u128> {}
|
||||
impl<const N: u128> Evaluatable<N> for () {}
|
||||
|
||||
struct Foo<const N: u8>([u8; N as usize])
|
||||
//~^ Error: unconstrained generic constant
|
||||
//~| help: try adding a `where` bound using this expression: `where [(); N as usize]:`
|
||||
where
|
||||
(): Evaluatable<{N as u128}>;
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
error: unconstrained generic constant
|
||||
--> $DIR/abstract-const-as-cast-2.rs:7:25
|
||||
|
|
||||
LL | struct Foo<const N: u8>([u8; N as usize])
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: try adding a `where` bound using this expression: `where [(); N as usize]:`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
// check-pass
|
||||
#![feature(const_evaluatable_checked, const_generics)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
struct Foo<const N: u8>([u8; N as usize])
|
||||
where
|
||||
[(); N as usize]:;
|
||||
|
||||
fn main() {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue