add tests
This commit is contained in:
parent
c10ad0d888
commit
7804644863
3 changed files with 29 additions and 0 deletions
17
src/test/ui/const_evaluatable/function-call.rs
Normal file
17
src/test/ui/const_evaluatable/function-call.rs
Normal 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() {}
|
12
src/test/ui/const_evaluatable/function-call.stderr
Normal file
12
src/test/ui/const_evaluatable/function-call.stderr
Normal 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
|
||||||
|
|
Loading…
Reference in a new issue