2020-08-06 15:32:12 -05:00
|
|
|
// check-pass
|
2020-09-08 09:47:19 -05:00
|
|
|
#![warn(const_evaluatable_unchecked)]
|
2020-08-06 15:32:12 -05:00
|
|
|
|
|
|
|
const fn foo<T>() -> usize {
|
|
|
|
if std::mem::size_of::<*mut T>() < 8 { // size of *mut T does not depend on T
|
|
|
|
std::mem::size_of::<T>()
|
|
|
|
} else {
|
|
|
|
8
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn test<T>() {
|
|
|
|
let _ = [0; foo::<T>()];
|
|
|
|
//~^ WARN cannot use constants which depend on generic parameters in types
|
|
|
|
//~| WARN this was previously accepted by the compiler but is being phased out
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|