add tests

This commit is contained in:
Bastian Kauschke 2020-08-06 22:32:12 +02:00
parent c10ad0d888
commit 7804644863
3 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,17 @@
// check-pass
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() {}

View File

@ -0,0 +1,12 @@
warning: cannot use constants which depend on generic parameters in types
--> $DIR/function-call.rs:12:17
|
LL | let _ = [0; foo::<T>()];
| ^^^^^^^^^^
|
= note: `#[warn(const_evaluatable_unchecked)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see TODO
warning: 1 warning emitted