Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
forbid complex types for generic parameters
- Loading branch information
Showing
3 changed files
with
80 additions
and
13 deletions.
There are no files selected for viewing
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
18 changes: 18 additions & 0 deletions
18
src/test/ui/const-generics/min_const_generics/complex-types.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,18 @@ | ||
#![feature(min_const_generics)] | ||
|
||
struct Foo<const N: [u8; 0]>; | ||
//~^ ERROR using `[u8; 0]` as const generic parameters is forbidden | ||
|
||
struct Bar<const N: ()>; | ||
//~^ ERROR using `()` as const generic parameters is forbidden | ||
|
||
#[derive(PartialEq, Eq)] | ||
struct No; | ||
|
||
struct Fez<const N: No>; | ||
//~^ ERROR using `No` as const generic parameters is forbidden | ||
|
||
struct Faz<const N: &'static u8>; | ||
//~^ ERROR using `&'static u8` as const generic parameters is forbidden | ||
|
||
fn main() {} |
34 changes: 34 additions & 0 deletions
34
src/test/ui/const-generics/min_const_generics/complex-types.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,34 @@ | ||
error: using `[u8; 0]` as const generic parameters is forbidden | ||
--> $DIR/complex-types.rs:3:21 | ||
| | ||
LL | struct Foo<const N: [u8; 0]>; | ||
| ^^^^^^^ | ||
| | ||
= note: the only supported types are integers, `bool` and `char` | ||
|
||
error: using `()` as const generic parameters is forbidden | ||
--> $DIR/complex-types.rs:6:21 | ||
| | ||
LL | struct Bar<const N: ()>; | ||
| ^^ | ||
| | ||
= note: the only supported types are integers, `bool` and `char` | ||
|
||
error: using `No` as const generic parameters is forbidden | ||
--> $DIR/complex-types.rs:12:21 | ||
| | ||
LL | struct Fez<const N: No>; | ||
| ^^ | ||
| | ||
= note: the only supported types are integers, `bool` and `char` | ||
|
||
error: using `&'static u8` as const generic parameters is forbidden | ||
--> $DIR/complex-types.rs:15:21 | ||
| | ||
LL | struct Faz<const N: &'static u8>; | ||
| ^^^^^^^^^^^ | ||
| | ||
= note: the only supported types are integers, `bool` and `char` | ||
|
||
error: aborting due to 4 previous errors | ||
|