Skip to content

Commit 0f792ab

Browse files
committed
Add a test for failed inference of const types
1 parent 5310801 commit 0f792ab

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#![feature(const_generics)]
2+
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
3+
4+
// We should probably be able to infer the types here. However, this test is checking that we don't
5+
// get an ICE in this case. It may be modified later to not be an error.
6+
7+
struct Foo<const NUM_BYTES: usize>(pub [u8; NUM_BYTES]);
8+
9+
fn main() {
10+
let _ = Foo::<3>([1, 2, 3]); //~ ERROR type annotations needed
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
2+
--> $DIR/cannot-infer-type-for-const-param.rs:1:12
3+
|
4+
LL | #![feature(const_generics)]
5+
| ^^^^^^^^^^^^^^
6+
7+
error[E0282]: type annotations needed
8+
--> $DIR/cannot-infer-type-for-const-param.rs:10:19
9+
|
10+
LL | let _ = Foo::<3>([1, 2, 3]);
11+
| ^ cannot infer type for `{integer}`
12+
13+
error: aborting due to previous error
14+
15+
For more information about this error, try `rustc --explain E0282`.

0 commit comments

Comments
 (0)