Skip to content

Commit 7804644

Browse files
committed
add tests
1 parent c10ad0d commit 7804644

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// check-pass
2+
3+
const fn foo<T>() -> usize {
4+
if std::mem::size_of::<*mut T>() < 8 { // size of *mut T does not depend on T
5+
std::mem::size_of::<T>()
6+
} else {
7+
8
8+
}
9+
}
10+
11+
fn test<T>() {
12+
let _ = [0; foo::<T>()];
13+
//~^ WARN cannot use constants which depend on generic parameters in types
14+
//~| WARN this was previously accepted by the compiler but is being phased out
15+
}
16+
17+
fn main() {}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
warning: cannot use constants which depend on generic parameters in types
2+
--> $DIR/function-call.rs:12:17
3+
|
4+
LL | let _ = [0; foo::<T>()];
5+
| ^^^^^^^^^^
6+
|
7+
= note: `#[warn(const_evaluatable_unchecked)]` on by default
8+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
9+
= note: for more information, see TODO
10+
11+
warning: 1 warning emitted
12+

0 commit comments

Comments
 (0)