Skip to content

Commit

Permalink
Add a test for failed inference of const types
Browse files Browse the repository at this point in the history
  • Loading branch information
varkor committed May 10, 2019
1 parent 5310801 commit 0f792ab
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/test/ui/const-generics/cannot-infer-type-for-const-param.rs
@@ -0,0 +1,11 @@
#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash

// We should probably be able to infer the types here. However, this test is checking that we don't
// get an ICE in this case. It may be modified later to not be an error.

struct Foo<const NUM_BYTES: usize>(pub [u8; NUM_BYTES]);

fn main() {
let _ = Foo::<3>([1, 2, 3]); //~ ERROR type annotations needed
}
@@ -0,0 +1,15 @@
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
--> $DIR/cannot-infer-type-for-const-param.rs:1:12
|
LL | #![feature(const_generics)]
| ^^^^^^^^^^^^^^

error[E0282]: type annotations needed
--> $DIR/cannot-infer-type-for-const-param.rs:10:19
|
LL | let _ = Foo::<3>([1, 2, 3]);
| ^ cannot infer type for `{integer}`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0282`.

0 comments on commit 0f792ab

Please sign in to comment.