forbid generic params in complex consts
This commit is contained in:
parent
375bccb8b3
commit
289e5fca7e
8 changed files with 194 additions and 18 deletions
|
@ -0,0 +1,37 @@
|
|||
#![feature(min_const_generics)]
|
||||
|
||||
fn test<const N: usize>() {}
|
||||
|
||||
fn ok<const M: usize>() -> [u8; M] {
|
||||
[0; { M }]
|
||||
}
|
||||
|
||||
struct Break0<const N: usize>([u8; { N + 1 }]);
|
||||
//~^ ERROR generic parameters must not be used inside of non trivial constant values
|
||||
|
||||
struct Break1<const N: usize>([u8; { { N } }]);
|
||||
//~^ ERROR generic parameters must not be used inside of non trivial constant values
|
||||
|
||||
fn break2<const N: usize>() {
|
||||
let _: [u8; N + 1];
|
||||
//~^ ERROR generic parameters must not be used inside of non trivial constant values
|
||||
}
|
||||
|
||||
fn break3<const N: usize>() {
|
||||
let _ = [0; N + 1];
|
||||
//~^ ERROR generic parameters must not be used inside of non trivial constant values
|
||||
}
|
||||
|
||||
trait Foo {
|
||||
const ASSOC: usize;
|
||||
}
|
||||
|
||||
impl<const N: usize> Foo for [u8; N] {
|
||||
const ASSOC: usize = N + 1;
|
||||
//~^ ERROR generic parameters must not be used inside of non trivial constant values
|
||||
// FIXME(min_const_generics): We probably have to allow this as we can
|
||||
// already allow referencing type parameters here on stable.
|
||||
}
|
||||
|
||||
|
||||
fn main() {}
|
Loading…
Add table
Add a link
Reference in a new issue