min_const_generics: allow ty param in repeat expr
This commit is contained in:
parent
8f0fa9d51f
commit
4a15a25662
9 changed files with 192 additions and 38 deletions
|
@ -1,5 +1,7 @@
|
|||
#![feature(min_const_generics)]
|
||||
|
||||
use std::mem::size_of;
|
||||
|
||||
fn test<const N: usize>() {}
|
||||
|
||||
fn ok<const M: usize>() -> [u8; M] {
|
||||
|
@ -22,6 +24,24 @@ fn break3<const N: usize>() {
|
|||
//~^ ERROR generic parameters may not be used in const operations
|
||||
}
|
||||
|
||||
struct BreakTy0<T>(T, [u8; { size_of::<*mut T>() }]);
|
||||
//~^ ERROR generic parameters may not be used in const operations
|
||||
|
||||
struct BreakTy1<T>(T, [u8; { { size_of::<*mut T>() } }]);
|
||||
//~^ ERROR generic parameters may not be used in const operations
|
||||
|
||||
fn break_ty2<T>() {
|
||||
let _: [u8; size_of::<*mut T>() + 1];
|
||||
//~^ ERROR generic parameters may not be used in const operations
|
||||
}
|
||||
|
||||
fn break_ty3<T>() {
|
||||
let _ = [0; size_of::<*mut T>() + 1];
|
||||
//~^ WARN cannot use constants which depend on generic parameters in types
|
||||
//~| WARN this was previously accepted by the compiler but is being phased out
|
||||
}
|
||||
|
||||
|
||||
trait Foo {
|
||||
const ASSOC: usize;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue