Skip to content

Commit 359031e

Browse files
committed
add generic param mismatch test
1 parent d76cdb0 commit 359031e

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/generic-param-mismatch.rs:7:5
3+
|
4+
LL | fn test<const N: usize, const M: usize>() -> [u8; M] {
5+
| ------- expected `[u8; M]` because of return type
6+
LL | [0; N]
7+
| ^^^^^^ expected `M`, found `N`
8+
|
9+
= note: expected array `[u8; M]`
10+
found array `[u8; N]`
11+
12+
error: aborting due to previous error
13+
14+
For more information about this error, try `rustc --explain E0308`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/generic-param-mismatch.rs:7:5
3+
|
4+
LL | fn test<const N: usize, const M: usize>() -> [u8; M] {
5+
| ------- expected `[u8; M]` because of return type
6+
LL | [0; N]
7+
| ^^^^^^ expected `M`, found `N`
8+
|
9+
= note: expected array `[u8; M]`
10+
found array `[u8; N]`
11+
12+
error: aborting due to previous error
13+
14+
For more information about this error, try `rustc --explain E0308`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// revisions: full min
2+
#![cfg_attr(full, allow(incomplete_features))]
3+
#![cfg_attr(full, feature(const_generics))]
4+
#![cfg_attr(min, feature(min_const_generics))]
5+
6+
fn test<const N: usize, const M: usize>() -> [u8; M] {
7+
[0; N] //~ ERROR mismatched types
8+
}
9+
10+
fn main() {}

0 commit comments

Comments
 (0)