mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-02 03:33:59 +00:00
add tests
This commit is contained in:
parent
c10ad0d888
commit
7804644863
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 New Issue
Block a user