Skip to content

Commit

Permalink
Add a test for invalid const arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
varkor committed May 10, 2019
1 parent 385d012 commit 5310801
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
@@ -0,0 +1,9 @@
use std::convert::TryInto;

struct S;

fn main() {
let _: u32 = 5i32.try_into::<32>().unwrap(); //~ ERROR wrong number of const arguments
S.f::<0>(); //~ ERROR no method named `f`
S::<0>; //~ ERROR wrong number of const arguments
}
25 changes: 25 additions & 0 deletions src/test/ui/const-generics/invalid-const-arg-for-type-param.stderr
@@ -0,0 +1,25 @@
error[E0107]: wrong number of const arguments: expected 0, found 1
--> $DIR/invalid-const-arg-for-type-param.rs:6:34
|
LL | let _: u32 = 5i32.try_into::<32>().unwrap();
| ^^ unexpected const argument

error[E0599]: no method named `f` found for type `S` in the current scope
--> $DIR/invalid-const-arg-for-type-param.rs:7:7
|
LL | struct S;
| --------- method `f` not found for this
...
LL | S.f::<0>();
| ^

error[E0107]: wrong number of const arguments: expected 0, found 1
--> $DIR/invalid-const-arg-for-type-param.rs:8:9
|
LL | S::<0>;
| ^ unexpected const argument

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0107, E0599.
For more information about an error, try `rustc --explain E0107`.

0 comments on commit 5310801

Please sign in to comment.