Skip to content

Commit 5310801

Browse files
committed
Add a test for invalid const arguments
1 parent 385d012 commit 5310801

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
use std::convert::TryInto;
2+
3+
struct S;
4+
5+
fn main() {
6+
let _: u32 = 5i32.try_into::<32>().unwrap(); //~ ERROR wrong number of const arguments
7+
S.f::<0>(); //~ ERROR no method named `f`
8+
S::<0>; //~ ERROR wrong number of const arguments
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
error[E0107]: wrong number of const arguments: expected 0, found 1
2+
--> $DIR/invalid-const-arg-for-type-param.rs:6:34
3+
|
4+
LL | let _: u32 = 5i32.try_into::<32>().unwrap();
5+
| ^^ unexpected const argument
6+
7+
error[E0599]: no method named `f` found for type `S` in the current scope
8+
--> $DIR/invalid-const-arg-for-type-param.rs:7:7
9+
|
10+
LL | struct S;
11+
| --------- method `f` not found for this
12+
...
13+
LL | S.f::<0>();
14+
| ^
15+
16+
error[E0107]: wrong number of const arguments: expected 0, found 1
17+
--> $DIR/invalid-const-arg-for-type-param.rs:8:9
18+
|
19+
LL | S::<0>;
20+
| ^ unexpected const argument
21+
22+
error: aborting due to 3 previous errors
23+
24+
Some errors have detailed explanations: E0107, E0599.
25+
For more information about an error, try `rustc --explain E0107`.

0 commit comments

Comments
 (0)