Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test for invalid const arguments
- Loading branch information
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
src/test/ui/const-generics/invalid-const-arg-for-type-param.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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
25
src/test/ui/const-generics/invalid-const-arg-for-type-param.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |